2 * endgame -- plays through a chess game ending. enjoy.
4 * Copyright (C) 2002 Blair Tennessy (tennessy@cs.ubc.ca)
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation. No representations are made about the suitability of this
11 * software for any purpose. It is provided "as is" without express or
15 #ifndef __CHESSGAMES_H__
16 #define __CHESSGAMES_H__
18 /** structure for a chess game */
21 /** original board configuration */
22 int board[BOARDSIZE][BOARDSIZE];
28 moves in game. this is a slight hack: moves are encoded in
29 integer pairs (x,y). the first pair, _from_, determines the
30 piece to move. the second pair, _to_, determines where to move.
32 in case _to_ is held by another piece, that piece is taken.
33 (see drawTakePiece(), draw_chess())
35 in case the move promotes a pawn, we assume a queening.
36 (see drawMovingPiece())
39 castling, en passant, under-promotions.
45 ChessGame games[GAMES] = {
50 E. N. Somov-Nasimovitsch
51 White to play and win.
58 { 0, 0, 0, 0, 0, BKING, 0, 0},
59 { BPAWN, 0, BPAWN, 0, BPAWN, 0, 0, 0},
60 { 0, 0, BPAWN, 0, BPAWN, 0, 0, KNIGHT},
61 { PAWN, 0, ROOK, 0, 0, 0, 0, 0},
62 { PAWN, 0, 0, 0, KING, PAWN, 0, 0},
63 { 0, 0, 0, 0, 0, 0, 0, 0},
64 { BPAWN, 0, 0, 0, 0, 0, 0, PAWN},
65 { BBISHOP,0, 0, 0, 0, 0, 0, 0},
82 {3, 2, 4, 2}, /* pawn to bishop 5 */
83 {1, 5, 0, 3}, /* check */
85 {0, 3, 2, 4}, /* takes pawn */
89 {6, 3, 6, 1}, /* rook takes bishop */
102 White to play and win.
109 { 0, 0, 0, 0, 0, 0, 0, 0},
110 { 0, 0, 0, 0, 0, 0, 0, BPAWN},
111 { 0, 0, 0, 0, BPAWN, KING, 0, BKING},
112 { 0, 0, 0, 0, 0, ROOK, 0, 0},
113 { 0, 0, 0, 0, 0, 0, 0, 0},
114 { 0,BBISHOP, 0, 0, BROOK, 0, PAWN, 0},
115 { 0, 0, 0, 0, 0, 0, 0, 0},
116 { 0, 0, 0, 0, 0,BISHOP, 0, 0},
124 {6, 5, 6, 7}, /* check */
128 {5, 6, 4, 6}, /* ! */
139 White to play and win.
146 { 0, 0, 0, KNIGHT, 0, 0, 0, KNIGHT},
147 { 0, KING, BPAWN, BPAWN, 0, 0, 0, 0},
148 { 0, 0, 0, 0, 0, 0, 0, 0},
149 { 0, BKING, 0, 0, 0, 0, 0, 0},
150 { 0, PAWN, 0, 0, 0, BPAWN, 0, 0},
151 { PAWN, 0, PAWN, 0, 0, 0, 0, 0},
152 { 0, 0, 0, 0, 0, 0, 0, 0},
153 { 0, 0, 0, 0, 0, 0, 0, 0},
165 {3, 4, 5, 3}, /* ! */
168 {0, 0, 0, 0}, /* mull it over... */
177 White to play and win.
184 { 0, 0, 0, 0, BQUEEN, 0, 0, 0},
185 {BKNIGHT, 0, 0, 0, 0, 0, 0, 0},
186 { 0, 0, 0, 0, 0, 0, 0, 0},
187 { 0, 0, 0, 0, 0, 0, 0, PAWN},
188 { BKING, 0, BISHOP, 0, KNIGHT, 0, 0, 0},
189 { PAWN, 0, 0, 0, KNIGHT, 0, 0, 0},
190 { 0, 0, 0, 0, 0, 0, 0, 0},
191 { KING, 0, 0, 0, 0, 0, 0, 0},
198 {0, 4, 3, 1}, /* queen wins bishop */
200 {4, 0, 5, 0}, /* king takes pawn */
201 {5, 2, 3, 1}, /* knight takes queen, check */
202 {1, 0, 3, 1}, /* knight takes knight */
203 {3, 7, 2, 7}, /* pawn advances */
207 {2, 7, 1, 7}, /* pawn advances */
219 White to play and win
221 First Prize - "Truda"
226 { 0, 0, BISHOP, 0, 0, 0, 0, 0},
227 { BPAWN, ROOK, 0, 0, 0, 0, 0, 0},
228 { 0, 0, BPAWN, PAWN, 0, BKING, 0, 0},
229 { 0, 0, 0, 0, 0, 0, 0, 0},
230 { 0, 0, 0, 0, 0, 0, KING, BBISHOP},
231 { 0, 0, 0, 0, BPAWN, 0, PAWN, 0},
232 { 0, 0, 0, 0, 0, BPAWN, 0, 0},
233 { 0, 0, 0, 0, 0, 0, 0, 0},
239 {2, 3, 1, 3}, /* pawn to q7 */
240 {2, 5, 1, 4}, /* cover with king */
242 {4, 7, 5, 6}, /* bishop takes pawn */
243 {0, 1, 0, 0}, /* r - r8 */
244 {6, 5, 7, 5}, /* queened */
245 {1, 3, 0, 3}, /* white pawn promoted */
246 {1, 4, 0, 3}, /* king takes queen */
247 {0, 2, 2, 0}, /* discovered check */
248 {5, 6, 0, 1}, /* pull back bishop */
249 {2, 0, 7, 5}, /* bishop takes queen */
251 {7, 5, 2, 0}, /* save rook */
253 {2, 0, 6, 4}, /* bishop takes pawn */
254 {1, 2, 1, 1}, /* king moves in */
267 White to play and win
274 { 0, 0, 0, 0, 0, 0, KNIGHT, 0},
275 { BKNIGHT, 0, 0, 0, 0, 0, 0, 0},
276 { 0, 0, 0, BKING, BKNIGHT, 0, 0, 0},
277 { KING, 0, 0, 0, 0, 0, 0, 0},
278 { 0, 0, 0, 0, 0, 0, KNIGHT, 0},
279 { 0, 0, 0, 0, 0, 0, 0, 0},
280 { 0, 0, 0, 0, 0, 0, 0, 0},
281 { 0, 0, 0, 0, BISHOP, 0, 0, 0},
287 {3, 0, 2, 1}, /* king on move */
288 {1, 0, 0, 2}, /* check */
290 {0, 2, 1, 4}, /* knight moves on */
291 {7, 4, 5, 6}, /* bishop puts king in check */
292 {2, 3, 1, 3}, /* king moves back */
293 {0, 6, 2, 5}, /* knight moves in, check */
294 {1, 3, 0, 3}, /* king moves back queen */
295 {5, 6, 1, 2}, /* bishop - b7 ch!! */
296 {2, 4, 1, 2}, /* black knight takes bishop */
297 {4, 6, 3, 4}, /* knight to k5 */
298 {0, 0, 0, 0}, /* mate */
307 White to play and win
314 { 0, KNIGHT, 0, 0, 0, 0, 0, 0},
315 { 0, 0, 0, 0, 0, 0, 0, 0},
316 { KING, 0, 0, 0, 0, 0, 0, 0},
317 { 0, 0, 0, BKING, 0, 0, 0, 0},
318 { 0, 0, 0, BPAWN, 0, 0, 0, BISHOP},
319 { BPAWN, 0, 0, 0, 0, 0, 0, 0},
320 { 0, 0, PAWN, PAWN, 0, 0, 0, 0},
321 { 0, 0, 0, 0, 0, 0, 0, 0},
327 {0, 1, 2, 2}, /* kt-b6 */
328 {3, 3, 2, 2}, /* k x kt */
329 {4, 7, 2, 5}, /* b-b6 */
330 {2, 2, 3, 3}, /* king back to original position */
331 {6, 3, 5, 3}, /* p-q3! */
332 {5, 0, 6, 0}, /* p-r7 */
333 {6, 2, 4, 2}, /* p-b4ch */
334 {3, 3, 3, 2}, /* king moves, black cannot capture in passing */
335 {2, 0, 1, 1}, /* k-kt7! */
336 {6, 0, 7, 0}, /* promo */
337 {2, 5, 1, 4}, /* mate */
343 #endif /* __CHESSGAMES_H__ */