Just added the infrastructure, no functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
case PH_GOOD_CAPTURES:
numOfMoves = generate_captures(pos, moves);
score_captures();
case PH_GOOD_CAPTURES:
numOfMoves = generate_captures(pos, moves);
score_captures();
+ capSquares = EmptyBoardBB;
-/// find_best_index() loops across the moves and returns index of
-/// the highest scored one.
+/// find_best_index() loops across the moves and returns index of\r
+/// the highest scored one. There is also a second version that\r
+/// lowers the priority of moves that attack the same square,\r
+/// so that if the best move that attack a square fails the next\r
+/// move picked attacks a different square if any, not the same one.
int MovePicker::find_best_index() {
int MovePicker::find_best_index() {
+int MovePicker::find_best_index(Bitboard* squares, int values[]) {\r
+\r
+ int hs;\r
+ Move m;\r
+ Square to;\r
+ int bestScore = -10000000, bestIndex = -1;\r
+\r
+ for (int i = movesPicked; i < numOfMoves; i++)\r
+ {\r
+ m = moves[i].move;\r
+ to = move_to(m);\r
+ \r
+ if (!bit_is_set(*squares, to))\r
+ {\r
+ // Init at first use\r
+ set_bit(squares, to);\r
+ values[to] = 0;\r
+ }\r
+\r
+ hs = moves[i].score - values[to];\r
+ if (hs > bestScore)\r
+ {\r
+ bestIndex = i;\r
+ bestScore = hs;\r
+ }\r
+ }\r
+\r
+ if (bestIndex != -1)\r
+ {\r
+ // Raise value of the picked square, so next attack\r
+ // to the same square will get low priority.\r
+ to = move_to(moves[bestIndex].move);\r
+ values[to] += 0xB00;\r
+ }\r
+ return bestIndex;\r
+}
+
/// MovePicker::pick_move_from_list() picks the move with the biggest score
/// from a list of generated moves (moves[] or badCaptures[], depending on
/// MovePicker::pick_move_from_list() picks the move with the biggest score
/// from a list of generated moves (moves[] or badCaptures[], depending on
void score_qcaptures();
Move pick_move_from_list();
int find_best_index();
void score_qcaptures();
Move pick_move_from_list();
int find_best_index();
+ int MovePicker::find_best_index(Bitboard* squares, int values[]);
const Position& pos;
Move ttMove, mateKiller, killer1, killer2;
Bitboard pinned, dc;
MoveStack moves[256], badCaptures[64];
const Position& pos;
Move ttMove, mateKiller, killer1, killer2;
Bitboard pinned, dc;
MoveStack moves[256], badCaptures[64];
+ Bitboard capSquares;\r
+ int capSqValues[64];
bool pvNode;
Depth depth;
int phaseIndex;
bool pvNode;
Depth depth;
int phaseIndex;