mirror of
https://github.com/MSWS/Chess.git
synced 2025-12-06 05:32:37 -08:00
f83f9dd036528241517e0105e2d239e3d55fa3a6
``` 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.
Description
Languages
Go
100%