[Game] Simple Chess

Hello,

I’ve created pretty simple chess for Pokitto, using SAF and my chess library/engine smallchesslib found here. Graphically it’s nothing impressive, just very simple interface, I was focused on just making Pokitto play chess – if you want, you can use my library to create something more shiny. Of course everything is CC0, public domain.

chess

firmware.bin (63.7 KB)

source code

The library/engine is another one of my KISS/suckless C libraries, it supports all you need for playing chess and manipulating some standard chess formats plus it includes a moderately strong AI – the strength depends on settings and hardware, I’ve let it play as a bot on lichess.org under the nickname smolchessbot and it achieved an ELO of about 1600 (well not really ELO but “Glicko” rating). On Pokitto I’ve limited AI to maximum level of 3 (full search to depth of 2 plys with possibility to extend to another 2 plys for interesting moves) which is a little weaker than this, it’s because of the CPU speed, something stronger would take too long to compute a move. In the future I’ll probably try to optimize and improve the AI, e.g. with transposition tables, so maybe it will get stronger and faster over time.

If anyone’s more interested in chess programming, there’s a hugely useful and interesting chess programming wiki.

Some features and limitation of this program:

  • Graphics is extremely simple.
  • All rules of chess are implemented, even the lesser known such as en passant etc. 50 move rule also applies. Draw via repetition is also implemented, but for simplicity only consecutive positions are considered.
  • Board is automatically rotated if the game thinks it should be rotated.
  • Each player can be either human or AI of strength 1 to 3. This can be changed any time during play.
  • Sometimes the stronger AI needs more time to compute the move and there is no indication of it working so it seems frozen, just wait :slight_smile:
  • On Pokitto if two AIs play against each other, you have to press A after each move. This is basically for technical reasons and due to simplicity of SAF (basically if I let AIs just move as they wish there’s no “multithreading” and when AI is computing for a long time it delays a frame for very long and it messes up rendering so that you wouldn’t see the game unwind until it would end).
  • You can undo moves with C.
  • After the game ends the whole game is being repeatedly replayed in the background so that you can write it down.
  • There are also simple chess variant: chess 960 (Fisher random, but without castling), horde and knights vs knights.
12 Likes

Oh wow!!! Chess! This is something I often wondered about if a chess engine would be feasible

1 Like

Dude heck yes!! Can’t wait to try it out! I love chess :D!

2 Likes

If you’re on liches you can also challenge the bot, he’s online most of the time (when I have my laptop on).

2 Likes

Nice! Time to test my skill Vs Pokitto.

4 Likes

Wow, look at the code. Its 600 lines with some vertical spacing. I am not I can write a menu system in less lines than that!

4 Likes

@drummyfish hey hey hey. The Queen and the King are the wrong way around in the start of the game

The king is on the colour (white king on white square). I just confirmed that it is indeed the wrong way around in this chess game

It is supposed to be like this:
image

however, in your game (the selected piece is the queen and should be able to move forwards more than 1 square)

No, you’ve got it wrong :slight_smile: Queen starts on its color.

2 Likes

gosh. does this mean I have set up the board wrong all my life?

lol

5 Likes

That board does actually show the white queen on the white tile and the black queen on the black tile.

The queen has the pointy tiara-style crown (♕, ♛) the king has the more domed crown (♔, ♚).

1 Like