mirror of
https://github.com/MSWS/Chess.git
synced 2025-12-05 21:30:23 -08:00
40326d03b0e96c401f9efc9c88a02ab3c89e8251
``` Refactor and enhance board logic, move handling, and test cases - Refactor `board/board.go`: - Rename move fields to uppercase for consistent capitalization (`From`, `To`, `Piece`, etc.). - Add handling for castling restrictions when a rook is captured. - Refactor en passant and promotion logic to align with updated field names. - Introduce a new `Perft` function for move generation debugging. - Refactor `board/move.go`: - Standardize field capitalizations and update corresponding usage in methods (`IsCastle`, `String`, `GetAlgebra`, etc.). - Ensure consistency in pawn moves, sliding moves, and enemy/ally filtering. - Update `board/move_test.go`: - Replace field references (`from`, `to`, etc.) with updated capitalized counterparts. - Update test cases to reflect new naming conventions and improve error readability. - Update `board/board_test.go`: - Adjust test logic and variable references to match capitalized field naming. - Ensure test consistency with updated function and variable naming. - Update `main.go`: - Integrate `Perft` function for move depth evaluation and replace existing logic. - Modify initial FEN string and improve output formatting for perft count. ``` [board/board.go] - **Refactored move field names**: - Renamed lowercase fields (e.g., `from`, `to`, `piece`, `capture`, `promotionTo`) to uppercase (`From`, `To`, `Piece`, `Capture`, `PromotionTo`) to align with Go's convention for exported fields. - **Added handling for castling restrictions**: - Added logic to update the opponent's castling ability when a rook is captured. - **Adjusted en passant logic**: - Refactored en passant related field usage to match updated naming (`move.To`, `move.From`, etc.). - Maintained correct behavior for capture during en passant and validation scenarios. - **Updated UndoMove method**: - Updated field references to use uppercase names for `move` attributes. - Refactored en passant and castling restoration logic. - **Introduced a new `Perft` function**: - Added the `Perft(depth int)` method to calculate the number of legal positions at a given search depth for move generation debugging purposes. - **Improved consistency**: - Standardized field usage across functions (e.g., `Captured` instead of `captured`). - Applied uniform conventions for accessing all attributes across the codebase. - **Enhanced promotion logic**: - Updated the piece promotion logic to reference the refactored field names. - **Refactored applyCastle method**: - Updated logic to use renamed fields (`move.To`, `move.Piece`, `move.Capture`). [board/move.go] - Standardized field capitalizations, modifying `from`, `to`, `piece`, and `capture` to `From`, `To`, `Piece`, and `Capture`. - Updated method calls and assignments to match the new field capitalizations throughout the file. - Adjusted logic in functions related to moves (`IsCastle`, `String`, `GetAlgebra`, etc.) to use updated field names. - Ensured filtering logic for captures and allies checks matches the new field naming conventions. - Made associated updates in pawn move generation, sliding moves, and enemy/ally filtering functions to reference `Capture` instead of `capture`. - Introduced minor layout consistency improvements without altering functionality. [board/move_test.go] - Replaced `move.from`, `move.to`, `move.piece`, and `move.capture` with `move.From`, `move.To`, `move.Piece`, and `move.Capture` for consistent capitalization throughout the file. - Updated method call `perft` to `Perft` in accordance with naming convention changes. - Removed the `perft` function from the file, likely moved somewhere else or made redundant. - Adjusted test cases to reflect changes in attribute and method naming conventions (e.g., `from` to `From`, `to` to `To`, `piece` to `Piece`, `capture` to `Capture`). - Improved error messages in test cases to align with updated attribute names. [board/board_test.go] - Variable case corrections for `move.to` and `move.from` to `move.To` and `move.From` respectively. - Adjusted references of function arguments to match updated casing in various test cases. - Aligned test logic to maintain consistency with adjusted variable naming conventions. - No functional logic changes, only updates for adherence to a particular naming style. [main.go] - Updated the initial board position by changing the FEN string to a new scenario. - Added a new variable `depth` set to 2 for evaluating moves to a specific depth. - Introduced tracking of the total perft count with a new `total` variable. - Replaced the retrieval of new moves with the use of the `Perft` function to calculate possible moves. - Modified the output to print the algebraic notation of moves along with their perft count. - Simplified the final output to display the total count instead of listing all moves.
Description
Languages
Go
100%