mirror of
https://github.com/MSWS/Chess.git
synced 2025-12-05 21:30:23 -08:00
``` Add comprehensive test cases for chess scenarios and validate JSON parsing in integration tests - Add `integration_test.go` to handle JSON test cases, parse data, and validate chess move generation against expected results. - Add `checkmates.json` with test cases for various checkmate scenarios, including mirrors and edge cases. - Add `famous.json` detailing positions and test sequences from historical chess games for validation. - Add `standard.json` to test and verify early-game chess positions and standard move transitions. - Add `promotions.json` with detailed cases for pawn promotions, including edge scenarios and forced moves. - Add additional JSON files (`castling.json`, `taxing.json`, `pawns.json`, `stalemates.json`) with test data for specific chess rule validations and edge cases like castling, stalemates, and en passant captures. ``` [testdata/integration_test.go] - Adds a new test file to validate JSON-defined chess scenarios against board states and expected moves. - Defines structs for handling test data, including descriptions, starting positions, and expected outcomes. - Implements a test function to read JSON files in the directory, parse them, and execute tests on the data. - Introduces helper functions to parse JSON data and iterate through test cases. - Adds logic to compare expected moves from JSON with generated moves from the chess board state. - Includes error handling for file reading, JSON unmarshalling, and position validation from the chess board. [testdata/checkmates.json] - Added a new JSON file containing test cases for checkmate scenarios. - Each test case includes a FEN description and an expected output. - Descriptions and tests cover specific checkmate types: ladder mate, smothered mate, en passant situations, and minimal-piece mates. - Added transposed positions for each checkmate scenario to validate mirrored setups. [testdata/famous.json] - Added new JSON file containing chess positions and test cases. - Included a "description" field specifying the context of the chess problems. - Each test case specifies a starting position (given by a FEN string) and a list of moves along with their corresponding resulting positions (also as FEN strings). - Added detailed test cases for two famous chess games: "The Game of the Century" and "The Gold Coins Game". - For "The Game of the Century", provided multiple legal move sequences and their outcomes from a specific mid-game position. - For "The Gold Coins Game", included potential moves and their resulting positions leading to the iconic "Gold Coin move". - Enriched some moves with descriptive comments for historical or tactical significance. - Added various chess scenarios to thoroughly test a move generator's capability to handle diverse situations. [testdata/standard.json] - Added a new JSON file containing test cases for specific chess board positions. - The JSON includes: - Definitions of starting positions using FEN strings. - Descriptions of the starting positions, such as "Standard starting position" and "Ruy Lopez opening". - Expected potential moves with resulting FEN states after each move. These moves explore various legal possibilities from the starting positions. - The file contains test cases primarily for validating early-game configurations and various move transitions in chess. [testdata/promotions.json] - Added a new file containing JSON data describing chess test cases focused on pawn promotions. - Included multiple scenarios covering basic promotion, transposed positions, and edge cases such as forced promotion to escape check or mate. - Detailed expected moves and resulting board configurations in FEN format for each scenario. - Descriptions accompanied each test case to clarify the situations being tested, like promoting via capture, forced promotions, or specific checks on the king. - Covered scenarios where multiple promotion options exist, including promotions resulting in check or checkmate. [testdata/castling.json] - Added a new JSON file for castling test cases. - Created test cases for all possible castling scenarios, including: - Normal castling for both sides. - Castling when prohibited due to an attacking piece (rook, bishop, knight, queen, king, and pawn). - Castling into or through check. - Castling when the king or rooks have moved. - Implemented edge cases, including en passant and pawn-promotion interference with castling rights. - Included transposed positions to test symmetry and equivalence in board states. - Supported scenarios where attacks on rooks do not affect castling ability. - Verified that castling remains allowed despite irrelevant pawn attacks or unoccupied intermediate squares. [testdata/taxing.json] - Added a large JSON file containing test cases and expected results for chess positions. - Introduced different scenarios to analyze edge cases: - Positions with pieces in maximal quantity for a specific type (e.g., maximum knights, maximum queens, maximum bishops). - Transposed positions to verify symmetric behavior. - Special rules scenarios like prohibited en passant captures due to check. - Organized data with a `description` for each scenario, `start` positions in FEN format, and corresponding `expected` moves with their resulting positions. - Ensured diverse test coverage, including: - Positions designed to stress test move generation. - Positions covering intricate rules interactions like pawn structure scenarios (en passant). - Positions with multiple complexity levels (low-mobility vs high-mobility positions). [testdata/pawns.json] - Added a new JSON file defining test cases involving pawn positions in chess. - The test cases cover various scenarios with en passant possibilities, moves without en passant, and full pawn setups. - Each test scenario details the starting board position (FEN), a description, and expected moves along with the resulting FEN after each move. - Includes mirrored or transposed versions of positions to test symmetry and edge cases. - Scenarios test both legal and illegal moves, focusing on edge cases like restricted en passant and pawn movement logic. - Ensures test coverage for complex pawn interactions, including rows with dense pawn positions and potential captures. - Scenarios also evaluate king movements in relation to pawns. - Emphasizes positions where rule-specific mechanics, like en passant, are critical to validate correctness. [testdata/stalemates.json] - Added a new JSON test data file for stalemate cases in chess. - Included multiple test cases with starting positions (FEN notation) and expected results. - Each test case represents a specific stalemate scenario or its transpose (mirrored version). - Some descriptions provide details about positions, such as the shortest stalemate possible. - Empty arrays are used for expected outputs, implying no further data is expected from these stalemate setups.
305 lines
7.7 KiB
JSON
305 lines
7.7 KiB
JSON
{
|
|
"description": "Test cases involving pawns.",
|
|
"testCases": [
|
|
{
|
|
"start": {
|
|
"fen": "7k/8/8/8/pPp5/8/8/7K b - b3 0 1",
|
|
"description": "Two possible en passant capture possibilities."
|
|
},
|
|
"expected": [
|
|
{
|
|
"move": "a3",
|
|
"fen": "7k/8/8/8/1Pp5/p7/8/7K w - - 0 2"
|
|
},
|
|
{
|
|
"move": "axb3",
|
|
"fen": "7k/8/8/8/2p5/1p6/8/7K w - - 0 2"
|
|
},
|
|
{
|
|
"move": "c3",
|
|
"fen": "7k/8/8/8/pP6/2p5/8/7K w - - 0 2"
|
|
},
|
|
{
|
|
"move": "cxb3",
|
|
"fen": "7k/8/8/8/p7/1p6/8/7K w - - 0 2"
|
|
},
|
|
{
|
|
"move": "Kg7",
|
|
"fen": "8/6k1/8/8/pPp5/8/8/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kh7",
|
|
"fen": "8/7k/8/8/pPp5/8/8/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kg8",
|
|
"fen": "6k1/8/8/8/pPp5/8/8/7K w - - 1 2"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Transpose of 7k/8/8/8/pPp5/8/8/7K b - b3 0 1",
|
|
"start": {
|
|
"fen": "7k/8/8/PpP5/8/8/8/7K w - b6 0 1",
|
|
"description": "Two possible en passant capture possibilities."
|
|
},
|
|
"expected": [
|
|
{
|
|
"move": "Kg1",
|
|
"fen": "7k/8/8/PpP5/8/8/8/6K1 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kg2",
|
|
"fen": "7k/8/8/PpP5/8/8/6K1/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kh2",
|
|
"fen": "7k/8/8/PpP5/8/8/7K/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "a6",
|
|
"fen": "7k/8/P7/1pP5/8/8/8/7K b - - 0 1"
|
|
},
|
|
{
|
|
"move": "axb6",
|
|
"fen": "7k/8/1P6/2P5/8/8/8/7K b - - 0 1"
|
|
},
|
|
{
|
|
"move": "c6",
|
|
"fen": "7k/8/2P5/Pp6/8/8/8/7K b - - 0 1"
|
|
},
|
|
{
|
|
"move": "cxb6",
|
|
"fen": "7k/8/1P6/P7/8/8/8/7K b - - 0 1"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"start": {
|
|
"fen": "7k/8/8/8/pPp5/8/8/7K b - - 0 1",
|
|
"description": "Same position but without the en passant capture possibilities."
|
|
},
|
|
"expected": [
|
|
{
|
|
"move": "a3",
|
|
"fen": "7k/8/8/8/1Pp5/p7/8/7K w - - 0 2"
|
|
},
|
|
{
|
|
"move": "c3",
|
|
"fen": "7k/8/8/8/pP6/2p5/8/7K w - - 0 2"
|
|
},
|
|
{
|
|
"move": "Kg7",
|
|
"fen": "8/6k1/8/8/pPp5/8/8/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kh7",
|
|
"fen": "8/7k/8/8/pPp5/8/8/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kg8",
|
|
"fen": "6k1/8/8/8/pPp5/8/8/7K w - - 1 2"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Transpose of 7k/8/8/8/pPp5/8/8/7K b - - 0 1",
|
|
"start": {
|
|
"fen": "7k/8/8/PpP5/8/8/8/7K w - - 0 1",
|
|
"description": "Same position but without the en passant capture possibilities."
|
|
},
|
|
"expected": [
|
|
{
|
|
"move": "Kg1",
|
|
"fen": "7k/8/8/PpP5/8/8/8/6K1 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kg2",
|
|
"fen": "7k/8/8/PpP5/8/8/6K1/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kh2",
|
|
"fen": "7k/8/8/PpP5/8/8/7K/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "a6",
|
|
"fen": "7k/8/P7/1pP5/8/8/8/7K b - - 0 1"
|
|
},
|
|
{
|
|
"move": "c6",
|
|
"fen": "7k/8/2P5/Pp6/8/8/8/7K b - - 0 1"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"start": {
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/8/5K2/8 w - - 0 1",
|
|
"description": "Full set of pawns but no moves."
|
|
},
|
|
"expected": [
|
|
{
|
|
"move": "Ke1",
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/8/8/4K3 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kf1",
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/8/8/5K2 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kg1",
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/8/8/6K1 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Ke2",
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/8/4K3/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kg2",
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/8/6K1/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Ke3",
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/4K3/8/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kf3",
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/5K2/8/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kg3",
|
|
"fen": "8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/6K1/8/8 b - - 1 1"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Transpose of 8/4k3/1p1p1p1p/pPpPpPpP/P1P1P1P1/8/5K2/8 w - - 0 1",
|
|
"start": {
|
|
"fen": "8/5k2/8/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 b - - 0 1",
|
|
"description": "Full set of pawns but no moves."
|
|
},
|
|
"expected": [
|
|
{
|
|
"move": "Ke6",
|
|
"fen": "8/8/4k3/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kf6",
|
|
"fen": "8/8/5k2/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kg6",
|
|
"fen": "8/8/6k1/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Ke7",
|
|
"fen": "8/4k3/8/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kg7",
|
|
"fen": "8/6k1/8/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Ke8",
|
|
"fen": "4k3/8/8/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kf8",
|
|
"fen": "5k2/8/8/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kg8",
|
|
"fen": "6k1/8/8/p1p1p1p1/PpPpPpPp/1P1P1P1P/4K3/8 w - - 1 2"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"start": {
|
|
"fen": "8/8/4k3/8/2pPp3/8/B7/7K b - d3 0 1",
|
|
"description": "Black has two en passant possibilities, but only one is legal."
|
|
},
|
|
"expected": [
|
|
{
|
|
"move": "e3",
|
|
"fen": "8/8/4k3/8/2pP4/4p3/B7/7K w - - 0 2"
|
|
},
|
|
{
|
|
"move": "exd3",
|
|
"fen": "8/8/4k3/8/2p5/3p4/B7/7K w - - 0 2"
|
|
},
|
|
{
|
|
"move": "Kd5",
|
|
"fen": "8/8/8/3k4/2pPp3/8/B7/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kf5",
|
|
"fen": "8/8/8/5k2/2pPp3/8/B7/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kd6",
|
|
"fen": "8/8/3k4/8/2pPp3/8/B7/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kf6",
|
|
"fen": "8/8/5k2/8/2pPp3/8/B7/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kd7",
|
|
"fen": "8/3k4/8/8/2pPp3/8/B7/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Ke7",
|
|
"fen": "8/4k3/8/8/2pPp3/8/B7/7K w - - 1 2"
|
|
},
|
|
{
|
|
"move": "Kf7",
|
|
"fen": "8/5k2/8/8/2pPp3/8/B7/7K w - - 1 2"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Transpose of 8/8/4k3/8/2pPp3/8/B7/7K b - d3 0 1",
|
|
"start": {
|
|
"fen": "7k/b7/8/2PpP3/8/4K3/8/8 w - d6 0 1",
|
|
"description": "White has two en passant possibilities, but only one is legal."
|
|
},
|
|
"expected": [
|
|
{
|
|
"move": "Kd2",
|
|
"fen": "7k/b7/8/2PpP3/8/8/3K4/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Ke2",
|
|
"fen": "7k/b7/8/2PpP3/8/8/4K3/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kf2",
|
|
"fen": "7k/b7/8/2PpP3/8/8/5K2/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kd3",
|
|
"fen": "7k/b7/8/2PpP3/8/3K4/8/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kf3",
|
|
"fen": "7k/b7/8/2PpP3/8/5K2/8/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kd4",
|
|
"fen": "7k/b7/8/2PpP3/3K4/8/8/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "Kf4",
|
|
"fen": "7k/b7/8/2PpP3/5K2/8/8/8 b - - 1 1"
|
|
},
|
|
{
|
|
"move": "e6",
|
|
"fen": "7k/b7/4P3/2Pp4/8/4K3/8/8 b - - 0 1"
|
|
},
|
|
{
|
|
"move": "exd6",
|
|
"fen": "7k/b7/3P4/2P5/8/4K3/8/8 b - - 0 1"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
} |