mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Retire UCI_Chess960 option
We don't need that ! We can infere from starting fen string if we are in a Chess960 game or not. And note that this is a per-position property, not an application wide one. A nice trick is to use a custom manipulator (that is an enum actually) to keep using the handy operator<<() on the move when sending to std::cout, yes, I have indulged a bit here ;-) Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
7b721b3663
commit
e17fa64aec
8 changed files with 43 additions and 32 deletions
|
@ -67,8 +67,6 @@ static const string AppTag = "";
|
||||||
//// Variables
|
//// Variables
|
||||||
////
|
////
|
||||||
|
|
||||||
bool Chess960;
|
|
||||||
|
|
||||||
uint64_t dbg_cnt0 = 0;
|
uint64_t dbg_cnt0 = 0;
|
||||||
uint64_t dbg_cnt1 = 0;
|
uint64_t dbg_cnt1 = 0;
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,6 @@
|
||||||
#define Max(x, y) (((x) < (y))? (y) : (x))
|
#define Max(x, y) (((x) < (y))? (y) : (x))
|
||||||
|
|
||||||
|
|
||||||
////
|
|
||||||
//// Variables
|
|
||||||
////
|
|
||||||
|
|
||||||
extern bool Chess960;
|
|
||||||
|
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Prototypes
|
//// Prototypes
|
||||||
////
|
////
|
||||||
|
|
13
src/move.cpp
13
src/move.cpp
|
@ -108,7 +108,7 @@ Move move_from_string(const Position& pos, const std::string& str) {
|
||||||
/// print in the e1g1 notation in normal chess mode, and in e1h1 notation in
|
/// print in the e1g1 notation in normal chess mode, and in e1h1 notation in
|
||||||
/// Chess960 mode.
|
/// Chess960 mode.
|
||||||
|
|
||||||
const std::string move_to_string(Move move) {
|
const std::string move_to_string(Move move, bool chess960) {
|
||||||
|
|
||||||
std::string str;
|
std::string str;
|
||||||
Square from = move_from(move);
|
Square from = move_from(move);
|
||||||
|
@ -120,14 +120,12 @@ const std::string move_to_string(Move move) {
|
||||||
str = "0000";
|
str = "0000";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!Chess960)
|
if (move_is_short_castle(move) && !chess960)
|
||||||
{
|
|
||||||
if (move_is_short_castle(move))
|
|
||||||
return (from == SQ_E1 ? "e1g1" : "e8g8");
|
return (from == SQ_E1 ? "e1g1" : "e8g8");
|
||||||
|
|
||||||
if (move_is_long_castle(move))
|
if (move_is_long_castle(move) && !chess960)
|
||||||
return (from == SQ_E1 ? "e1c1" : "e8c8");
|
return (from == SQ_E1 ? "e1c1" : "e8c8");
|
||||||
}
|
|
||||||
str = square_to_string(from) + square_to_string(to);
|
str = square_to_string(from) + square_to_string(to);
|
||||||
if (move_is_promotion(move))
|
if (move_is_promotion(move))
|
||||||
str += piece_type_to_char(move_promotion_piece(move), false);
|
str += piece_type_to_char(move_promotion_piece(move), false);
|
||||||
|
@ -140,7 +138,8 @@ const std::string move_to_string(Move move) {
|
||||||
|
|
||||||
std::ostream& operator << (std::ostream& os, Move m) {
|
std::ostream& operator << (std::ostream& os, Move m) {
|
||||||
|
|
||||||
return os << move_to_string(m);
|
bool chess960 = (os.iword(0) != 0); // See set960()
|
||||||
|
return os << move_to_string(m, chess960);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ inline Move make_ep_move(Square from, Square to) {
|
||||||
|
|
||||||
extern std::ostream& operator<<(std::ostream& os, Move m);
|
extern std::ostream& operator<<(std::ostream& os, Move m);
|
||||||
extern Move move_from_string(const Position& pos, const std::string &str);
|
extern Move move_from_string(const Position& pos, const std::string &str);
|
||||||
extern const std::string move_to_string(Move m);
|
extern const std::string move_to_string(Move m, bool chess960);
|
||||||
extern bool move_is_ok(Move m);
|
extern bool move_is_ok(Move m);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -246,6 +246,10 @@ void Position::from_fen(const string& fen) {
|
||||||
castleRightsMask[make_square(initialQRFile, RANK_1)] ^= WHITE_OOO;
|
castleRightsMask[make_square(initialQRFile, RANK_1)] ^= WHITE_OOO;
|
||||||
castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO;
|
castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO;
|
||||||
|
|
||||||
|
isChess960 = initialKFile != FILE_E
|
||||||
|
|| initialQRFile != FILE_A
|
||||||
|
|| initialKRFile != FILE_H;
|
||||||
|
|
||||||
find_checkers();
|
find_checkers();
|
||||||
|
|
||||||
st->key = compute_key();
|
st->key = compute_key();
|
||||||
|
@ -352,21 +356,17 @@ const string Position::to_fen() const {
|
||||||
|
|
||||||
if (st->castleRights != CASTLES_NONE)
|
if (st->castleRights != CASTLES_NONE)
|
||||||
{
|
{
|
||||||
const bool Chess960 = initialKFile != FILE_E
|
|
||||||
|| initialQRFile != FILE_A
|
|
||||||
|| initialKRFile != FILE_H;
|
|
||||||
|
|
||||||
if (can_castle_kingside(WHITE))
|
if (can_castle_kingside(WHITE))
|
||||||
fen += Chess960 ? char(toupper(file_to_char(initialKRFile))) : 'K';
|
fen += isChess960 ? char(toupper(file_to_char(initialKRFile))) : 'K';
|
||||||
|
|
||||||
if (can_castle_queenside(WHITE))
|
if (can_castle_queenside(WHITE))
|
||||||
fen += Chess960 ? char(toupper(file_to_char(initialQRFile))) : 'Q';
|
fen += isChess960 ? char(toupper(file_to_char(initialQRFile))) : 'Q';
|
||||||
|
|
||||||
if (can_castle_kingside(BLACK))
|
if (can_castle_kingside(BLACK))
|
||||||
fen += Chess960 ? file_to_char(initialKRFile) : 'k';
|
fen += isChess960 ? file_to_char(initialKRFile) : 'k';
|
||||||
|
|
||||||
if (can_castle_queenside(BLACK))
|
if (can_castle_queenside(BLACK))
|
||||||
fen += Chess960 ? file_to_char(initialQRFile) : 'q';
|
fen += isChess960 ? file_to_char(initialQRFile) : 'q';
|
||||||
} else
|
} else
|
||||||
fen += '-';
|
fen += '-';
|
||||||
|
|
||||||
|
|
|
@ -272,6 +272,7 @@ public:
|
||||||
// Other properties of the position
|
// Other properties of the position
|
||||||
bool opposite_colored_bishops() const;
|
bool opposite_colored_bishops() const;
|
||||||
bool has_pawn_on_7th(Color c) const;
|
bool has_pawn_on_7th(Color c) const;
|
||||||
|
bool is_chess960() const;
|
||||||
|
|
||||||
// Current thread ID searching on the position
|
// Current thread ID searching on the position
|
||||||
int thread() const;
|
int thread() const;
|
||||||
|
@ -335,6 +336,7 @@ private:
|
||||||
int castleRightsMask[64];
|
int castleRightsMask[64];
|
||||||
StateInfo startState;
|
StateInfo startState;
|
||||||
File initialKFile, initialKRFile, initialQRFile;
|
File initialKFile, initialKRFile, initialQRFile;
|
||||||
|
bool isChess960;
|
||||||
int startPosPlyCounter;
|
int startPosPlyCounter;
|
||||||
int threadID;
|
int threadID;
|
||||||
StateInfo* st;
|
StateInfo* st;
|
||||||
|
@ -555,6 +557,11 @@ inline bool Position::has_pawn_on_7th(Color c) const {
|
||||||
return pieces(PAWN, c) & relative_rank_bb(c, RANK_7);
|
return pieces(PAWN, c) & relative_rank_bb(c, RANK_7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool Position::is_chess960() const {
|
||||||
|
|
||||||
|
return isChess960;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool Position::move_is_capture(Move m) const {
|
inline bool Position::move_is_capture(Move m) const {
|
||||||
|
|
||||||
// Move must not be MOVE_NONE !
|
// Move must not be MOVE_NONE !
|
||||||
|
|
|
@ -161,6 +161,21 @@ namespace {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// When formatting a move for std::cout we must know if we are in Chess960
|
||||||
|
// or not. To keep using the handy operator<<() on the move the trick is to
|
||||||
|
// embed this flag in the stream itself. Function-like named enum set960 is
|
||||||
|
// used as a custom manipulator and the stream internal general-purpose array,
|
||||||
|
// accessed through ios_base::iword(), is used to pass the flag to the move's
|
||||||
|
// operator<<() that will use it to properly format castling moves.
|
||||||
|
enum set960 {};
|
||||||
|
|
||||||
|
std::ostream& operator<< (std::ostream& os, const set960& m) {
|
||||||
|
|
||||||
|
os.iword(0) = int(m);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Adjustments
|
/// Adjustments
|
||||||
|
|
||||||
// Step 6. Razoring
|
// Step 6. Razoring
|
||||||
|
@ -448,7 +463,6 @@ bool think(const Position& pos, bool infinite, bool ponder, int time[], int incr
|
||||||
MinimumSplitDepth = get_option_value_int("Minimum Split Depth") * ONE_PLY;
|
MinimumSplitDepth = get_option_value_int("Minimum Split Depth") * ONE_PLY;
|
||||||
MaxThreadsPerSplitPoint = get_option_value_int("Maximum Number of Threads per Split Point");
|
MaxThreadsPerSplitPoint = get_option_value_int("Maximum Number of Threads per Split Point");
|
||||||
MultiPV = get_option_value_int("MultiPV");
|
MultiPV = get_option_value_int("MultiPV");
|
||||||
Chess960 = get_option_value_bool("UCI_Chess960");
|
|
||||||
UseLogFile = get_option_value_bool("Use Search Log");
|
UseLogFile = get_option_value_bool("Use Search Log");
|
||||||
|
|
||||||
if (UseLogFile)
|
if (UseLogFile)
|
||||||
|
@ -534,7 +548,8 @@ namespace {
|
||||||
|
|
||||||
// Print RootMoveList startup scoring to the standard output,
|
// Print RootMoveList startup scoring to the standard output,
|
||||||
// so to output information also for iteration 1.
|
// so to output information also for iteration 1.
|
||||||
cout << "info depth " << 1
|
cout << set960(p.is_chess960()) // Is enough to set once at the beginning
|
||||||
|
<< "info depth " << 1
|
||||||
<< "\ninfo depth " << 1
|
<< "\ninfo depth " << 1
|
||||||
<< " score " << value_to_uci(rml.get_move_score(0))
|
<< " score " << value_to_uci(rml.get_move_score(0))
|
||||||
<< " time " << current_search_time()
|
<< " time " << current_search_time()
|
||||||
|
|
|
@ -131,7 +131,6 @@ namespace {
|
||||||
o["Emergency Base Time"] = Option(200, 0, 60000);
|
o["Emergency Base Time"] = Option(200, 0, 60000);
|
||||||
o["Emergency Move Time"] = Option(70, 0, 5000);
|
o["Emergency Move Time"] = Option(70, 0, 5000);
|
||||||
o["Minimum Thinking Time"] = Option(20, 0, 5000);
|
o["Minimum Thinking Time"] = Option(20, 0, 5000);
|
||||||
o["UCI_Chess960"] = Option(false);
|
|
||||||
o["UCI_AnalyseMode"] = Option(false);
|
o["UCI_AnalyseMode"] = Option(false);
|
||||||
|
|
||||||
// Any option should know its name so to be easily printed
|
// Any option should know its name so to be easily printed
|
||||||
|
|
Loading…
Add table
Reference in a new issue