Log In  


Cart #quickchessyness-4 | 2022-09-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
11

A snappy little chess engine

1.41 small bug fix
1.4 Fixes an issue with castling and improves king safety.
1.3 Brings some small fixes and improvements.

11


1

This is a wonderful and challenging chess! I keep losing, sadly…


1

I played this and remembered why I hate playing against chess AIs so much. Which is to say you did a great job making it good.


1

Very nice that you managed to ship an opening library with the game! The first moves are indeed snappy.

Can you give a few technical details about the engine? How deep does it search for moves? And is it mostly focused on material and checkmate or does it have other heuristics?


1

Nice work, impressively snappy, and fun to play against!

fyi: I ran into a crash bug on my final move (see image below). If it helps you figure out the root cause: this was on the move I checkmated, which happened to be by promoting a pawn, and the enemy king was the only piece left on the board when I did that (and was on the top row of the board).


Nice to see some comments for this. I'll look into the bug. I don't think I was able to bug test dominating the engine that well!

For general info on the engine:
To be fast it is very dumb. The first thing it does is look to see if it can do a forcing checkmate and that is the furthest ahead it looks and is when you see the spinning icon in the corner at the start of it's moves. It only looks 4 moves (or 2 depending how you are counting) as I recall (I might have increased it) and it stops if the opponent has too many options to get out of check.

When you see it cycling through the pieces it is checking all it's moves and all possible opponents moves and does a simple point adding calc. However, to make it smarter, despite the shallow search, there are functions it then runs through to check for forks and pins and mybe some other stuff (I don't remember what code I left in in the end) with relatively with little cost compared to a deeper search.

Finally once it picks a move it runs a check to make sure it doesn't lead to a one move checkmate.

The idea for this engine was to make it good without it doing a deep search by adding functions to check for things like forks but there are many issues as a result. For example if you threaten to take the queen and the queen is attacked on any square it can move it might take a pawn so at least it takes something, when the best move might be to go to a square where the queen is can be taken but would result in a queen trade. I've theorized about how to (sometimes) fix this without doing a deeper search but I would have to return to working on it.

It does well against the other pico8 chess engine I know of, Pico-Checkmate. Seems Pico-Checkmate is actually very weak at delivering checkmate. Pico-Checkmate takes a long time with moves and will typically gets in much better positions but then either looses to a forcing checkmate or it goes into an endgame where it struggles to deliver checkmate.

*EDIT I just looked at the code for the first time in a long time and it values having as many squares as possible covered, has a small preference for giving check and likes to move pawns to attack knights, bishops, queens and rooks. Not sure it checks for pawn forks anywhere. I wrote code just for that but must have trimmed it due to limits.



[Please log in to post a comment]