mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
Chess: Fix signed/unsigned issues
Make everything signed so that we don't have to deal with silly casting issues thoughout the Chess code. I am unsure if this affects the chess AI negatively, it seems just as "intelligent" before and after this change :^)
This commit is contained in:
parent
d0eb376520
commit
0262a99a1f
3 changed files with 25 additions and 27 deletions
|
@ -55,10 +55,10 @@ struct Piece {
|
|||
constexpr Piece EmptyPiece = { Color::None, Type::None };
|
||||
|
||||
struct Square {
|
||||
unsigned rank; // zero indexed;
|
||||
unsigned file;
|
||||
int rank; // zero indexed;
|
||||
int file;
|
||||
Square(const StringView& name);
|
||||
Square(const unsigned& rank, const unsigned& file)
|
||||
Square(const int& rank, const int& file)
|
||||
: rank(rank)
|
||||
, file(file)
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ struct Square {
|
|||
}
|
||||
}
|
||||
|
||||
bool in_bounds() const { return rank < 8 && file < 8; }
|
||||
bool in_bounds() const { return rank >= 0 && file >= 0 && rank < 8 && file < 8; }
|
||||
bool is_light() const { return (rank % 2) != (file % 2); }
|
||||
String to_algebraic() const;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue