Hi everyone,
I wanted to see if I could program a Chess game for the Sony Reader. Here's what I have so far. This version only works in 2-player mode. However, it includes castling and en passant, you can choose which piece you get when you promote a pawn, and it automatically detects checkmate and stalemate (although it doesn't detect the 50-move type, just the "while I am not currently in check, there are no legal moves" type.)
Next step, if I have time (and I am not even sure that it is technically possible) is to include AI for a 1 player mode. We'll see..
Hope it works for you. It should work for both Touch and non-Touch readers (although it's pretty painful in non-Touch mode!) I have tested it successfully on my PRS-600.
Sincerely,
Ben.
P.S. Updated to fix graphics issue with non-Touch readers, as well as incorporating Mark Nord's suggestions: buttons 1-8 now move cursor, which is no longer the "hand" icon.
NEW UPDATE:
I have added an initial implementation of Artificial Intelligence! If you press the SIZE button, the reader will make a move for whoever's turn it is. You can therefore play the white pieces, and then press SIZE so that the reader will move for black. Or you can press SIZE so that the reader will move for white, and then you play the black pieces. Alternatively, you can keep pressing SIZE to watch the reader play against itself! Note, though, that there is no automatic mode. You have to press SIZE each time to make an AI move.
The fine print: the AI is not always very good, and it is quite slow. In "Slow mode", AI moves take between 30 and 60 seconds on my 600, and there is no indication that things are happening, so be patient! Also, I have noticed a rather nasty bug: check is not always recognised, or defended against, and the king can even move offensively into check. So if that happens to you, I am sorry! (Although, it can be fun to take the king and watch the game continue!) Since the AI was slotted into place (taken from p4wn on Sourceforge!) I don't think I will be able to track down these bugs... Alternatively, a completely different AI engine could be slotted in at a later stage.
MINOR FIX:
I have found a way to check for checkmate / stalemate no matter who moved last (human or AI), and so it should work in all situations now. (The AI may still move offensively into check, but you'll win as a result!)
I have also changed the default AI speed to "Medium". The AI is good enough and the speed is
much quicker than "Slow" mode.
LATEST UPDATE:
I have added an Auto Mode (thanks to code from Kartu!) which is on by default and a 1-level undo feature. The Auto Mode can be turned off using the NEXT button. It will cycle through the AI speeds (Auto On) then the AI speeds (Auto Off), etc. When Auto Mode is On, the reader will move Black. If you want to play the black pieces against the reader, turn the auto mode off, and use the SIZE button to force an AI move when it is White's turn.
As for undo, the Undo button takes the board back to before the latest White move. So this is good for White, not so good for Black. (In other words, if White makes a silly move and Black takes advantage of it, Undo reverts to before White's move. If Black makes a silly move, and then White takes advantage of it, Undo only goes back to before White's move - that is, after Black's silly move.) If people don't like that, I guess I can go back and implement a proper 2-move reversal!
TINY UPDATE: Undo now allows you to continue if your were in checkmate and you press undo.
ANOTHER TINY UPDATE: If you force an white AI move when Auto if On, the reader will now automatically do the Black move as you would expect.
UPDATE: Latest version now found in post
#145.