Sunday, July 15, 2012

Back in the saddle

Wow, finally a breather so I can get back to programming?  Excellent!

Here's a screenshot of the NetReversi game so far.  It doesn't do anything yet (other than move the cursor), but some of the logic is built-in ready to be used:

Here's a little snippet of the code.  I'm currently using the Notepad++ editor:

Today I'm working on what might be the most difficult piece of this game - determining if a move is legal.

In Reversi, you play on a 8x8 board, with game discs that are black on one side, white on the other.  Like checkers, you and your opponent both have a color (white or black).  When you take one of your opponent's pieces, you turn it to your color by flipping it.

The way to take one of your opponent's pieces is by surrounding them on the board, either horizontally, vertically, or diagonally.  If you have one of your pieces on one side of your opponent's piece(s), and you place one of your pieces on an empty square adjacent to and on the other side of those opponent's pieces, you turn all the opponent's pieces in between to your color.  For a better explanation of the rules, you can consult Wikipedia's page on Reversi.

The thing is, since a capture can happen from any angle (horiz, vert, or diag), and since you have to circumscribe your opponent's pieces, it's actually a deceptively difficult algorithm to determine if a move is legal.  The best bet is probably to use a recursive function.

More to come, hopefully later today...

Sunday, July 1, 2012

Retrochallenge: Sharpening the Saw

After a week or two off, I'm getting back into the swing of things on my networked Reversi game for the Commodore 64.

The rules of Reversi are deceptively difficult to program.  I've been faced with creating a recursive algorithm to check whether a move is legal, and then flip the corresponding pieces accordingly.

In terms of development, I've decided on these tools at the moment:

  • CC65 C compiler for 6502-based systems (notably the C64)
  • Notepad++ for my code editor (probably will replace this part)
  • CC65 makefile for building/testing
  • VICE emulator for local testing (can't test network functions with this)
  • Real Commodore 128 and Flyer drive/network device for testing (have to move code to the device for testing)

My Retrochallenge goal is to have a working prototype of this game - a 0.1 version, if you will - by the end of July.  I'd better get coding!