//// Variables
////
-bool Chess960;
-
uint64_t dbg_cnt0 = 0;
uint64_t dbg_cnt1 = 0;
#define Max(x, y) (((x) < (y))? (y) : (x))
-////
-//// Variables
-////
-
-extern bool Chess960;
-
-
////
//// Prototypes
////
/// move_to_string() converts a move to a string in coordinate notation
-/// (g1f3, a7a8q, etc.). The only special case is castling moves, where we
+/// (g1f3, a7a8q, etc.). The only special case is castling moves, where we
/// print in the e1g1 notation in normal chess mode, and in e1h1 notation in
/// Chess960 mode.
-const std::string move_to_string(Move move) {
+const std::string move_to_string(Move move, bool chess960) {
std::string str;
Square from = move_from(move);
str = "0000";
else
{
- if (!Chess960)
- {
- if (move_is_short_castle(move))
- return (from == SQ_E1 ? "e1g1" : "e8g8");
+ if (move_is_short_castle(move) && !chess960)
+ return (from == SQ_E1 ? "e1g1" : "e8g8");
+
+ if (move_is_long_castle(move) && !chess960)
+ return (from == SQ_E1 ? "e1c1" : "e8c8");
- if (move_is_long_castle(move))
- return (from == SQ_E1 ? "e1c1" : "e8c8");
- }
str = square_to_string(from) + square_to_string(to);
if (move_is_promotion(move))
str += piece_type_to_char(move_promotion_piece(move), false);
/// Overload the << operator, to make it easier to print moves.
-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);
}
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 const std::string move_to_string(Move m, bool chess960);
extern bool move_is_ok(Move m);
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();
if (st->castleRights != CASTLES_NONE)
{
- const bool Chess960 = initialKFile != FILE_E
- || initialQRFile != FILE_A
- || initialKRFile != FILE_H;
-
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))
- fen += Chess960 ? char(toupper(file_to_char(initialQRFile))) : 'Q';
+ fen += isChess960 ? char(toupper(file_to_char(initialQRFile))) : 'Q';
if (can_castle_kingside(BLACK))
- fen += Chess960 ? file_to_char(initialKRFile) : 'k';
+ fen += isChess960 ? file_to_char(initialKRFile) : 'k';
if (can_castle_queenside(BLACK))
- fen += Chess960 ? file_to_char(initialQRFile) : 'q';
+ fen += isChess960 ? file_to_char(initialQRFile) : 'q';
} else
fen += '-';
// Other properties of the position
bool opposite_colored_bishops() const;
bool has_pawn_on_7th(Color c) const;
+ bool is_chess960() const;
// Current thread ID searching on the position
int thread() const;
int castleRightsMask[64];
StateInfo startState;
File initialKFile, initialKRFile, initialQRFile;
+ bool isChess960;
int startPosPlyCounter;
int threadID;
StateInfo* st;
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 {
// Move must not be MOVE_NONE !
};
+ // 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
// Step 6. Razoring
MinimumSplitDepth = get_option_value_int("Minimum Split Depth") * ONE_PLY;
MaxThreadsPerSplitPoint = get_option_value_int("Maximum Number of Threads per Split Point");
MultiPV = get_option_value_int("MultiPV");
- Chess960 = get_option_value_bool("UCI_Chess960");
UseLogFile = get_option_value_bool("Use Search Log");
if (UseLogFile)
// Print RootMoveList startup scoring to the standard output,
// 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
<< " score " << value_to_uci(rml.get_move_score(0))
<< " time " << current_search_time()
o["Emergency Base Time"] = Option(200, 0, 60000);
o["Emergency Move Time"] = Option(70, 0, 5000);
o["Minimum Thinking Time"] = Option(20, 0, 5000);
- o["UCI_Chess960"] = Option(false);
o["UCI_AnalyseMode"] = Option(false);
// Any option should know its name so to be easily printed