Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing moves #23

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Parsing moves #23

wants to merge 3 commits into from

Conversation

ryan597
Copy link
Owner

@ryan597 ryan597 commented Dec 14, 2023

Implement the parse_move function such that board::move with parse input correctly and move the correct piece.

Also include tests for the parsing and move functions.

Fixes #3

Before submitting
  • Was this discussed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?

PR review

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Copy link

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy reports: 5 concern(s)
  • src/board.cpp

    src/board.cpp:107:16: warning: [readability-implicit-bool-conversion]

    implicit conversion 'int' -> bool

        } else if (isdigit(i)) {
                   ^
                              != 0
    /home/runner/work/chessengine/chessengine/src/board.cpp:120:25: warning: 64 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
      board_position.resize(64);
                            ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:128:26: warning: 64 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        int current_square = 64 - rank * 8 + file - 8;
                             ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:128:38: warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        int current_square = 64 - rank * 8 + file - 8;
                                         ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:128:49: warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        int current_square = 64 - rank * 8 + file - 8;
                                                    ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:131:44: warning: 32 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
          board_position.at(current_square) += 32; // convert to lowercase
                                               ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:135:23: warning: 64 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
      for (int i = 0; i < 64; i++) {
                          ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:137:19: warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        if ((i + 1) % 8 == 0) {
                      ^

    src/board.cpp:143:46: warning: [clang-diagnostic-unused-parameter]

    unused parameter 'notation'

    auto Board::is_legal_move(const std::string &notation) -> bool {
                                                 ^

    src/board.cpp:147:15: warning: [performance-for-range-copy]

    loop variable is copied but only used as const reference; consider making it a const reference

        for (auto move : temp_moves) {
                  ^
             const  &
  • tests/test.cpp

    tests/test.cpp:1:10: error: [clang-diagnostic-error]

    'catch2/catch_test_macros.hpp' file not found

    #include <catch2/catch_test_macros.hpp>
             ^

    tests/test.cpp:31:1: warning: [cppcoreguidelines-avoid-non-const-global-variables]

    variable 'TEST_CASE' is non-const and globally accessible, consider making it const

    TEST_CASE("Board constructor sets up pieces correctly", "[board]") {
    ^

Have any feedback or feature suggestions? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Board::move() and Board::parse_move() to find src square
1 participant