[gray-matter] r1617 committed - only check for insufficient material when...

0 views
Skip to first unread message

codesite...@google.com

unread,
Aug 2, 2010, 7:41:47 PM8/2/10
to gray-matter-...@googlegroups.com
Revision: 1617
Author: protonspring
Date: Mon Aug 2 16:40:38 2010
Log: only check for insufficient material when
the piece count is down.


http://code.google.com/p/gray-matter/source/detail?r=1617

Modified:
/trunk/inc/state.h
/trunk/src/board_base.cpp
/trunk/src/search_mtdf.cpp

=======================================
--- /trunk/inc/state.h Thu Jul 9 11:27:58 2009
+++ /trunk/inc/state.h Mon Aug 2 16:40:38 2010
@@ -43,6 +43,7 @@
int en_passant; ///< En passant vulnerability.
bool on_move; ///< Color on move.
int fifty; ///< 50 move rule counter.
+ unsigned iNumPieces; ///< piece count
} state_t;

class stateArray
=======================================
--- /trunk/src/board_base.cpp Mon Aug 2 15:27:38 2010
+++ /trunk/src/board_base.cpp Mon Aug 2 16:40:38 2010
@@ -386,6 +386,9 @@
if (!no_move_counts && ++index >= fen.length())
return set_board_fen_error(fen, "FEN string too short (12).", x,
y);

+ //update iNumPieces so we know when to check for insufficient
+ state.iNumPieces = get_num_pieces(BLACK) + get_num_pieces(WHITE);
+
init_rotation();
init_hash();

@@ -493,12 +496,8 @@
if (!state.piece[WHITE][KING] || !state.piece[BLACK][KING])
return ILLEGAL;

- // Are the kings attacking one other?
- //int n = FST(state.piece[WHITE][KING]);
- //if (squares_king[n & 0x7][n >> 3] & state.piece[BLACK][KING])
- //return ILLEGAL;
-
//if the king on move is in check, then this position is illegal
+ // This also covers if the kings attacking one other? maybe?
if (check(state.piece[OFF_MOVE][KING], ON_MOVE))
return ILLEGAL;

@@ -508,8 +507,11 @@
case STALEMATE: return STALEMATE;
case CHECKMATE: return CHECKMATE;
}
- if (insufficient())
+ if (state.iNumPieces < 5)
+ {
+ if (insufficient())
return INSUFFICIENT;
+ }
if (three())
return THREE;
if (fifty())
@@ -715,6 +717,7 @@
// The move is a capture. Reset the 50 move rule counter.
state.fifty = -1;
retValue = true;
+ state.iNumPieces--;
}
}

@@ -729,7 +732,7 @@
// If we're moving a piece to one of our opponent's rooks' initial
// positions, then make sure that our opponent is no longer marked
able to
// castle on that rook's side.
- if ((m.x2 == 0 || m.x2 == 7) && (m.y2 == (OFF_MOVE ? 7 : 0)))// &&
state.castle[OFF_MOVE][m.x2 == 7] == CAN_CASTLE)
+ if ((m.x2 == 0 || m.x2 == 7) && (m.y2 == (OFF_MOVE ? 7 : 0)))
{
state.castle[OFF_MOVE][m.x2 == 7] = CANT_CASTLE;
hash ^= key_castle[OFF_MOVE][m.x1 == 7][CANT_CASTLE];
@@ -758,7 +761,7 @@
// At this point, we've moved the king. Make sure that we're no
longer
// marked able to castle on either side.
for (int side = QUEEN_SIDE; side <= KING_SIDE; side++)
- if (state.castle[ON_MOVE][side] == CAN_CASTLE)
+ //if (state.castle[ON_MOVE][side] == CAN_CASTLE) //WHY?
{
state.castle[ON_MOVE][side] = CANT_CASTLE;
hash ^= key_castle[ON_MOVE][side][CANT_CASTLE];
@@ -788,11 +791,13 @@
BIT_CLR(rotation[angle][OFF_MOVE],
coord[MAP][angle][m.x2][m.y1][X], coord[MAP][angle][m.x2][m.y1][Y]);
hash ^= key_piece[OFF_MOVE][PAWN][m.x2][m.y1];
pawn_hash ^= key_piece[OFF_MOVE][PAWN][m.x2][m.y1];
- }
+ state.iNumPieces--;
+ }

// If we're advancing a pawn two squares, then mark it
vulnerable to en
// passant.
state.en_passant = abs((int) m.y1 - (int) m.y2) == 2 ? (int)
m.x1 : -1;
+
}
else
// Oops. We're not moving a pawn. Mark no pawn vulnerable to en
@@ -1236,6 +1241,7 @@
state.en_passant = -1;
state.on_move = WHITE;
state.fifty = 0;
+ state.iNumPieces = 32;
}


/*----------------------------------------------------------------------------*\
=======================================
--- /trunk/src/search_mtdf.cpp Fri Jul 30 09:41:31 2010
+++ /trunk/src/search_mtdf.cpp Mon Aug 2 16:40:38 2010
@@ -463,8 +463,8 @@
//if we didn't hit the timeout flag, then this position is
//a terminal one, store it with max depth so we always return
//it on a hash table probe (we'll never want to explore deeper).
- //if (!timeout_flag)
- //table_ptr->store(hash, max_depth-depth, EXACT, m);
+ if (!timeout_flag)
+ table_ptr->store(hash, MAX_DEPTH, EXACT, m);
#ifndef _MSDEV_WINDOWS
DEBUG_SEARCH_PRINT("%s.", m.value == VALUE_ILLEGAL ? "Illegal
position" : m.value == VALUE_CONTEMPT ? "Stalemated" : "Checkmated");
#endif
@@ -475,13 +475,11 @@
if (!timeout_flag)
{
// Nope, the results are complete and reliable. Save them for
progeny.
- if (m.value > saved_alpha && m.value < saved_beta)
- {
- // When doing MTD(f) zero-window searches, our move search
should
- // never return an exact score. I've only accounted for this
in the
- // interest of robustness.
- //if ((max_depth-depth) > 3)
- //table_ptr->store(hash, max_depth-depth-1, EXACT, m);
+ //if (m.value > saved_alpha && m.value < saved_beta)
+ //{
+ // When doing MTD(f) zero-window searches, our move search should
+ // never return an exact score. I've only accounted for this in
the
+ // interest of robustness.
if (depth < max_depth) //no special branches
table_ptr->store(hash, max_depth-depth,EXACT,m);
//else if (m.value <= saved_alpha)
@@ -490,7 +488,7 @@
//else // m.value >= saved_beta
//{
//table_ptr->store(hash, max_depth-depth, LOWER, m);
- }
+ //}
history_ptr->store(whose, m); //this seems like a good move
}

Reply all
Reply to author
Forward
0 new messages