http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.14.tar.gz
[xscreensaver] / hacks / glx / chessgames.h
1 /*
2  * endgame -- plays through a chess game ending.  enjoy.
3  *
4  * Copyright (C) 2002 Blair Tennessy (tennessy@cs.ubc.ca)
5  *
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
12  * implied warranty.
13  */
14
15 #ifndef __CHESSGAMES_H__
16 #define __CHESSGAMES_H__
17
18 /** structure for a chess game */
19 typedef struct {
20
21   /** original board configuration */
22   int board[BOARDSIZE][BOARDSIZE];
23
24   /** total moves */
25   int movecount;
26
27   /** 
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.
31       
32       in case _to_ is held by another piece, that piece is taken.
33       (see drawTakePiece(), draw_chess())
34
35       in case the move promotes a pawn, we assume a queening.
36       (see drawMovingPiece())
37
38       what's lacking? 
39       castling, en passant, under-promotions.
40   */
41   int moves[40][4];
42 } ChessGame;
43
44 #define GAMES 7
45 ChessGame games[GAMES] = {
46   
47   /** 
48       game 1:
49       
50       E. N. Somov-Nasimovitsch
51       White to play and win.
52       
53       "Zadachi I Etiudi"
54       1928
55   */
56   {
57     {
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},
66     },
67     
68     24,
69     
70     { 
71       {3, 2, 6, 2},
72       {7, 0, 6, 1},
73       {6, 2, 6, 6},
74       {0, 5, 0, 4},
75       {6, 6, 0, 6},
76       {0, 4, 1, 3},
77       {2, 7, 1, 5},
78       {2, 2, 3, 2},
79       {0, 6, 0, 3},
80       {1, 3, 2, 2},
81       {0, 3, 6, 3},
82       {3, 2, 4, 2}, /* pawn to bishop 5 */
83       {1, 5, 0, 3}, /* check */
84       {2, 2, 3, 2},
85       {0, 3, 2, 4}, /* takes pawn */
86       {3, 2, 2, 2},
87       {2, 4, 0, 3},
88       {2, 2, 3, 2},
89       {6, 3, 6, 1}, /* rook takes bishop */
90       {6, 0, 7, 0},
91       {6, 1, 3, 1},
92       {3, 2, 2, 3},
93       {3, 1, 3, 3},
94       {0, 0, 2, 3},
95     }
96   },
97
98   /** 
99       game 2: 
100       
101       K. A. L. Kubbel
102       White to play and win.
103       
104       "Chess in the USSR"
105       1936
106   */
107   {
108     {
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},
117     },
118     
119     10,
120     
121     { 
122       {3, 5, 6, 5},
123       {5, 1, 7, 3},
124       {6, 5, 6, 7}, /* check */
125       {7, 3, 3, 7}, 
126       {7, 5, 6, 4}, 
127       {5, 4, 6, 4},
128       {5, 6, 4, 6}, /* ! */
129       {6, 4, 6, 7},
130       {4, 6, 3, 6},
131       {0, 0, 2, 7}
132     }
133   },
134
135   /** 
136       game 3: 
137       
138       J. Hasek
139       White to play and win.
140       
141       "Le Strategie"
142       1929
143   */
144   {
145     {
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},
154     },
155     
156     11,
157
158     { 
159       {0, 3, 2, 2},
160       {1, 3, 2, 2},
161       {0, 7, 2, 6},
162       {4, 5, 5, 5}, 
163       {2, 6, 3, 4}, 
164       {5, 5, 6, 5},
165       {3, 4, 5, 3}, /* ! */
166       {6, 5, 7, 5},
167       {5, 3, 6, 1},
168       {0, 0, 0, 0}, /* mull it over... */
169       {0, 0, 3, 1}
170     }    
171   },
172
173   /** 
174       game 4: 
175
176       M.B. Newman
177       White to play and win.
178       
179       "Chess Amateur"
180       1913
181   */
182   {
183     {
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},
192     },
193     
194     15,
195
196     { 
197       {4, 2, 3, 1},
198       {0, 4, 3, 1}, /* queen wins bishop */
199       {4, 4, 5, 2},
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 */
204       {3, 1, 2, 3},
205       {5, 4, 4, 2},
206       {2, 3, 4, 2},
207       {2, 7, 1, 7}, /* pawn advances */
208       {4, 2, 2, 3},
209       {1, 7, 0, 7},
210       {0, 0, 0, 0},
211       {0, 0, 5, 0}
212     }    
213   },
214
215   /** 
216       game 5:
217
218       V.A. Korolikov
219       White to play and win
220       
221       First Prize - "Truda"
222       1935
223   */
224   {
225     {
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},
234     },
235     
236     21,
237
238     { 
239       {2, 3, 1, 3}, /* pawn to q7 */
240       {2, 5, 1, 4}, /* cover with king */
241       {1, 1, 0, 1},
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 */
250       {0, 3, 1, 2},
251       {7, 5, 2, 0}, /* save rook */
252       {5, 4, 6, 4},
253       {2, 0, 6, 4}, /* bishop takes pawn */
254       {1, 2, 1, 1}, /* king moves in */
255       {6, 4, 5, 5},
256       {1, 1, 0, 0},
257       {5, 5, 2, 2},
258       {0, 0, 0, 0},
259       {0, 0, 0, 0}
260     }    
261   },
262
263   /** 
264       game 6:
265
266       T.B. Gorgiev
267       White to play and win
268       
269       First Prize - "64"
270       1929
271   */
272   {
273     {
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},
282     },
283     
284     13,
285
286     { 
287       {3, 0, 2, 1}, /* king on move */
288       {1, 0, 0, 2}, /* check */
289       {2, 1, 1, 1},
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 */
299       {0, 0, 0, 0}
300     }    
301   },
302
303   /** 
304       game 7:
305
306       K. A. L. Kubbel
307       White to play and win
308       
309       "Schachmatny Listok"
310       1922
311   */
312   {
313     {
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},
322     },
323     
324     12,
325
326     { 
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 */
338       {0, 0, 3, 2},
339     }    
340   },
341 };
342
343 #endif /* __CHESSGAMES_H__ */