Tuesday, January 24, 2012

Status update - making a chess move

I was sort of dreading implementing the move validation because it's a bit tedious. But then I had an idea - since the javascript I'm using to validate a PGN file already validates individual moves, I should be able to just hook into that somehow. I need to mention that my PGN validator, jChess 1.0, was written by Ben Marini - thank you, Ben, wherever you are, you saved me so much work! I didn't have to reorganize much in Ben's code, and I now have a new move validator. All my code had to do was generate a new move in algebraic notation format, pass it in to the jChess PGN move validator, and catch any exception. Ben's code doesn't actually trap bad moves, it just chokes on them - so I just catch the resulting exception to know that the move is no good. Could hardly have been easier - whew!

Next up - server coding!

No comments:

Post a Comment