From: H.G.Muller Date: Sat, 14 Jan 2017 11:48:19 +0000 (+0100) Subject: Keep track of attacked squares near King X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=78359960a2989cb39d7ffa176dc78f2683acd8d2;p=crazywa.git Keep track of attacked squares near King The move generator now marks all attacked squares on an auxiliary board. At the end it counts the number of such squares next to the enemy King, empty squares and captures separately. It also counts the number of unattacked empty squares next to the King. --- diff --git a/dropper.c b/dropper.c index 85c44c3..219c868 100644 --- a/dropper.c +++ b/dropper.c @@ -691,6 +691,7 @@ typedef struct { // move stack sectioning int castlings; // end of list of board moves without castlings int epSqr; int checker; + int safety, hole, escape; } MoveStack; HashEntry *hashTable; @@ -740,20 +741,24 @@ void Dump (char *s) {int i; printf("%s\n",s); for(i=0; ifirstMove = m->nonCapts = m->late = moveSP; m->stage = 0; for(r=0; repSqr) { // reaches e.p. square: must be through diagonal move, and e.p. square is always empty @@ -808,6 +813,14 @@ MoveGen (int stm, MoveStack *m, int castle) if(board[r-1] == 0 && board[r-2] == 0 && board[r-3] == 0) f += 2, moveStack[moveSP++] = r << 8 | 8*22+21 + 22*(stm == BLACK); } + r = location[stm+31^COLOR]; // enemy King +# define HOLE(X) (attacks[X] == c)*!board[X] + m->hole = HOLE(r+1) + HOLE(r-1) + HOLE(r+22) + HOLE(r+21) + HOLE(r+23) + HOLE(r-21) + HOLE(r-22) + HOLE(r-23); +# define SAFE(X) (attacks[X] == c)*!(board[X] & stm) + m->safety = SAFE(r+1) + SAFE(r-1) + SAFE(r+22) + SAFE(r+21) + SAFE(r+23) + SAFE(r-21) + SAFE(r-22) + SAFE(r-23); +# define ESC(X) (board[X] & stm || attacks[X] == c) + m->escape = 8 - (ESC(r+1) + ESC(r-1) + ESC(r+22) + ESC(r+21) + ESC(r+23) + ESC(r-21) + ESC(r-22) + ESC(r-23)); + return 0; }