Rev 96 | Rev 169 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 96 | Rev 154 | ||
---|---|---|---|
Line 121... | Line 121... | ||
121 | result = INVALID; |
121 | result = INVALID; |
122 | 122 | ||
123 | // Immediate win if a pawn can be promoted without getting captured |
123 | // Immediate win if a pawn can be promoted without getting captured |
124 | else if ( us == WHITE |
124 | else if ( us == WHITE |
125 | && rank_of(psq) == RANK_7 |
125 | && rank_of(psq) == RANK_7 |
126 | && ksq[us] != psq + |
126 | && ksq[us] != psq + NORTH |
127 | && ( distance(ksq[~us], psq + |
127 | && ( distance(ksq[~us], psq + NORTH) > 1 |
128 | || (StepAttacksBB[KING][ksq[us]] & (psq + |
128 | || (StepAttacksBB[KING][ksq[us]] & (psq + NORTH)))) |
129 | result = WIN; |
129 | result = WIN; |
130 | 130 | ||
131 | // Immediate draw if it is a stalemate or a king captures undefended pawn |
131 | // Immediate draw if it is a stalemate or a king captures undefended pawn |
132 | else if ( us == BLACK |
132 | else if ( us == BLACK |
133 | && ( !(StepAttacksBB[KING][ksq[us]] & ~(StepAttacksBB[KING][ksq[~us]] | StepAttacksBB[PAWN][psq])) |
133 | && ( !(StepAttacksBB[KING][ksq[us]] & ~(StepAttacksBB[KING][ksq[~us]] | StepAttacksBB[PAWN][psq])) |
Line 164... | Line 164... | ||
164 | : db[index(Them, pop_lsb(&b), ksq[Them] , psq)]; |
164 | : db[index(Them, pop_lsb(&b), ksq[Them] , psq)]; |
165 | 165 | ||
166 | if (Us == WHITE) |
166 | if (Us == WHITE) |
167 | { |
167 | { |
168 | if (rank_of(psq) < RANK_7) // Single push |
168 | if (rank_of(psq) < RANK_7) // Single push |
169 | r |= db[index(Them, ksq[Them], ksq[Us], psq + |
169 | r |= db[index(Them, ksq[Them], ksq[Us], psq + NORTH)]; |
170 | 170 | ||
171 | if ( rank_of(psq) == RANK_2 // Double push |
171 | if ( rank_of(psq) == RANK_2 // Double push |
172 | && psq + |
172 | && psq + NORTH != ksq[Us] |
173 | && psq + |
173 | && psq + NORTH != ksq[Them]) |
174 | r |= db[index(Them, ksq[Them], ksq[Us], psq + |
174 | r |= db[index(Them, ksq[Them], ksq[Us], psq + NORTH + NORTH)]; |
175 | } |
175 | } |
176 | 176 | ||
177 | return result = r & Good ? Good : r & UNKNOWN ? UNKNOWN : Bad; |
177 | return result = r & Good ? Good : r & UNKNOWN ? UNKNOWN : Bad; |
178 | } |
178 | } |
179 | 179 |