Tuesday, January 08, 2013

Reversi Sample Code

reversiOne of my earliest attempts at programming a computer to play against me was a version of Reversi I attempted some30+ years ago. Reversi is a great game for this as the rules are pretty simple. It is reasonably easy to determine the legal moves for starters. Not as easy perhaps as checkers but still pretty easy. Strategy is a bit more work than just picking a random legal move. Back then the graphics were ASCII and pretty basic. There was no mouse let along touch screen for indicating a move but none of that mattered.. I was interested in programming the strategy!

I’ve tried again now and again over the years but not for a while. Yesterday I came across a Reversi XAML/C# Windows Store Sample Game thanks to Coding 4 Fun. This is a fully blown fully functional Reversi game for the Windows Store (in other words what used to be called a Metro app) that runs on Windows 8 and Windows RT.

It’s one of those samples apps that works hard to demonstrate a whole lot of concepts and ideas. That can make reading the code a bit daunting especially for beginners. But I think doing so can be very worthwhile as a learning experience. I can is it as a larger project case study. I can also seeing it used as a base for trying to understand a bit about artificial intelligence.

You see the game is very compartmentalized and well organized. You can easily isolate the existing AI and either understand how it works (some good comments help) or replace it with your own.

There is also some good documentation at Developing Reversi, a Windows Store game in C# and XAML (Windows)

No comments: