Thursday, May 5, 2011

Nanook chess from scratch - First step : UCI protocol, move generator and alpha-beta

I want for this version of Nanook chess to avoid from the beginning all kind of moves bugs that we often detect too late. Beginning with a stable move generator and a well working alpha-beta algorithm is the best way to correctly progress forward.

So, first of all, I choose a 0x88 board representation : It's a little different from the one used in the previous version of Nanook, but it seems to me to be a better way. Then I developed the move generator, nothing complicated at this point : just need to make sure that special move as castling/en passant/promotion are well understood. An finally, I implemented a basic alpha-beta algorithm with a really simple evaluation function (counting score of captured pieces, no score for position).

Before to make a step forward, I need to make sure that all these points work perfectly, the best way to do it is to implement now the UCI protocol, in order to be able to test all kind of situation with fen positions.

UCI protocol implements a lot of commands, basically at this point it will be interesting to integrate the commands position/info/bestmove/etc... (options and timer can be done later), the most important is the possibility to load a fen position. Believe it or not, but previous version of Nanook was not able to load a fen position, I never implemented it ! Testing a position was possible only using startpos...

UCI protocol - Analysing a given FEN position via command line
As soon as these commands are understood, the engine can reply with the best move, and some other informations... It should be interesting also to manage "go infinite" and "stop": when you will launch test analysis, the GUI might use these commands. The best way is probably to create a Thread where you launch your analysis, so you can continue to read input commands from GUI and wait for the "stop" signal.

Ok, so now Nanook Chess implements all these points, I just need to load and test some specific fen positions via UCI to make sure it didn't make an illegal move. I was thinking to do my own GUI engine with a list of fen positions and their expected moves, but it seems Arena give this possibility with the "engine analysis", you can load an EPD file (EPD is a format where you can find a list of fen positions and the move expected to be played for each of them), the engine will analyse these moves, and finally it will display which moves the engine success and fails. Great ! So the only thing I need to do is to create an EPD list with positions that Nanook should understand at this point of development (get a "free" piece, find a mate, escape a mate, test a pat, promotion, ...), and I will go forward only when it will success with 100%. This seems to be a very good way to proceed : for each step of the project, I will check again all EPD positions, and develop new ones, then Nanook should never have a worst score than the step before.

I'm now preparing an EPD list of fen (around 30 specific positions), I will probably test the engine today or tomorrow with it.

No comments:

Post a Comment