Page 1 of 1

New game uploaded: cc65 Chess

Posted: Sun Jul 12, 2020 7:04 am
by Getafix



cc65 Chess




View File






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.






 

New game uploaded: cc65 Chess

Posted: Sun Sep 13, 2020 8:17 pm
by geek504

Found two bugs in your game... #1: D7-D5 (Black move) became a White pawn.

x16_chess_bug1.PNG.55bdcf951330bbaab0516ec1edc803f6.PNG

#2: E7xF6 This pawn capture came out of nowhere, there wasn't any pawn on E7... and took my Bishop for free!

x16_chess_bug2.PNG.50e8fbc31a9dc0c7bb35724b07eb8ab3.PNG

But alas, that didn't matter... the final position:

x16_chess.PNG.d02ad64d2fb108770813e0f9ee113fb5.PNG

Thank you for a good game of chess!


New game uploaded: cc65 Chess

Posted: Mon Sep 14, 2020 4:17 pm
by Getafix

I did spend a bit of time looking at the "engine" and as I suspected, there are bugs for sure.  Casteling can cause grief and corrupt the DB, for example.

It may be worth my while to fix the bugs but I think I'd really like to rewrite the whole engine and just keep the interface to the UI (and thus have all the versions still work), now that I have been shown some chess programming resources.

I don't need the game to be great, but it would be nice if it could play a fairly descent game of chess. 

I am just busy with a couple of other things so I think I'll just leave it as is, for now. 


New game uploaded: cc65 Chess

Posted: Mon Sep 14, 2020 4:53 pm
by SlithyMatt

I'm curious as to why your grid markers don't use the standard character tiles. It looks like there is plenty of room for them. Is that a bitmap?


New game uploaded: cc65 Chess

Posted: Mon Sep 14, 2020 5:08 pm
by Getafix

A couple of reasosn it looks like it does.  I was trying to use the CX16 APIs as much as I could (this was also a learning exercise for me).  The grid markers are drawn using the  Graph Put Char API, which uses GEOS fonts.  If I remember correctly, the put graph char API uses a proportional font, which is not what I needed for the menu or the move log.  The Console API did use a mono-space font but the API wasn't well suited to how the menu code wanted to work, so I ended up using the regular text in Layer 1 for the menu and log, and the graph API to put the grid markers into Layer 0.  

I think you can add your own GEOS font for the Graph API but I don't know anything about GEOS so I didn't explore that route any further.   Also, if I remember correctly, the built-in (regular text) font on Layer 1 is a little too wide to look nice when used as a grid marker.

When I look at the screenshot now, it doesn't look great.  It's probably worthwhile looking into GEOS fonts and making or finding a font that works for all cases.