- Bitboard KPKPosition::pawn_attacks() const {
- return StepAttackBB[WP][pawnSquare];
- }
-
-
- void initialize() {
- KPKPosition p;
- for(int i = 0; i < IndexMax; i++) {
- p.from_index(i);
- if(!p.is_legal())
- Bitbase[i] = RESULT_INVALID;
- else if(p.is_immediate_draw())
- Bitbase[i] = RESULT_DRAW;
- else if(p.is_immediate_win())
- Bitbase[i] = RESULT_WIN;
- else {
- Bitbase[i] = RESULT_UNKNOWN;
- UnknownCount++;
- }
- }
- }
-
-
- bool next_iteration() {
- KPKPosition p;
- int previousUnknownCount = UnknownCount;
-
- for(int i = 0; i < IndexMax; i++)
- if(Bitbase[i] == RESULT_UNKNOWN) {
- p.from_index(i);
-
- Bitbase[i] = (p.sideToMove == WHITE)? classify_wtm(p) : classify_btm(p);
-
- if(Bitbase[i] == RESULT_WIN || Bitbase[i] == RESULT_LOSS ||
- Bitbase[i] == RESULT_DRAW)
- UnknownCount--;
- }
-
- return UnknownCount != previousUnknownCount;
- }
-
-
- Result classify_wtm(const KPKPosition &p) {
-
- // If one move leads to a position classified as RESULT_LOSS, the result
- // of the current position is RESULT_WIN. If all moves lead to positions
- // classified as RESULT_DRAW, the current position is classified as
- // RESULT_DRAW. Otherwise, the current position is classified as
- // RESULT_UNKNOWN.
-
- bool unknownFound = false;
- Bitboard b;
- Square s;
+ // White to Move: If one move leads to a position classified as RESULT_WIN,
+ // the result of the current position is RESULT_WIN. If all moves lead to
+ // positions classified as RESULT_DRAW, the current position is classified
+ // RESULT_DRAW otherwise the current position is classified as RESULT_UNKNOWN.
+ //
+ // Black to Move: If one move leads to a position classified as RESULT_DRAW,
+ // the result of the current position is RESULT_DRAW. If all moves lead to
+ // positions classified as RESULT_WIN, the position is classified RESULT_WIN.
+ // Otherwise, the current position is classified as RESULT_UNKNOWN.