Written in "C", in 2014 for the Commodore 64 and ported to CX16 in 2020. I wanted to know how hard it would be to make a chess AI.
I am not a great chess player, nor did I research chess engines, so I made things up as I went. The end result is this chess
which by any standards of chess, is not a good AI opponent. However, it's there and it's playable.
Use and keys
The user controls an on-screen cursor. The cursor changes color to indicate
a state. The colors for selection are:
Green - the piece can be selected
Red - The piece cannot be selected as it doesn't have valid moves
Purple - Empty tile or piece on the other side
Blue - The currently selected piece
Cyan - A valid destination for the currently selected piece
To move the cursor, use the cursor keys. To select a piece, press the RETURN
key while the piece is selected. To deselect the piece, press RETURN on the
same piece again, or press ESC.
To bring up the menu, press the M key, or the ESC key when no piece is
selected. Pressing ESC in a menu backs out of the menu, to the previous
menu or back to the game. Press RETURN to select a menu item and use the up
and down cursor keys to change the selection.
While a side is under human control, there are a few more options. Press B to
toggle on/off a state showing on every tile how many of both black and white's
pieces can attack that tile. Pressing A will toggle a highlight of all of the
pieces on the opposing side that attack the selected tile. Pressing D will
toggle a highlight of all the pieces on the side currently playing's side that
can defend the selected tile. All three of these options basically give a
visual representation of the Game Database. The colors are: For attackers Cyan
and for defenders Red.
Lastly, the game has an Undo/Redo stack that tracks the last 254 moves. Pressing
U will undo the last move and R will redo the last move. In an AI/Human game,
the undo will undo the last AI and human player move, so the human player can
make a different move.