From: homoSapiensSapiens Date: Fri, 16 Aug 2013 07:57:16 +0000 (+0200) Subject: Use constants arguments where possible X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=e005270fb6fb5a21ccfa91186181707882aef285 Use constants arguments where possible No functional changes. --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index b6085b73..daa911e6 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -238,18 +238,18 @@ namespace { Score evaluate_pieces_of_color(const Position& pos, EvalInfo& ei, Score& mobility); template - Score evaluate_king(const Position& pos, EvalInfo& ei, Value margins[]); + Score evaluate_king(const Position& pos, const EvalInfo& ei, Value margins[]); template - Score evaluate_threats(const Position& pos, EvalInfo& ei); + Score evaluate_threats(const Position& pos, const EvalInfo& ei); template - Score evaluate_passed_pawns(const Position& pos, EvalInfo& ei); + Score evaluate_passed_pawns(const Position& pos, const EvalInfo& ei); template - int evaluate_space(const Position& pos, EvalInfo& ei); + int evaluate_space(const Position& pos, const EvalInfo& ei); - Score evaluate_unstoppable_pawns(const Position& pos, EvalInfo& ei); + Score evaluate_unstoppable_pawns(const Position& pos, const EvalInfo& ei); Value interpolate(const Score& v, Phase ph, ScaleFactor sf); Score apply_weight(Score v, Score w); @@ -603,7 +603,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // and the type of attacked one. template - Score evaluate_threats(const Position& pos, EvalInfo& ei) { + Score evaluate_threats(const Position& pos, const EvalInfo& ei) { const Color Them = (Us == WHITE ? BLACK : WHITE); @@ -674,7 +674,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // evaluate_king<>() assigns bonuses and penalties to a king of a given color template - Score evaluate_king(const Position& pos, EvalInfo& ei, Value margins[]) { + Score evaluate_king(const Position& pos, const EvalInfo& ei, Value margins[]) { const Color Them = (Us == WHITE ? BLACK : WHITE); @@ -787,7 +787,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // evaluate_passed_pawns<>() evaluates the passed pawns of the given color template - Score evaluate_passed_pawns(const Position& pos, EvalInfo& ei) { + Score evaluate_passed_pawns(const Position& pos, const EvalInfo& ei) { const Color Them = (Us == WHITE ? BLACK : WHITE); @@ -889,7 +889,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // evaluate_unstoppable_pawns() evaluates the unstoppable passed pawns for both sides, this is quite // conservative and returns a winning score only when we are very sure that the pawn is winning. - Score evaluate_unstoppable_pawns(const Position& pos, EvalInfo& ei) { + Score evaluate_unstoppable_pawns(const Position& pos, const EvalInfo& ei) { Bitboard b, b2, blockers, supporters, queeningPath, candidates; Square s, blockSq, queeningSquare; @@ -1054,7 +1054,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // twice. Finally, the space bonus is scaled by a weight taken from the // material hash table. The aim is to improve play on game opening. template - int evaluate_space(const Position& pos, EvalInfo& ei) { + int evaluate_space(const Position& pos, const EvalInfo& ei) { const Color Them = (Us == WHITE ? BLACK : WHITE); diff --git a/src/thread.cpp b/src/thread.cpp index 08ac30e1..7d85db86 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -164,7 +164,7 @@ bool Thread::cutoff_occurred() const { // which are busy searching the split point at the top of slaves split point // stack (the "helpful master concept" in YBWC terminology). -bool Thread::is_available_to(Thread* master) const { +bool Thread::is_available_to(const Thread* master) const { if (searching) return false; @@ -238,7 +238,7 @@ void ThreadPool::read_uci_options() { // slave_available() tries to find an idle thread which is available as a slave // for the thread 'master'. -Thread* ThreadPool::available_slave(Thread* master) const { +Thread* ThreadPool::available_slave(const Thread* master) const { for (const_iterator it = begin(); it != end(); ++it) if ((*it)->is_available_to(master)) @@ -258,7 +258,7 @@ Thread* ThreadPool::available_slave(Thread* master) const { // search() then split() returns. template -void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bestValue, +void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove, Depth depth, Move threatMove, int moveCount, MovePicker* movePicker, int nodeType, bool cutNode) { @@ -348,8 +348,8 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes } // Explicit template instantiations -template void Thread::split(Position&, Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int, bool); -template void Thread::split< true>(Position&, Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int, bool); +template void Thread::split(Position&, const Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int, bool); +template void Thread::split< true>(Position&, const Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int, bool); // wait_for_think_finished() waits for main thread to go to sleep then returns diff --git a/src/thread.h b/src/thread.h index 7557c0e7..56d000f3 100644 --- a/src/thread.h +++ b/src/thread.h @@ -114,10 +114,10 @@ struct Thread : public ThreadBase { Thread(); virtual void idle_loop(); bool cutoff_occurred() const; - bool is_available_to(Thread* master) const; + bool is_available_to(const Thread* master) const; template - void split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove, + void split(Position& pos, const Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove, Depth depth, Move threatMove, int moveCount, MovePicker* movePicker, int nodeType, bool cutNode); SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD]; @@ -160,7 +160,7 @@ struct ThreadPool : public std::vector { MainThread* main() { return static_cast((*this)[0]); } void read_uci_options(); - Thread* available_slave(Thread* master) const; + Thread* available_slave(const Thread* master) const; void wait_for_think_finished(); void start_thinking(const Position&, const Search::LimitsType&, const std::vector&, Search::StateStackPtr&);