diff options
author | Jean-Baptiste Boric <jblbeurope@gmail.com> | 2021-05-16 14:55:20 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-17 18:14:05 +0100 |
commit | 0262a99a1f0b0c07de4a5742d05338133b18c3ef (patch) | |
tree | 902f78f9fd5bfb1b3e5c8c107fdd7919f885b3c5 /Userland/Libraries/LibChess/Chess.h | |
parent | d0eb376520db8fc2f95547f272fe4727f247d0fa (diff) | |
download | serenity-0262a99a1f0b0c07de4a5742d05338133b18c3ef.zip |
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 :^)
Diffstat (limited to 'Userland/Libraries/LibChess/Chess.h')
-rw-r--r-- | Userland/Libraries/LibChess/Chess.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibChess/Chess.h b/Userland/Libraries/LibChess/Chess.h index 7ffccf36a8..ac227ea287 100644 --- a/Userland/Libraries/LibChess/Chess.h +++ b/Userland/Libraries/LibChess/Chess.h @@ -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; }; |