Files
Chess/testdata/standard.json
MSWS 1177bfa6bf test: Add JSON test cases and integration tests for chess moves
```
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.
2025-03-22 17:46:26 -07:00

221 lines
6.6 KiB
JSON

{
"description": "Some common positions.",
"testCases": [
{
"start": {
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
"description": "Standard starting position."
},
"expected": [
{
"move": "Na3",
"fen": "rnbqkbnr/pppppppp/8/8/8/N7/PPPPPPPP/R1BQKBNR b KQkq - 1 1"
},
{
"move": "Nc3",
"fen": "rnbqkbnr/pppppppp/8/8/8/2N5/PPPPPPPP/R1BQKBNR b KQkq - 1 1"
},
{
"move": "Nf3",
"fen": "rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b KQkq - 1 1"
},
{
"move": "Nh3",
"fen": "rnbqkbnr/pppppppp/8/8/8/7N/PPPPPPPP/RNBQKB1R b KQkq - 1 1"
},
{
"move": "a3",
"fen": "rnbqkbnr/pppppppp/8/8/8/P7/1PPPPPPP/RNBQKBNR b KQkq - 0 1"
},
{
"move": "a4",
"fen": "rnbqkbnr/pppppppp/8/8/P7/8/1PPPPPPP/RNBQKBNR b KQkq a3 0 1"
},
{
"move": "b3",
"fen": "rnbqkbnr/pppppppp/8/8/8/1P6/P1PPPPPP/RNBQKBNR b KQkq - 0 1"
},
{
"move": "b4",
"fen": "rnbqkbnr/pppppppp/8/8/1P6/8/P1PPPPPP/RNBQKBNR b KQkq b3 0 1"
},
{
"move": "c3",
"fen": "rnbqkbnr/pppppppp/8/8/8/2P5/PP1PPPPP/RNBQKBNR b KQkq - 0 1"
},
{
"move": "c4",
"fen": "rnbqkbnr/pppppppp/8/8/2P5/8/PP1PPPPP/RNBQKBNR b KQkq c3 0 1"
},
{
"move": "d3",
"fen": "rnbqkbnr/pppppppp/8/8/8/3P4/PPP1PPPP/RNBQKBNR b KQkq - 0 1"
},
{
"move": "d4",
"fen": "rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq d3 0 1"
},
{
"move": "e3",
"fen": "rnbqkbnr/pppppppp/8/8/8/4P3/PPPP1PPP/RNBQKBNR b KQkq - 0 1"
},
{
"move": "e4",
"fen": "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1"
},
{
"move": "f3",
"fen": "rnbqkbnr/pppppppp/8/8/8/5P2/PPPPP1PP/RNBQKBNR b KQkq - 0 1"
},
{
"move": "f4",
"fen": "rnbqkbnr/pppppppp/8/8/5P2/8/PPPPP1PP/RNBQKBNR b KQkq f3 0 1"
},
{
"move": "g3",
"fen": "rnbqkbnr/pppppppp/8/8/8/6P1/PPPPPP1P/RNBQKBNR b KQkq - 0 1"
},
{
"move": "g4",
"fen": "rnbqkbnr/pppppppp/8/8/6P1/8/PPPPPP1P/RNBQKBNR b KQkq g3 0 1"
},
{
"move": "h3",
"fen": "rnbqkbnr/pppppppp/8/8/8/7P/PPPPPPP1/RNBQKBNR b KQkq - 0 1"
},
{
"move": "h4",
"fen": "rnbqkbnr/pppppppp/8/8/7P/8/PPPPPPP1/RNBQKBNR b KQkq h3 0 1"
}
]
},
{
"start": {
"fen": "r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R b - - 11 7",
"description": "Ruy Lopez opening."
},
"expected": [
{
"move": "Nb4",
"fen": "r1bqkbnr/pppp1ppp/8/1B2p3/1n2P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Nd4",
"fen": "r1bqkbnr/pppp1ppp/8/1B2p3/3nP3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Na5",
"fen": "r1bqkbnr/pppp1ppp/8/nB2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Nce7",
"fen": "r1bqkbnr/ppppnppp/8/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Nb8",
"fen": "rnbqkbnr/pppp1ppp/8/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "a6",
"fen": "r1bqkbnr/1ppp1ppp/p1n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 0 8"
},
{
"move": "a5",
"fen": "r1bqkbnr/1ppp1ppp/2n5/pB2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - a6 0 8"
},
{
"move": "b6",
"fen": "r1bqkbnr/p1pp1ppp/1pn5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 0 8"
},
{
"move": "d6",
"fen": "r1bqkbnr/ppp2ppp/2np4/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 0 8"
},
{
"move": "d5",
"fen": "r1bqkbnr/ppp2ppp/2n5/1B1pp3/4P3/5N2/PPPP1PPP/RNBQK2R w - d6 0 8"
},
{
"move": "f6",
"fen": "r1bqkbnr/pppp2pp/2n2p2/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 0 8"
},
{
"move": "f5",
"fen": "r1bqkbnr/pppp2pp/2n5/1B2pp2/4P3/5N2/PPPP1PPP/RNBQK2R w - f6 0 8"
},
{
"move": "g6",
"fen": "r1bqkbnr/pppp1p1p/2n3p1/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 0 8"
},
{
"move": "g5",
"fen": "r1bqkbnr/pppp1p1p/2n5/1B2p1p1/4P3/5N2/PPPP1PPP/RNBQK2R w - g6 0 8"
},
{
"move": "h6",
"fen": "r1bqkbnr/pppp1pp1/2n4p/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 0 8"
},
{
"move": "h5",
"fen": "r1bqkbnr/pppp1pp1/2n5/1B2p2p/4P3/5N2/PPPP1PPP/RNBQK2R w - h6 0 8"
},
{
"move": "Rb8",
"fen": "1rbqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Qe7",
"fen": "r1b1kbnr/ppppqppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Qf6",
"fen": "r1b1kbnr/pppp1ppp/2n2q2/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Qg5",
"fen": "r1b1kbnr/pppp1ppp/2n5/1B2p1q1/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Qh4",
"fen": "r1b1kbnr/pppp1ppp/2n5/1B2p3/4P2q/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Ke7",
"fen": "r1bq1bnr/ppppkppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Be7",
"fen": "r1bqk1nr/ppppbppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Bd6",
"fen": "r1bqk1nr/pppp1ppp/2nb4/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Bc5",
"fen": "r1bqk1nr/pppp1ppp/2n5/1Bb1p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Bb4",
"fen": "r1bqk1nr/pppp1ppp/2n5/1B2p3/1b2P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Ba3",
"fen": "r1bqk1nr/pppp1ppp/2n5/1B2p3/4P3/b4N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Nf6",
"fen": "r1bqkb1r/pppp1ppp/2n2n2/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Nh6",
"fen": "r1bqkb1r/pppp1ppp/2n4n/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
},
{
"move": "Nge7",
"fen": "r1bqkb1r/ppppnppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w - - 12 8"
}
]
}
]
}