Toto je starší verze dokumentu!
Šachy
Pro zadanou šachovnici
- vygenerujte všechny kombinace tahů daného hráče v jednoduchém případě (neuvažujte rošády, braní mimochodem, výměnu pěšců za figury)
- vytvořte funkci která pro zadanou pozici detekuje šach
- pozice kdy je šach a všechny tahy vedou do šachu ⇒ šach mat (konec hry)
- omezte vygenerované kombinace z 1 = nepovolte žádné tahy, které vedou do šachu
- nechte počítač hrát proti počítači, zcela náhodné tahy.
Datová reprezetance od ChatGPT
Create a JSON formatted example input of a chess solving program. Use all chess figure types in the example.
{
"board": {
"a8": "r",
"b8": "n",
"c8": "b",
"d8": "q",
"e8": "k",
"f8": "b",
"g8": "n",
"h8": "r",
"a7": "p",
"b7": "p",
"c7": "p",
"d7": "p",
"e7": "p",
"f7": "p",
"g7": "p",
"h7": "p",
"a2": "P",
"b2": "P",
"c2": "P",
"d2": "P",
"e2": "P",
"f2": "P",
"g2": "P",
"h2": "P",
"a1": "R",
"b1": "N",
"c1": "B",
"d1": "Q",
"e1": "K",
"f1": "B",
"g1": "N",
"h1": "R"
},
"turn": "white",
"castling_rights": "KQkq",
"en_passant_target": "e3",
"halfmove_clock": 25,
"fullmove_number": 12
}
In this JSON input:
- The board field represents the current state of the chessboard. Each square is represented by its coordinates (e.g., „a8“ for the square in the bottom-left corner) and the piece occupying it. Lowercase letters represent black pieces, and uppercase letters represent white pieces. Here, „r“ is for a black rook, „n“ for a black knight, „b“ for a black bishop, „q“ for a black queen, „k“ for a black king, „p“ for black pawns, and their uppercase counterparts for white pieces.
- The turn field indicates whose turn it is to move, which is „white“ in this example.
- The castling_rights field indicates the available castling rights. „KQkq“ means both white and black can still castle kingside and queenside.
- The en_passant_target field specifies the target square for en passant captures. In this case, it's „e3“.
- The halfmove_clock field represents the number of half-moves since the last pawn move or capture.
- The fullmove_number field indicates the number of the current full move, where a full move consists of both players making a move.
- castling = rošáda
- en passant = tah mimochodem
ChatGPT nejspíš vychází z https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation a podobných zdrojů
Alternativní seznam
{
"chess_pieces": [
{ "type": "rook", "color": "black", "position": "a8" },
{ "type": "knight", "color": "black", "position": "b8" },
{ "type": "bishop", "color": "black", "position": "c8" },
{ "type": "queen", "color": "black", "position": "d8" },
{ "type": "king", "color": "black", "position": "e8" },
{ "type": "bishop", "color": "black", "position": "f8" },
{ "type": "knight", "color": "black", "position": "g8" },
{ "type": "rook", "color": "black", "position": "h8" },
{ "type": "pawn", "color": "black", "position": "a7" },
{ "type": "pawn", "color": "black", "position": "b7" },
{ "type": "pawn", "color": "black", "position": "c7" },
{ "type": "pawn", "color": "black", "position": "d7" },
{ "type": "pawn", "color": "black", "position": "e7" },
{ "type": "pawn", "color": "black", "position": "f7" },
{ "type": "pawn", "color": "black", "position": "g7" },
{ "type": "pawn", "color": "black", "position": "h7" },
{ "type": "pawn", "color": "white", "position": "a2" },
{ "type": "pawn", "color": "white", "position": "b2" },
{ "type": "pawn", "color": "white", "position": "c2" },
{ "type": "pawn", "color": "white", "position": "d2" },
{ "type": "pawn", "color": "white", "position": "e2" },
{ "type": "pawn", "color": "white", "position": "f2" },
{ "type": "pawn", "color": "white", "position": "g2" },
{ "type": "pawn", "color": "white", "position": "h2" },
{ "type": "rook", "color": "white", "position": "a1" },
{ "type": "knight", "color": "white", "position": "b1" },
{ "type": "bishop", "color": "white", "position": "c1" },
{ "type": "queen", "color": "white", "position": "d1" },
{ "type": "king", "color": "white", "position": "e1" },
{ "type": "bishop", "color": "white", "position": "f1" },
{ "type": "knight", "color": "white", "position": "g1" },
{ "type": "rook", "color": "white", "position": "h1" }
]
}
A ještě lépe parsovatelná pozice:
{
"chess_pieces": [
{ "type": "rook", "color": "black", "position": { "x": 0, "y": 7 } },
{ "type": "knight", "color": "black", "position": { "x": 1, "y": 7 } },
{ "type": "bishop", "color": "black", "position": { "x": 2, "y": 7 } },
{ "type": "queen", "color": "black", "position": { "x": 3, "y": 7 } },
{ "type": "king", "color": "black", "position": { "x": 4, "y": 7 } },
{ "type": "bishop", "color": "black", "position": { "x": 5, "y": 7 } },
{ "type": "knight", "color": "black", "position": { "x": 6, "y": 7 } },
{ "type": "rook", "color": "black", "position": { "x": 7, "y": 7 } },
{ "type": "pawn", "color": "black", "position": { "x": 0, "y": 6 } },
{ "type": "pawn", "color": "black", "position": { "x": 1, "y": 6 } },
{ "type": "pawn", "color": "black", "position": { "x": 2, "y": 6 } },
{ "type": "pawn", "color": "black", "position": { "x": 3, "y": 6 } },
{ "type": "pawn", "color": "black", "position": { "x": 4, "y": 6 } },
{ "type": "pawn", "color": "black", "position": { "x": 5, "y": 6 } },
{ "type": "pawn", "color": "black", "position": { "x": 6, "y": 6 } },
{ "type": "pawn", "color": "black", "position": { "x": 7, "y": 6 } },
{ "type": "pawn", "color": "white", "position": { "x": 0, "y": 1 } },
{ "type": "pawn", "color": "white", "position": { "x": 1, "y": 1 } },
{ "type": "pawn", "color": "white", "position": { "x": 2, "y": 1 } },
{ "type": "pawn", "color": "white", "position": { "x": 3, "y": 1 } },
{ "type": "pawn", "color": "white", "position": { "x": 4, "y": 1 } },
{ "type": "pawn", "color": "white", "position": { "x": 5, "y": 1 } },
{ "type": "pawn", "color": "white", "position": { "x": 6, "y": 1 } },
{ "type": "pawn", "color": "white", "position": { "x": 7, "y": 1 } },
{ "type": "rook", "color": "white", "position": { "x": 0, "y": 0 } },
{ "type": "knight", "color": "white", "position": { "x": 1, "y": 0 } },
{ "type": "bishop", "color": "white", "position": { "x": 2, "y": 0 } },
{ "type": "queen", "color": "white", "position": { "x": 3, "y": 0 } },
{ "type": "king", "color": "white", "position": { "x": 4, "y": 0 } },
{ "type": "bishop", "color": "white", "position": { "x": 5, "y": 0 } },
{ "type": "knight", "color": "white", "position": { "x": 6, "y": 0 } },
{ "type": "rook", "color": "white", "position": { "x": 7, "y": 0 } }
]
}