Short internal description
- 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:
E1 | D1 | H1 | A1 | F1 C1 | G1 | B1 H2 | G2 | F2 | E2 | D2 | C2 | B2 | A2 | 0xff
E8 | D8 | H8 | A8 | F8 C8 | G8 | B8 H7 | G7 | F7 | E7 | D7 | C7 | B7 | A7 | 0xff
The area is sorted on piece-value and controlled by 4 pointers:
wpnt1 - start white pieces (0)
wpnt2 - start white pawns (8)
zpnt1 - start black pieces (17)
zpnt2 - start black pieces (25)
- evaluation() evaluates the given board posirion in 2 steps:
Step1 - via veldwz (see source/attack.c) it first builds the attack boards bord2 (for white) and bord3 (for black). more info at: Inside REBEL During step-1 material, PST, mobility (for knight, bishop and rook) pins, subtraction threads, bad (inactive) bishops, caught bishops, rook doubling, rook cooperation, rook open and half open files are evaluated. Furthermore it builds 2 variables called wsom and zsom for the use in step-2 for late endgame evaluation.
Step2 - now that bord2 and bord3 are 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 in bord2 and bord3 we extract the 2 highest hanging pieces (SEE) from the 2 tables with a simple table lookup into the varaibles z2 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:
your_score = (mp*100)/256;