12 May 2011

Forking Me!

I have decided to split my online persona into four areas: Work, Social, Music and Other.

This one is my "Other" blog, where I will be discussing techn stuff that's not work-related and anything left-field that don't fit in the other blogs.

AreaBlogTwitter
Work     http://howarddev.posterous.com @HowardDev
Social     http://hricketts.posterous.com @H_Ricketts
Music http://thetypesettersrevenge.posterous.com     @TypesettersRev
Other http://pragmatisation.posterous.com  
7 Feb 2011

It's a programmer cliché...

P15

But the coffee is good :-)
7 Feb 2011

Noughts and Crosses (Tic Tac Toe) Part 000 (Permutations)

I've been a developer for years and years and yet I've never written a game (apart from the simple Higher/Lower Number guessing game that was in the manual that came with my ZX81).

I have been following the brilliant blog of Sam Jack (http://blog.functionalfun.net) as he has been building a game for Windows Phone 7, so I thought I would start to explore the world of games myself.

One of the simplest of games is Noughts and Crosses (or Tic Tac Toe if you are American).

One of the core requirements of a Game Engine is to represent the board and to generate all the next possible/legal moves.  I have decided to represent the board as a single dimension array of integers (with zero meaning an empty position).  I have also crafted a quick IEnumerable method to get all the next legal moves, and implemented a simple "clone" capability.

I could have chosen a more limited range of values (0,1,2) to represent the "pieces" on the board, but I would then lose the ordering information.  Storing the board pieces as integers gives me the following options:

  • I can expand the game up to multi-player using a modulus operator (%) to split the pieces by player
  • I can implement extra rules (for larger board sizes) like: "Players cannot place adjacent pieces on two consecutive turns".

I have simply written some code to produce an exhaustive list of all the possible game moves (to complete board saturation, rather than to victory).

Running the numbers (to produce all combinations of board states) gives the following stats:

  • A board with 2 squares has 4 possible game states.
  • A board with 4 squares has 64 possible game states.
  • A board with 8 squares has 109600 possible game states.
  • A board with 9 squares has 986409 possible game states.

As you can see, efficient use of memory; rapid disposal of poor lines of play; and good use of multi-core parallelisation will be critical to getting good performance out of our Game Engine.  

To be continued...

 

20 Jan 2011

Hello

This is the customary first post that contains no real content. I am a developer with Contigo; an CTRM / ETRM (Commodity / Energy Trading and Risk Management) software company.

Howard Ricketts's Space

Work

I am a Developer at Contigo which is a software company making ETRM (Energy Trading and Risk Management) and Logistics web applications.

Follow me on twitter at:@howarddev
Follow contigo on twitter at:@contigonews