From 880e3cd7c82c82776e85042c849e884811378e21 Mon Sep 17 00:00:00 2001 From: lucasart Date: Sat, 9 Aug 2014 13:11:36 +0800 Subject: [PATCH] Move to_char() and to_string() to notation Where they better belong. Also, this removes '#include ' from types.h, which reduces the amount of code to compile (every translation unit includes types.h). No functional change. --- src/bitboard.h | 1 + src/notation.h | 13 +++++++++++++ src/position.cpp | 1 + src/types.h | 15 --------------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/bitboard.h b/src/bitboard.h index 98142683..7330a199 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -21,6 +21,7 @@ #ifndef BITBOARD_H_INCLUDED #define BITBOARD_H_INCLUDED +#include #include "types.h" namespace Bitboards { diff --git a/src/notation.h b/src/notation.h index 730e8416..a8168c53 100644 --- a/src/notation.h +++ b/src/notation.h @@ -32,4 +32,17 @@ const std::string move_to_uci(Move m, bool chess960); const std::string move_to_san(Position& pos, Move m); std::string pretty_pv(Position& pos, int depth, Value score, int64_t msecs, Move pv[]); +inline char to_char(File f, bool tolower = true) { + return char(f - FILE_A + (tolower ? 'a' : 'A')); +} + +inline char to_char(Rank r) { + return char(r - RANK_1 + '1'); +} + +inline const std::string to_string(Square s) { + char ch[] = { to_char(file_of(s)), to_char(rank_of(s)), 0 }; + return ch; +} + #endif // #ifndef NOTATION_H_INCLUDED diff --git a/src/position.cpp b/src/position.cpp index 7b067723..db4c857b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -30,6 +30,7 @@ #include "rkiss.h" #include "thread.h" #include "tt.h" +#include "notation.h" using std::string; diff --git a/src/types.h b/src/types.h index c3911446..f921f9e1 100644 --- a/src/types.h +++ b/src/types.h @@ -405,14 +405,6 @@ inline bool opposite_colors(Square s1, Square s2) { return ((s >> 3) ^ s) & 1; } -inline char to_char(File f, bool tolower = true) { - return char(f - FILE_A + (tolower ? 'a' : 'A')); -} - -inline char to_char(Rank r) { - return char(r - RANK_1 + '1'); -} - inline Square pawn_push(Color c) { return c == WHITE ? DELTA_N : DELTA_S; } @@ -446,11 +438,4 @@ inline bool is_ok(Move m) { return from_sq(m) != to_sq(m); // Catches also MOVE_NULL and MOVE_NONE } -#include - -inline const std::string to_string(Square s) { - char ch[] = { to_char(file_of(s)), to_char(rank_of(s)), 0 }; - return ch; -} - #endif // #ifndef TYPES_H_INCLUDED -- 2.39.2