Keep the isChess960 flag inside Position so that is
copied with the Position, but esplicitly highlight the
fact that a FEN string has not enough information to detect
Chess960 in general case. To do this add a boolean argument
isChess960 to from_fen() function so to self document this
shortcoming of FEN notation.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
{
Move moves[1] = { MOVE_NONE };
int dummy[2] = { 0, 0 };
{
Move moves[1] = { MOVE_NONE };
int dummy[2] = { 0, 0 };
+ Position pos(*it, false, 0);
cerr << "\nBench position: " << cnt << '/' << positions.size() << endl << endl;
if (valType == "perft")
{
cerr << "\nBench position: " << cnt << '/' << positions.size() << endl << endl;
if (valType == "perft")
{
}
// Special extra evaluation for bishops
}
// Special extra evaluation for bishops
+ if (Piece == BISHOP && pos.is_chess960())
{
// An important Chess960 pattern: A cornered bishop blocked by
// a friendly pawn diagonally in front of it is a very serious
{
// An important Chess960 pattern: A cornered bishop blocked by
// a friendly pawn diagonally in front of it is a very serious
}
fen += char(8 - keyCode.length() + '0');
fen += "/8/8/8/8/8/8/8 w - -";
}
fen += char(8 - keyCode.length() + '0');
fen += "/8/8/8/8/8/8/8 w - -";
- return Position(fen, 0).get_material_key();
+ return Position(fen, false, 0).get_material_key();
}
const string EndgameFunctions::swapColors(const string& keyCode) {
}
const string EndgameFunctions::swapColors(const string& keyCode) {
-Position::Position(const string& fen, int th) {
+Position::Position(const string& fen, bool isChess960, int th) {
+ from_fen(fen, isChess960);
/// string. This function is not very robust - make sure that input FENs are
/// correct (this is assumed to be the responsibility of the GUI).
/// string. This function is not very robust - make sure that input FENs are
/// correct (this is assumed to be the responsibility of the GUI).
-void Position::from_fen(const string& fen) {
+void Position::from_fen(const string& fen, bool c960) {
/*
A FEN string defines a particular position using only the ASCII character set.
/*
A FEN string defines a particular position using only the ASCII character set.
castleRightsMask[make_square(initialQRFile, RANK_1)] ^= WHITE_OOO;
castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO;
castleRightsMask[make_square(initialQRFile, RANK_1)] ^= WHITE_OOO;
castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO;
- isChess960 = initialKFile != FILE_E
- || initialQRFile != FILE_A
- || initialKRFile != FILE_H;
-
find_checkers();
st->key = compute_key();
find_checkers();
st->key = compute_key();
// Constructors
Position(const Position& pos, int threadID);
// Constructors
Position(const Position& pos, int threadID);
- Position(const std::string& fen, int threadID);
+ Position(const std::string& fen, bool isChess960, int threadID);
- void from_fen(const std::string& fen);
+ void from_fen(const std::string& fen, bool isChess960);
const std::string to_fen() const;
void print(Move m = MOVE_NONE) const;
const std::string to_fen() const;
void print(Move m = MOVE_NONE) const;
bool execute_uci_command(const string& cmd) {
bool execute_uci_command(const string& cmd) {
- static Position pos(StartPositionFEN, 0); // The root position
+ static Position pos(StartPositionFEN, false, 0); // The root position
UCIParser up(cmd);
string token;
UCIParser up(cmd);
string token;
cout << "uciok" << endl;
}
else if (token == "ucinewgame")
cout << "uciok" << endl;
}
else if (token == "ucinewgame")
- pos.from_fen(StartPositionFEN);
+ pos.from_fen(StartPositionFEN, false);
else if (token == "isready")
cout << "readyok" << endl;
else if (token == "isready")
cout << "readyok" << endl;
if (token == "startpos")
{
if (token == "startpos")
{
- pos.from_fen(StartPositionFEN);
+ pos.from_fen(StartPositionFEN, false);
if (!(up >> token))
return;
}
if (!(up >> token))
return;
}
fen += token;
fen += ' ';
}
fen += token;
fen += ' ';
}
+ pos.from_fen(fen, Options["UCI_Chess960"].value<bool>());