Play@Work

Sunday, January 30, 2005

Knots and Crosses.

Hari was recently showing me some Knots-and-Crosses implementation he had coded. He talked about how his players had a Strategy injected into them while they were created, so that the game playing logic was kind of pluggable.

Sounded damn interesting.

So I decided to code my own implementation of Knots-and-Crosses. And its been a pretty interesting so far. Its nice to see how simple problems like this can throw a zillion design decisions at you. Very interesting to see how an Object model comes out of such an exercise.

After 3-4 stabs at this and with some design changes, I have come at this object model.

The objects that I have are

Game
Board
Consequence
Player

Game: basically you can register 2 players and a board with the game. And the game will alternate the players and inform the players that they can make their move.
Board: is pretty dumb. You can mark a location on the board. But the board can also return the consequence of a particular move.
Consequence: copied this Term from Haris Object model, cause it sounded sooo interesting :), but I think the behaviour is different. Basically after a move you can get the consequence of that move from the board and you can perform various queries on it.
Player: As of now I dont have any interesting behaviour here. Like Hari's model, I want to be able to plug in a Strategy that the player can use to play an intelligent game.

Looks a little bloated. Have to see if I can fine tune this.
Tomorrow Hari and me will be swapping notes on how we are proceeding with our implementations.

1 Comments:

  • hi

    I've also started on some similar lines for knots and crosses, though dont have much experience codig. I'm E&C btech, so tried something of "weights",. Can u send me what ever you've done. At least the logic part to lorddj@gmail.com

    Thanks
    Deepak

    By Anonymous Anonymous, at 10:08 AM  

Post a Comment

<< Home