Wednesday, January 19, 2005

Monopoly Simulator

I have been working on a Monopoly Simulator for the past week or two. It's turning out to be an interesting project. At first I thought it would be interesting to simulate games to see if I could glean any strategic points, but a quick Google search turned up all kinds of Monopoly statistics. But, the more I thought about it, the more I thought it would be interesting to have a "pluggable" architecture so that different "players" could have different rule sets. Of course, because of my competitive nature, this quickly leaped to having people develop their own players with their own set of behavior rules (e.g. when they buy property, which properties they go after, trading, etc...) that could play against each other. On the other hand, I have a hard enough time finding people to play the regular Monopoly board game with me, much less code their own player rules in Java.

So, now I think I'm resigned to develop it just for learning's sake - which is sort of freeing.

I started out ok last week and identified which objects I would need and came up with what I thought would be a working model. Things were going ok, but then in typical form, I got a little excited about the whole thing and threw TDD out the window. Several lunch hours later, I had a Monopoly simulator that was "working" in that it actually simulated games and had a winner at the end, but I had no idea if it was working properly because I had no unit tests. The design also ended up in a rather unsatisfying mess with little room for expansion or flexibility. I need to refactor, but looking at it again I think I need to start over and just pull bits and pieces out as I need them.

I'm really interested in trying to integrate AOP in here somehow. I think in the area of generating statistics this will be great because that is certainly a cross-cutting concern. Each action in the game should be able to register some statistic of what just happened. Also, I'm thinking of using a rule engine for the player rules. That way, it's much easier to modify the player behavior using pseudo-english and, who knows, may even help get someone else to develop their own player.

More on this later.


No comments: