5 Commits

Author SHA1 Message Date
Isaac
bbaf785ef8 Apply GoLand formatting (#7) 2025-03-25 04:52:59 +00:00
Isaac
6726754cfe Feat/static check (#5)
* ci: Add and update CI workflows; refine build and test steps

- Add new "Static" GitHub Actions workflow for running `staticcheck`
- Rename `go.yml` to `buildtest.yml` and update workflows
  - Add build and test jobs with caching, coverage, and result publishing
- Update `.gitignore` to exclude `.vscode` files

[.github/workflows/static.yml]
- Added a new GitHub Actions workflow named "Static".
- Configured the workflow to trigger on push and pull request events.
- Defined a CI job running on `ubuntu-latest`.
- Included steps for checking out the repository and running the `staticcheck` tool using a specific version (`2022.1.1`).
[.github/workflows/go.yml]
- Renamed the GitHub Actions workflow file from `go.yml` to `buildtest.yml`.
- Updated the file paths in the `push` trigger to reflect the new filename.
- Renamed the `unit_tests` job to `build` and added a "Build" step to run `go build -v ./...`.
- Introduced a cache setup step in the `build` job for Golang caches, improving build performance.
- Added a new `test` job that runs after the `build` job (with `needs: build` dependency).
   - `test` job includes permissions configuration for checks and pull requests.
   - Installs dependencies, runs tests with coverage, generates JUnit reports, and publishes test results.
- Removed unused permissions settings in the `build` job.
[.gitignore]
- Added `.vscode` to the ignored files in the `.gitignore` file.

* ci: Update checkout action to version 4 in workflow

* ci: Update staticcheck action to version 1.3.1

* ci: Update staticcheck action to use the latest version

* Fix/static errors (#4)

* refactor: Refactor piece enums to prioritize color over type

- Update piece composition order to prioritize color before piece type across relevant files (`Color | Piece` instead of `Piece | Color`)
- Remove `filterEnemies` method from `board/move.go`
- Update test cases and helper functions in `board/fen_test.go` to reflect the new composition order
- Adjust piece constant definitions in `board/pieces_test.go` for consistency with new composition order

[board/pieces_test.go]
- Updated the order of composition for piece constants to prioritize color before piece type (e.g., White | King instead of King | White).
[board/move.go]
- Removed the `filterEnemies` method, which filtered moves based on whether the captured piece was an enemy.
- No other changes to the file.
[board/fen_test.go]
- Reordered enum composition for clarity and consistency, changing the order from `Piece | Color` to `Color | Piece`.
- Updated test cases in `TestGenerateRow` to reflect the new order of enum composition.
  - Modified piece definitions in scenarios including "All Pawns", "Rooks Only", "Alternating Pawns", "Many Kings".
- Adjusted the helper function `getTestBoard` to match the new enum composition order in all board row definitions.

* ci: Refactor workflows by merging test into build job

- Update `.github/workflows/buildtest.yml` to merge "Test" job into "Build" job
- Add explicit permissions for checks and pull-requests in the "Build" job
- Integrate testing, coverage reporting, JUnit report generation, and result publishing into the "Build" job

[.github/workflows/buildtest.yml]
- Added explicit permissions for checks and pull-requests in the "Build" job.
- Removed the "Test" job and merged its steps into the "Build" job.
- Integrated testing, coverage reporting, JUnit report generation, and result publishing directly into the "Build" job.

* ci: Specify read permissions in CI job configuration
2025-03-24 19:51:38 +00:00
Isaac
1b3df458a6 Revert "feat: Implement UCI engine with command processing loop" (#2)
* Revert "feat: Implement UCI engine with command processing loop"

This reverts commit f83f9dd036.

* Run CodeQL
2025-03-24 19:18:30 +00:00
MSWS
f83f9dd036 feat: Implement UCI engine with command processing loop
```
Introduce UCI engine and improve codebase functionality

- Add `CreateMoveUCI` function in `board/move.go` for parsing UCI strings into moves with error handling for invalid inputs.
- Refactor `main.go` to use the `uci` package for implementing a chess engine, replacing legacy functionality and optimizing input handling with `bufio`.
- Add a new `Engine` interface implementation in `uci/engine.go` for handling UCI interactions, including methods for engine initialization, copy protection, and position parsing.
- Add `.vscode` to the `.gitignore` file to exclude editor-specific configurations.
- Add unit tests in `uci/engine_test.go` and `main_test.go` for verifying the UCI engine and main module functionality.
```

[board/move.go]
- Added a new function `CreateMoveUCI` for creating a move using the Universal Chess Interface (UCI) string format.
- The function constructs move coordinates and handles promotion if included in the UCI string.
- Error handling added for invalid promotion piece inputs, with a panic in case of an error.
[main.go]
- Replaced usage of the `fmt` package with `bufio` for input handling.
- Removed logic related to chess board initialization and move generation.
- Introduced new usage of the `uci` package to create and manage a chess engine.
- Implemented a loop to continuously read commands from `stdin`.
- Removed legacy functionality, including FEN parsing, move generation, and `Perft` calculations.
- Added a goroutine to asynchronously handle and process commands using the UCI engine.
[main_test.go]
- Added a new test file for the main package.
[uci/engine.go]
- Added a new implementation of an `Engine` interface for handling UCI (Universal Chess Interface) interactions.
- Defined the `MyEngine` struct with fields for reader, writer, a chess game object, and a debug flag.
- Implemented `Engine` interface methods:
  - `CopyProtection`: Responds with a "copyprotection ok" message.
  - `Init`: Outputs engine metadata such as name and author and indicates UCI readiness.
  - `Debug`: Toggles debug mode.
  - `SetOption`: Stub method added but not yet implemented.
  - `Position`: Parses a FEN string to initialize a chess game and handles errors in debug mode.
- Introduced utility methods for printing through the engine's output stream.
- Provided a constructor function `NewEngine` to initialize a `MyEngine` instance.
[.gitignore]
- Added `.vscode` to the ignored files list.
[uci/engine_test.go]
- Added a test file with unit tests for the UCI engine.
- Implemented a `base` helper function to initialize the engine and establish pipe connections.
- Added a test case `TestInit` to validate the engine's initialization:
  - Ensures that initialization output is read from the pipe.
  - Checks for errors during read operations.
  - Verifies the output matches the expected initialization string.
2025-03-24 12:03:23 -07:00
MSWS
bb3658c01b Initial commit - All files 2024-12-12 03:24:39 -08:00