Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ set(CMAKE_CXX_STANDARD 20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

if(CMAKE_BUILD_TYPE MATCHES Debug)
if(MSVC)
if(CMAKE_HOST_WIN32)
#/WX
add_compile_options(/W4)
add_compile_options(-Wno-unused-parameter)
else()
# Flags to be added once refactor is done
#-Werror
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_library(nginlib STATIC

add_executable(NGin ${SOURCES})

if(MSVC)
if(CMAKE_HOST_WIN32)
set(ENABLED_WARNINGS /Wall)
else()
set(ENABLED_WARNING -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -Wold-style-cast -Wcast-align
Expand Down
12 changes: 6 additions & 6 deletions src/board.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "board.hpp"

auto make_type_ptr(int i, char col, char file, char rank)
auto make_type_ptr(size_t i, char col, char file, char rank)
-> std::unique_ptr<Piece> {
switch (i) {
case 0:
Expand Down Expand Up @@ -34,7 +34,7 @@ Board::Board() {
const std::vector<char> back_rank{'R', 'N', 'B', 'K', 'Q', 'B', 'N', 'R'};
m_pieces.reserve(32);

for (std::size_t i = 0; i < back_rank.size(); i++) {
for (size_t i = 0; i < back_rank.size(); i++) {
char file = char('a' + i);
m_pieces.emplace_back(std::make_unique<Pawn>('w', Square{file, '2'}));
m_pieces.emplace_back(make_type_ptr(i, 'w', file, '1'));
Expand Down Expand Up @@ -105,7 +105,7 @@ auto Board::print_position(std::string &fen) -> void {
if (std::find(pieces.begin(), pieces.end(), i) != std::end(pieces)) {
asci_position += i;
} else if (isdigit(i)) {
asci_position += std::string(i - '0', '.');
asci_position += std::string(size_t(i - '0'), '.');
} else if (i == '/') {
asci_position += '\n';
} else if (i == ' ') {
Expand All @@ -125,14 +125,14 @@ auto Board::print() -> void {
auto rank = piece->get_rank();
// when printing we start at the top left of the board (a8), so rank=7 (0
// index for the array) and file=0 (0 indexed for the array)
int current_square = 64 - rank * 8 + file - 8;
size_t current_square = 64 - rank * 8 + file - 8;
board_position.at(current_square) = piece->get_type();
if (piece->get_colour() == 'b') {
board_position.at(current_square) += 32; // convert to lowercase
}
}

for (int i = 0; i < 64; i++) {
for (size_t i = 0; i < 64; i++) {
std::cout << board_position.at(i);
if ((i + 1) % 8 == 0) {
std::cout << '\n';
Expand Down Expand Up @@ -167,7 +167,7 @@ auto Board::move(const std::string &notation) -> bool {
auto Board::parse_move(const std::string &move) -> void {
// Square src;
Square dst;
int pad{};
size_t pad{};
if (move.at(move.size() - 1) == '+' || move.at(move.size() - 1) == '#') {
pad++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "board.cpp"
#include "player.cpp"

auto main(int argc, char **argv) -> int {
auto main() -> int {

Player player1{"White", 1500.0, 'w'};
Player player2{"Black", 1600.0, 'b'};
Expand Down
4 changes: 2 additions & 2 deletions src/piece.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ auto Piece::get_type() const -> char { return m_type; }

auto Piece::get_colour() const -> char { return m_colour; }

auto Piece::get_file() const -> int { return int(m_position.file - 'a'); }
auto Piece::get_file() const -> size_t { return size_t(m_position.file - 'a'); }

auto Piece::get_rank() const -> int { return int(m_position.rank - '1'); }
auto Piece::get_rank() const -> size_t { return size_t(m_position.rank - '1'); }

auto Piece::get_square() const -> Square { return m_position; }

Expand Down
10 changes: 5 additions & 5 deletions src/piece.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ struct Square {
Square(char file, char rank);
Square(std::string position);
struct HashFunction {
auto operator()(const Square &position) const -> int {
int rowHash = std::hash<char>()(position.file);
int colHash = std::hash<char>()(position.rank) << 1;
auto operator()(const Square &position) const -> size_t {
size_t rowHash = std::hash<char>()(position.file);
size_t colHash = std::hash<char>()(position.rank) << 1;
return rowHash ^ colHash;
}
};
Expand All @@ -44,8 +44,8 @@ class Piece {
Piece(char type, char colour, Square position);
auto get_type() const -> char;
auto get_colour() const -> char;
auto get_file() const -> int;
auto get_rank() const -> int;
auto get_file() const -> size_t;
auto get_rank() const -> size_t;
auto get_square() const -> Square;
auto move(Square dest) -> void;
auto virtual generate_legal_moves(Board &board)
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ include(CTest)
include(Catch)
catch_discover_tests(tests)

if( NOT MSVC AND CMAKE_BUILD_TYPE MATCHES Debug)
if( NOT CMAKE_HOST_WIN32 AND CMAKE_BUILD_TYPE MATCHES Debug)
setup_target_for_coverage_lcov(NAME coverage
EXECUTABLE tests
EXCLUDE "/usr/*" "cmake/catch2/*"
Expand Down