/* generate pawn captures and promotions */ void genattacksp(int f, int r, int c) { int forward = dir(c); square loc = SQ(f,r); r += forward; if (f<7) { chesspiece p = getpiece(f+1, r); if (p&&chesspiececolor(p)!=c) pushmove(MV(loc, SQ(f+1, r))); } if (f>0) { chesspiece p = getpiece(f-1,r); if (p&&chesspiececolor(p)!=c) pushmove(MV(loc, SQ(f-1, r))); } if (c==WHITE) { if ((r==6)&&emptyp(f,r)) pushmove(MV(loc, SQ(f,r))); } else { if ((r==1)&&emptyp(f,r)) pushmove(MV(loc, SQ(f,r))); } /* get en passante */ if (doublepushp()) { square start; square end; move m; m = lastmove(); start = FR(m); end = TO(m); r -= forward; /* restore to original r */ if (R(end) == r) { if (((f+1) == F(start))|| ((f-1) == F(start))) pushmove(MV(loc, SQ(F(start),forward+r))); } } }
void getmovesp(int f, int r, int c) { int forward = dir(c); square loc = SQ(f,r); r += forward; // captures if ((f<7) && (oppenentp (f+1, r, c))) { push_pawn_move(loc, SQ(1+f, r)); } if ((f>0) && (oppenentp (f-1, r, c))) { push_pawn_move(loc, SQ(f-1, r)); } if (emptyp(f,r)) { int startrank = ((c == WHITE) ? 2 : 5); push_pawn_move(loc, SQ(f,r)); /* can go two on first move */ if ((r == startrank)&&(emptyp(f,r+forward))) pushmove(MV(loc, SQ(f,r+forward))); } // if last move was double push we can possibly do an en passante if (doublepushp()) { square start; square end; move m; m = lastmove(); start = FR(m); end = TO(m); r -= forward; /* restore to original r */ if (R(end) == r) { if (((f+1) == F(start))|| ((f-1) == F(start))) pushmove(MV(loc, SQ(F(start),forward+r))); } } }
char *formatflags() { static char fmt[20]; fmt[0] = flag_test(wqcastlep(), 'Q'); fmt[1] = flag_test(wkcastlep(), 'K'); fmt[2] = flag_test(bqcastlep(), 'q'); fmt[3] = flag_test(bkcastlep(), 'k'); fmt[4] = flag_test(castledp(), 'C'); fmt[5] = flag_test(enpassantedp(), 'E'); fmt[6] = flag_test(doublepushp(), 'P'); fmt[7] = flag_test(wkcastledp(), 'K'); fmt[8] = flag_test(wqcastledp(), 'Q'); fmt[9] = flag_test(bkcastledp(), 'k'); fmt[10] = flag_test(bqcastledp(), 'q'); fmt[11] = tomove() == WHITE ? 'W' : 'B'; fmt[12] = 0; return fmt; }