This C-code contains (most of) the evaluation function of the Gideon chess program (aka REBEL) that won the WCCCM Vancouver 1991 and WCCC Madrid 1992.

It is my first (and only) C-program after reading the first chapters of a book about C programming because there was time pressure to port the ARM RISC assembler code from the ChessMachine to the PC. Later versions (Rebel 6.0 and on) were written in assembler. Hence the C-code might be not what you expect just in case you wonder since I am not a typical C-guy. The code can be compiled with the GNU and Digital Mars compiler.

You can use the code in 2 ways:

1. build your own search around it.

2. insert it in your own existing engine.

Usuage

All it needs is the board in REBEL format as described below which you can communicate in 3 ways:

1. Use the REBEL format.

2. Make a quick conversion as demonstrated in TSCP (Tom Kerrigan Simple Chess Program), see example.

init() initializes a few things before the evaluation of the position can start, the most important table is the piece-list veldwz in order that we don't have to scan the full board with all its empty squares, just the pieces on the board only. veldwz from the start position looks like this:

Step2 - now thatbord2 andbord3are generated we can further evaluate the position, see source/eval2.c Once again via veldwz we evaluate king safety, pawn structure, weak paws, isolated pawns, double pawns, passed pawns, pawn pressure on weak | isolated pawns and unstoppable pawns. Thereafter the final score is calculated in the variable mp and returned. Late endgame cases such as KPK, WNBK etc. are handled seperately via wsom and zsom.

Last but not least with the information inbord2 andbord3 we extract the 2 highest hanging pieces (SEE) from the 2 tables with a simple table lookup into the varaiblesz2 and z5. These are exteremely handy for move ordering, just generate the captures on these squares first, of course after searching the move from the hash table first.

REBEL uses the value of 256 for a pawn so if you are using a different value (say 100) convert it back by: