It Pays to Think About Things
January 21st, 2009
I posted this morning about the issues around converting my board object to a 2-player system. After the post I started reading through the code trying to decide how to proceed. After thinking about things for a while I came to an important realisation: my single player game is actually a special case of my two player game! I’d been thinking about the problem backwards!
What this means is that I can convert the board so that it always thinks it’s running a 2-player game. It will make calls to the game state to ask it whose turn it is, etc. However, in the single player game, the game state always returns that’s it’s player 1′s turn.
The nice thing about this is that there will be very little player-specific code in the board. There will be some, but it should be pretty minimal.
I’ve spent the rest of the day working my way through the board code updating things and it’s going quite well so far. I also uncovered and fixed a major bug in my search code in the process. It’s feeling like a good day.
Owen






Wow, a game where the single player is a specific case of multiplayer… fancy that!
[yoda] Much anger in you, I sense… [/yoda]
If, at the start, I had thought I’d actually have time to implement the 2-player mode, I might have had the foresight to build it this way in the first place.