mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Retire color.h
Move contents to piece.h and square.h No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
2ff2b59727
commit
95212222c7
5 changed files with 22 additions and 66 deletions
56
src/color.h
56
src/color.h
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
|
||||
Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Stockfish is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(COLOR_H_INCLUDED)
|
||||
#define COLOR_H_INCLUDED
|
||||
|
||||
#include "types.h"
|
||||
|
||||
////
|
||||
//// Types
|
||||
////
|
||||
|
||||
enum Color {
|
||||
WHITE,
|
||||
BLACK,
|
||||
COLOR_NONE
|
||||
};
|
||||
|
||||
enum SquareColor {
|
||||
DARK,
|
||||
LIGHT
|
||||
};
|
||||
|
||||
ENABLE_OPERATORS_ON(Color)
|
||||
|
||||
|
||||
////
|
||||
//// Inline functions
|
||||
////
|
||||
|
||||
inline Color opposite_color(Color c) {
|
||||
return Color(int(c) ^ 1);
|
||||
}
|
||||
|
||||
inline bool color_is_ok(Color c) {
|
||||
return c == WHITE || c == BLACK;
|
||||
}
|
||||
|
||||
#endif // !defined(COLOR_H_INCLUDED)
|
|
@ -21,7 +21,7 @@
|
|||
#if !defined(EVALUATE_H_INCLUDED)
|
||||
#define EVALUATE_H_INCLUDED
|
||||
|
||||
#include "color.h"
|
||||
#include "piece.h"
|
||||
#include "value.h"
|
||||
|
||||
class Position;
|
||||
|
|
14
src/piece.h
14
src/piece.h
|
@ -20,7 +20,6 @@
|
|||
#if !defined(PIECE_H_INCLUDED)
|
||||
#define PIECE_H_INCLUDED
|
||||
|
||||
#include "color.h"
|
||||
#include "value.h"
|
||||
|
||||
enum PieceType {
|
||||
|
@ -33,8 +32,13 @@ enum Piece {
|
|||
BP = 9, BN = 10, BB = 11, BR = 12, BQ = 13, BK = 14, PIECE_NONE = 16
|
||||
};
|
||||
|
||||
enum Color {
|
||||
WHITE, BLACK, COLOR_NONE
|
||||
};
|
||||
|
||||
ENABLE_OPERATORS_ON(PieceType)
|
||||
ENABLE_OPERATORS_ON(Piece)
|
||||
ENABLE_OPERATORS_ON(Color)
|
||||
|
||||
/// Important: If the material values are changed, one must also
|
||||
/// adjust the piece square tables, and the method game_phase() in the
|
||||
|
@ -65,6 +69,14 @@ inline Color color_of_piece(Piece p) {
|
|||
return Color(int(p) >> 3);
|
||||
}
|
||||
|
||||
inline Color opposite_color(Color c) {
|
||||
return Color(int(c) ^ 1);
|
||||
}
|
||||
|
||||
inline bool color_is_ok(Color c) {
|
||||
return c == WHITE || c == BLACK;
|
||||
}
|
||||
|
||||
inline bool piece_type_is_ok(PieceType pt) {
|
||||
return pt >= PAWN && pt <= KING;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#define POSITION_H_INCLUDED
|
||||
|
||||
#include "bitboard.h"
|
||||
#include "color.h"
|
||||
#include "move.h"
|
||||
#include "piece.h"
|
||||
#include "square.h"
|
||||
|
|
15
src/square.h
15
src/square.h
|
@ -23,8 +23,8 @@
|
|||
#include <cstdlib> // for abs()
|
||||
#include <string>
|
||||
|
||||
#include "color.h"
|
||||
#include "misc.h"
|
||||
#include "piece.h"
|
||||
|
||||
enum Square {
|
||||
SQ_A1, SQ_B1, SQ_C1, SQ_D1, SQ_E1, SQ_F1, SQ_G1, SQ_H1,
|
||||
|
@ -58,13 +58,14 @@ enum Rank {
|
|||
RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
|
||||
};
|
||||
|
||||
enum SquareColor {
|
||||
DARK, LIGHT
|
||||
};
|
||||
|
||||
ENABLE_OPERATORS_ON(Square)
|
||||
ENABLE_OPERATORS_ON(File)
|
||||
ENABLE_OPERATORS_ON(Rank)
|
||||
|
||||
const int FlipMask = 56;
|
||||
const int FlopMask = 7;
|
||||
|
||||
inline Square make_square(File f, Rank r) {
|
||||
return Square((int(r) << 3) | int(f));
|
||||
}
|
||||
|
@ -78,15 +79,15 @@ inline Rank square_rank(Square s) {
|
|||
}
|
||||
|
||||
inline Square flip_square(Square s) {
|
||||
return Square(int(s) ^ FlipMask);
|
||||
return Square(int(s) ^ 56);
|
||||
}
|
||||
|
||||
inline Square flop_square(Square s) {
|
||||
return Square(int(s) ^ FlopMask);
|
||||
return Square(int(s) ^ 7);
|
||||
}
|
||||
|
||||
inline Square relative_square(Color c, Square s) {
|
||||
return Square(int(s) ^ (int(c) * FlipMask));
|
||||
return Square(int(s) ^ (int(c) * 56));
|
||||
}
|
||||
|
||||
inline Rank relative_rank(Color c, Rank r) {
|
||||
|
|
Loading…
Add table
Reference in a new issue