cerr << "\nPerft " << maxDepth << " result (nodes searched): " << perftCnt << endl << endl;
totalNodes += perftCnt;
} else {
- if (!think(pos, false, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves))
+ if (!think(pos, false, false, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves))
break;
totalNodes += nodes_searched();
}
}
- // scale_by_game_phase() interpolates between a middle game and an endgame
- // score, based on game phase. It also scales the return value by a
- // ScaleFactor array.
+ // scale_by_game_phase() interpolates between a middle game and an endgame score,
+ // based on game phase. It also scales the return value by a ScaleFactor array.
Value scale_by_game_phase(const Score& v, Phase ph, const ScaleFactor sf[]) {
Value eg = eg_value(v);
ScaleFactor f = sf[eg > Value(0) ? WHITE : BLACK];
- Value ev = Value((eg * f) / int(SCALE_FACTOR_NORMAL));
+ Value ev = Value((eg * f) / SCALE_FACTOR_NORMAL);
int result = (mg_value(v) * ph + ev * (128 - ph)) / 128;
return Value(result & ~(GrainSize - 1));
//// Prototypes
////
-extern std::ostream& operator<<(std::ostream &os, Move m);
-extern Move move_from_string(const Position &pos, const std::string &str);
+extern std::ostream& operator<<(std::ostream& os, Move m);
+extern Move move_from_string(const Position& pos, const std::string &str);
extern const std::string move_to_string(Move m);
extern bool move_is_ok(Move m);
////
/// FEN string for the initial position
-const std::string StartPosition = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
+const std::string StartPositionFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
/// Maximum number of plies per game (220 should be enough, because the
/// maximum search depth is 100, and during position setup we reset the
/// search-related global variables, and calls root_search(). It returns false
/// when a quit command is received during the search.
-bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
- int time[], int increment[], int movesToGo, int maxDepth,
- int maxNodes, int maxTime, Move searchMoves[]) {
+bool think(const Position& pos, bool infinite, bool ponder, int time[], int increment[],
+ int movesToGo, int maxDepth, int maxNodes, int maxTime, Move searchMoves[]) {
// Initialize global search variables
StopOnPonderhit = AbortSearch = Quit = AspirationFailLow = false;
TM.wake_sleeping_threads();
// Set thinking time
- int myTime = time[side_to_move];
- int myIncrement = increment[side_to_move];
+ int myTime = time[pos.side_to_move()];
+ int myIncrement = increment[pos.side_to_move()];
if (UseTimeManagement)
{
if (!movesToGo) // Sudden death time control
extern void init_search();
extern void init_threads();
extern void exit_threads();
-extern bool think(const Position &pos, bool infinite, bool ponder, int side_to_move,
- int time[], int increment[], int movesToGo, int maxDepth,
- int maxNodes, int maxTime, Move searchMoves[]);
-extern int perft(Position &pos, Depth depth);
+extern int perft(Position& pos, Depth depth);
extern int64_t nodes_searched();
-
+extern bool think(const Position& pos, bool infinite, bool ponder, int time[], int increment[],
+ int movesToGo, int maxDepth, int maxNodes, int maxTime, Move searchMoves[]);
#endif // !defined(SEARCH_H_INCLUDED)
void uci_main_loop() {
- RootPosition.from_fen(StartPosition);
+ RootPosition.from_fen(StartPositionFEN);
string command;
do {
{
push_button("New Game");
Position::init_piece_square_tables();
- RootPosition.from_fen(StartPosition);
+ RootPosition.from_fen(StartPositionFEN);
}
else if (token == "isready")
cout << "readyok" << endl;
else if (token == "eval")
{
EvalInfo ei;
- cout << "Incremental mg: " << mg_value(RootPosition.value())
+ cout << "Incremental mg: " << mg_value(RootPosition.value())
<< "\nIncremental eg: " << eg_value(RootPosition.value())
- << "\nFull eval: " << evaluate(RootPosition, ei) << endl;
+ << "\nFull eval: " << evaluate(RootPosition, ei) << endl;
}
else if (token == "key")
cout << "key: " << hex << RootPosition.get_key()
return;
if (token == "startpos")
- RootPosition.from_fen(StartPosition);
+ RootPosition.from_fen(StartPositionFEN);
else if (token == "fen")
{
string fen;
RootPosition.reset_game_ply();
}
// Our StateInfo st is about going out of scope so copy
- // its content inside RootPosition before they disappear.
+ // its content inside RootPosition before it disappears.
RootPosition.detach();
}
}
assert(RootPosition.is_ok());
- return think(RootPosition, infinite, ponder, RootPosition.side_to_move(),
- time, inc, movesToGo, depth, nodes, moveTime, searchMoves);
+ return think(RootPosition, infinite, ponder, time, inc, movesToGo,
+ depth, nodes, moveTime, searchMoves);
}
void perft(UCIInputParser& uip) {