mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 13:17:44 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ee0842c81 | |||
| e59ff49a55 | |||
| 225dcfeeb7 | |||
| 8dd01fda12 | |||
| 18cd83a380 | |||
| fd2b3df770 | |||
| da948cc94e | |||
| e49b21eacb | |||
| 60bc30275d | |||
| 32dfaa56b0 | |||
| 3701a8e57d |
+1
-1
@@ -50,7 +50,7 @@ using namespace std;
|
|||||||
/// Version number. If this is left empty, the current date (in the format
|
/// Version number. If this is left empty, the current date (in the format
|
||||||
/// YYMMDD) is used as a version number.
|
/// YYMMDD) is used as a version number.
|
||||||
|
|
||||||
static const string EngineVersion = "1.5";
|
static const string EngineVersion = "1.5.1";
|
||||||
static const string AppName = "Stockfish";
|
static const string AppName = "Stockfish";
|
||||||
static const string AppTag = "";
|
static const string AppTag = "";
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ class PawnInfo {
|
|||||||
friend class PawnInfoTable;
|
friend class PawnInfoTable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PawnInfo() : key(0) { clear(); }
|
PawnInfo() { clear(); }
|
||||||
|
|
||||||
Value mg_value() const;
|
Value mg_value() const;
|
||||||
Value eg_value() const;
|
Value eg_value() const;
|
||||||
|
|||||||
+29
-18
@@ -985,16 +985,21 @@ void Position::do_castle_move(Move m) {
|
|||||||
rto = relative_square(us, SQ_D1);
|
rto = relative_square(us, SQ_D1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the pieces
|
// Remove pieces from source squares:
|
||||||
Bitboard kmove_bb = make_move_bb(kfrom, kto);
|
clear_bit(&(byColorBB[us]), kfrom);
|
||||||
do_move_bb(&(byColorBB[us]), kmove_bb);
|
clear_bit(&(byTypeBB[KING]), kfrom);
|
||||||
do_move_bb(&(byTypeBB[KING]), kmove_bb);
|
clear_bit(&(byTypeBB[0]), kfrom); // HACK: byTypeBB[0] == occupied squares
|
||||||
do_move_bb(&(byTypeBB[0]), kmove_bb); // HACK: byTypeBB[0] == occupied squares
|
clear_bit(&(byColorBB[us]), rfrom);
|
||||||
|
clear_bit(&(byTypeBB[ROOK]), rfrom);
|
||||||
|
clear_bit(&(byTypeBB[0]), rfrom); // HACK: byTypeBB[0] == occupied squares
|
||||||
|
|
||||||
Bitboard rmove_bb = make_move_bb(rfrom, rto);
|
// Put pieces on destination squares:
|
||||||
do_move_bb(&(byColorBB[us]), rmove_bb);
|
set_bit(&(byColorBB[us]), kto);
|
||||||
do_move_bb(&(byTypeBB[ROOK]), rmove_bb);
|
set_bit(&(byTypeBB[KING]), kto);
|
||||||
do_move_bb(&(byTypeBB[0]), rmove_bb); // HACK: byTypeBB[0] == occupied squares
|
set_bit(&(byTypeBB[0]), kto); // HACK: byTypeBB[0] == occupied squares
|
||||||
|
set_bit(&(byColorBB[us]), rto);
|
||||||
|
set_bit(&(byTypeBB[ROOK]), rto);
|
||||||
|
set_bit(&(byTypeBB[0]), rto); // HACK: byTypeBB[0] == occupied squares
|
||||||
|
|
||||||
// Update board array
|
// Update board array
|
||||||
Piece king = piece_of_color_and_type(us, KING);
|
Piece king = piece_of_color_and_type(us, KING);
|
||||||
@@ -1106,6 +1111,7 @@ void Position::undo_move(Move m) {
|
|||||||
pieceList[us][PAWN][index[to]] = to;
|
pieceList[us][PAWN][index[to]] = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Put the piece back at the source square
|
// Put the piece back at the source square
|
||||||
Bitboard move_bb = make_move_bb(to, from);
|
Bitboard move_bb = make_move_bb(to, from);
|
||||||
do_move_bb(&(byColorBB[us]), move_bb);
|
do_move_bb(&(byColorBB[us]), move_bb);
|
||||||
@@ -1184,16 +1190,21 @@ void Position::undo_castle_move(Move m) {
|
|||||||
assert(piece_on(kto) == piece_of_color_and_type(us, KING));
|
assert(piece_on(kto) == piece_of_color_and_type(us, KING));
|
||||||
assert(piece_on(rto) == piece_of_color_and_type(us, ROOK));
|
assert(piece_on(rto) == piece_of_color_and_type(us, ROOK));
|
||||||
|
|
||||||
// Put the pieces back at the source square
|
// Remove pieces from destination squares:
|
||||||
Bitboard kmove_bb = make_move_bb(kto, kfrom);
|
clear_bit(&(byColorBB[us]), kto);
|
||||||
do_move_bb(&(byColorBB[us]), kmove_bb);
|
clear_bit(&(byTypeBB[KING]), kto);
|
||||||
do_move_bb(&(byTypeBB[KING]), kmove_bb);
|
clear_bit(&(byTypeBB[0]), kto); // HACK: byTypeBB[0] == occupied squares
|
||||||
do_move_bb(&(byTypeBB[0]), kmove_bb); // HACK: byTypeBB[0] == occupied squares
|
clear_bit(&(byColorBB[us]), rto);
|
||||||
|
clear_bit(&(byTypeBB[ROOK]), rto);
|
||||||
|
clear_bit(&(byTypeBB[0]), rto); // HACK: byTypeBB[0] == occupied squares
|
||||||
|
|
||||||
Bitboard rmove_bb = make_move_bb(rto, rfrom);
|
// Put pieces on source squares:
|
||||||
do_move_bb(&(byColorBB[us]), rmove_bb);
|
set_bit(&(byColorBB[us]), kfrom);
|
||||||
do_move_bb(&(byTypeBB[ROOK]), rmove_bb);
|
set_bit(&(byTypeBB[KING]), kfrom);
|
||||||
do_move_bb(&(byTypeBB[0]), rmove_bb); // HACK: byTypeBB[0] == occupied squares
|
set_bit(&(byTypeBB[0]), kfrom); // HACK: byTypeBB[0] == occupied squares
|
||||||
|
set_bit(&(byColorBB[us]), rfrom);
|
||||||
|
set_bit(&(byTypeBB[ROOK]), rfrom);
|
||||||
|
set_bit(&(byTypeBB[0]), rfrom); // HACK: byTypeBB[0] == occupied squares
|
||||||
|
|
||||||
// Update board
|
// Update board
|
||||||
board[rto] = board[kto] = EMPTY;
|
board[rto] = board[kto] = EMPTY;
|
||||||
|
|||||||
+3
-2
@@ -325,14 +325,15 @@ const string line_to_san(const Position& pos, Move line[], int startColumn, bool
|
|||||||
/// when the UCI parameter "Use Search Log" is "true").
|
/// when the UCI parameter "Use Search Log" is "true").
|
||||||
|
|
||||||
const string pretty_pv(const Position& pos, int time, int depth,
|
const string pretty_pv(const Position& pos, int time, int depth,
|
||||||
uint64_t nodes, Value score, Move pv[]) {
|
uint64_t nodes, Value score, ValueType type, Move pv[]) {
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
|
|
||||||
// Depth
|
// Depth
|
||||||
s << std::setw(2) << depth << " ";
|
s << std::setw(2) << depth << " ";
|
||||||
|
|
||||||
// Score
|
// Score
|
||||||
s << std::setw(8) << score_string(score);
|
s << ((type == VALUE_TYPE_LOWER)? ">" : ((type == VALUE_TYPE_UPPER)? "<" : " "));
|
||||||
|
s << std::setw(7) << score_string(score);
|
||||||
|
|
||||||
// Time
|
// Time
|
||||||
s << std::setw(8) << time_string(time) << " ";
|
s << std::setw(8) << time_string(time) << " ";
|
||||||
|
|||||||
@@ -39,6 +39,6 @@
|
|||||||
extern const std::string move_to_san(const Position& pos, Move m);
|
extern const std::string move_to_san(const Position& pos, Move m);
|
||||||
extern Move move_from_san(const Position& pos, const std::string& str);
|
extern Move move_from_san(const Position& pos, const std::string& str);
|
||||||
extern const std::string line_to_san(const Position& pos, Move line[], int startColumn, bool breakLines);
|
extern const std::string line_to_san(const Position& pos, Move line[], int startColumn, bool breakLines);
|
||||||
extern const std::string pretty_pv(const Position& pos, int time, int depth, uint64_t nodes, Value score, Move pv[]);
|
extern const std::string pretty_pv(const Position& pos, int time, int depth, uint64_t nodes, Value score, ValueType type, Move pv[]);
|
||||||
|
|
||||||
#endif // !defined(SAN_H_INCLUDED)
|
#endif // !defined(SAN_H_INCLUDED)
|
||||||
|
|||||||
+26
-8
@@ -299,6 +299,7 @@ namespace {
|
|||||||
void ponderhit();
|
void ponderhit();
|
||||||
void print_current_line(SearchStack ss[], int ply, int threadID);
|
void print_current_line(SearchStack ss[], int ply, int threadID);
|
||||||
void wait_for_stop_or_ponderhit();
|
void wait_for_stop_or_ponderhit();
|
||||||
|
void init_ss_array(SearchStack ss[]);
|
||||||
|
|
||||||
void idle_loop(int threadID, SplitPoint* waitSp);
|
void idle_loop(int threadID, SplitPoint* waitSp);
|
||||||
void init_split_point_stack();
|
void init_split_point_stack();
|
||||||
@@ -445,7 +446,8 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
|
|||||||
if (movesToGo == 1)
|
if (movesToGo == 1)
|
||||||
{
|
{
|
||||||
MaxSearchTime = myTime / 2;
|
MaxSearchTime = myTime / 2;
|
||||||
AbsoluteMaxSearchTime = Min(myTime / 2, myTime - 500);
|
AbsoluteMaxSearchTime =
|
||||||
|
(myTime > 3000)? (myTime - 500) : ((myTime * 3) / 4);
|
||||||
} else {
|
} else {
|
||||||
MaxSearchTime = myTime / Min(movesToGo, 20);
|
MaxSearchTime = myTime / Min(movesToGo, 20);
|
||||||
AbsoluteMaxSearchTime = Min((4 * myTime) / movesToGo, myTime / 3);
|
AbsoluteMaxSearchTime = Min((4 * myTime) / movesToGo, myTime / 3);
|
||||||
@@ -469,6 +471,10 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
|
|||||||
NodesBetweenPolls = Min(MaxNodes, 30000);
|
NodesBetweenPolls = Min(MaxNodes, 30000);
|
||||||
InfiniteSearch = true; // HACK
|
InfiniteSearch = true; // HACK
|
||||||
}
|
}
|
||||||
|
else if (myTime && myTime < 1000)
|
||||||
|
NodesBetweenPolls = 1000;
|
||||||
|
else if (myTime && myTime < 5000)
|
||||||
|
NodesBetweenPolls = 5000;
|
||||||
else
|
else
|
||||||
NodesBetweenPolls = 30000;
|
NodesBetweenPolls = 30000;
|
||||||
|
|
||||||
@@ -636,11 +642,7 @@ namespace {
|
|||||||
// Initialize
|
// Initialize
|
||||||
TT.new_search();
|
TT.new_search();
|
||||||
H.clear();
|
H.clear();
|
||||||
for (int i = 0; i < 3; i++)
|
init_ss_array(ss);
|
||||||
{
|
|
||||||
ss[i].init(i);
|
|
||||||
ss[i].initKillers();
|
|
||||||
}
|
|
||||||
IterationInfo[1] = IterationInfoType(rml.get_move_score(0), rml.get_move_score(0));
|
IterationInfo[1] = IterationInfoType(rml.get_move_score(0), rml.get_move_score(0));
|
||||||
Iteration = 1;
|
Iteration = 1;
|
||||||
|
|
||||||
@@ -947,7 +949,7 @@ namespace {
|
|||||||
// Update PV
|
// Update PV
|
||||||
rml.set_move_score(i, value);
|
rml.set_move_score(i, value);
|
||||||
update_pv(ss, 0);
|
update_pv(ss, 0);
|
||||||
TT.extract_pv(pos, ss[0].pv);
|
TT.extract_pv(pos, ss[0].pv, PLY_MAX);
|
||||||
rml.set_move_pv(i, ss[0].pv);
|
rml.set_move_pv(i, ss[0].pv);
|
||||||
|
|
||||||
if (MultiPV == 1)
|
if (MultiPV == 1)
|
||||||
@@ -974,7 +976,10 @@ namespace {
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
if (UseLogFile)
|
if (UseLogFile)
|
||||||
LogFile << pretty_pv(pos, current_search_time(), Iteration, nodes_searched(), value, ss[0].pv)
|
LogFile << pretty_pv(pos, current_search_time(), Iteration, nodes_searched(), value,
|
||||||
|
((value >= beta)? VALUE_TYPE_LOWER
|
||||||
|
: ((value <= alpha)? VALUE_TYPE_UPPER : VALUE_TYPE_EXACT)),
|
||||||
|
ss[0].pv)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
if (value > alpha)
|
if (value > alpha)
|
||||||
@@ -1961,6 +1966,7 @@ namespace {
|
|||||||
// Find a quick score for the move
|
// Find a quick score for the move
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
SearchStack ss[PLY_MAX_PLUS_2];
|
SearchStack ss[PLY_MAX_PLUS_2];
|
||||||
|
init_ss_array(ss);
|
||||||
|
|
||||||
moves[count].move = cur->move;
|
moves[count].move = cur->move;
|
||||||
pos.do_move(moves[count].move, st);
|
pos.do_move(moves[count].move, st);
|
||||||
@@ -2560,6 +2566,18 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// init_ss_array() does a fast reset of the first entries of a SearchStack array
|
||||||
|
|
||||||
|
void init_ss_array(SearchStack ss[]) {
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
ss[i].init(i);
|
||||||
|
ss[i].initKillers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// wait_for_stop_or_ponderhit() is called when the maximum depth is reached
|
// wait_for_stop_or_ponderhit() is called when the maximum depth is reached
|
||||||
// while the program is pondering. The point is to work around a wrinkle in
|
// while the program is pondering. The point is to work around a wrinkle in
|
||||||
// the UCI protocol: When pondering, the engine is not allowed to give a
|
// the UCI protocol: When pondering, the engine is not allowed to give a
|
||||||
|
|||||||
+16
-17
@@ -220,27 +220,26 @@ void TranspositionTable::insert_pv(const Position& pos, Move pv[]) {
|
|||||||
/// will often get single-move PVs when the search stops while failing high,
|
/// will often get single-move PVs when the search stops while failing high,
|
||||||
/// and a single-move PV means that we don't have a ponder move.
|
/// and a single-move PV means that we don't have a ponder move.
|
||||||
|
|
||||||
void TranspositionTable::extract_pv(const Position& pos, Move pv[]) {
|
void TranspositionTable::extract_pv(const Position& pos, Move pv[], int pvSize) {
|
||||||
|
|
||||||
int ply;
|
|
||||||
Position p(pos);
|
|
||||||
StateInfo st[100];
|
|
||||||
|
|
||||||
for (ply = 0; pv[ply] != MOVE_NONE; ply++)
|
|
||||||
p.do_move(pv[ply], st[ply]);
|
|
||||||
|
|
||||||
bool stop;
|
|
||||||
const TTEntry* tte;
|
const TTEntry* tte;
|
||||||
for (stop = false, tte = retrieve(p.get_key());
|
StateInfo st;
|
||||||
tte && tte->move() != MOVE_NONE && !stop;
|
Position p(pos);
|
||||||
tte = retrieve(p.get_key()), ply++)
|
int ply = 0;
|
||||||
|
|
||||||
|
// Update position to the end of current PV
|
||||||
|
while (pv[ply] != MOVE_NONE)
|
||||||
|
p.do_move(pv[ply++], st);
|
||||||
|
|
||||||
|
// Try to add moves from TT while possible
|
||||||
|
while ( (tte = retrieve(p.get_key())) != NULL
|
||||||
|
&& tte->move() != MOVE_NONE
|
||||||
|
&& move_is_legal(p, tte->move())
|
||||||
|
&& (!p.is_draw() || ply < 2)
|
||||||
|
&& ply < pvSize)
|
||||||
{
|
{
|
||||||
if (!move_is_legal(p, tte->move()))
|
|
||||||
break;
|
|
||||||
pv[ply] = tte->move();
|
pv[ply] = tte->move();
|
||||||
p.do_move(pv[ply], st[ply]);
|
p.do_move(pv[ply++], st);
|
||||||
for (int j = 0; j < ply; j++)
|
|
||||||
if (st[j].key == p.get_key()) stop = true;
|
|
||||||
}
|
}
|
||||||
pv[ply] = MOVE_NONE;
|
pv[ply] = MOVE_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
void prefetch(const Key posKey) const;
|
void prefetch(const Key posKey) const;
|
||||||
void new_search();
|
void new_search();
|
||||||
void insert_pv(const Position& pos, Move pv[]);
|
void insert_pv(const Position& pos, Move pv[]);
|
||||||
void extract_pv(const Position& pos, Move pv[]);
|
void extract_pv(const Position& pos, Move pv[], int pvSize);
|
||||||
int full() const;
|
int full() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user