1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 08:13:08 +00:00

Remove redundant argument in think()

We don't need to pass side_to_move because we can get
it directly from the position object.

Note that in benchmark we always used to pass '0' and
it was a bug, but with no effect because was used only
in time[] and increment[], set always to 0 for both
colors.

Also additional small cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-07-15 17:05:56 +02:00
parent a98dee7835
commit b6ab610e2f
7 changed files with 22 additions and 26 deletions

View file

@ -159,7 +159,7 @@ void benchmark(const string& commandLine) {
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();
}

View file

@ -1064,9 +1064,8 @@ namespace {
}
// 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[]) {
@ -1076,7 +1075,7 @@ namespace {
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));

View file

@ -201,8 +201,8 @@ inline Move make_ep_move(Square from, Square to) {
//// 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);

View file

@ -51,7 +51,7 @@
////
/// 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

View file

@ -411,9 +411,8 @@ int perft(Position& pos, Depth depth)
/// 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;
@ -486,8 +485,8 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
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

View file

@ -72,11 +72,9 @@ struct SearchStack {
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)

View file

@ -79,7 +79,7 @@ namespace {
void uci_main_loop() {
RootPosition.from_fen(StartPosition);
RootPosition.from_fen(StartPositionFEN);
string command;
do {
@ -127,7 +127,7 @@ namespace {
{
push_button("New Game");
Position::init_piece_square_tables();
RootPosition.from_fen(StartPosition);
RootPosition.from_fen(StartPositionFEN);
}
else if (token == "isready")
cout << "readyok" << endl;
@ -149,9 +149,9 @@ namespace {
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()
@ -180,7 +180,7 @@ namespace {
return;
if (token == "startpos")
RootPosition.from_fen(StartPosition);
RootPosition.from_fen(StartPositionFEN);
else if (token == "fen")
{
string fen;
@ -209,7 +209,7 @@ namespace {
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();
}
}
@ -300,8 +300,8 @@ namespace {
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) {