ftp://ftp.krokus.ru/pub/OpenBSD/distfiles/xscreensaver-4.06.tar.gz
[xscreensaver] / hacks / glx / chessgames.h
1 /*
2  * endgame -- plays through a chess game ending.  enjoy.
3  *
4  * Copyright (C) 2002 Blair Tennessy (tennessb@unbc.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       whats lacking? 
39       castling, en passant, under-promotions.  hack at will.
40       more games!  feel free to encode favorites!
41       and this moves[40][4] junk.  i love c!
42   */
43   int moves[40][4];
44 } ChessGame;
45
46 #define GAMES 3
47 ChessGame games[GAMES] = {
48   
49   /** 
50       game 1:
51       
52       E. N. Somov-Nasimovitsch
53       White to play and win.
54       
55       "Zadachi I Etiudi"
56       1928
57   */
58   {
59     {
60       {   0,     0,     0,    0,     0, BKING,    0,    0},
61       {   BPAWN, 0, BPAWN,    0, BPAWN,     0,    0,    0},
62       {   0,     0, BPAWN,    0, BPAWN,     0,    0,    KNIGHT},
63       {   PAWN,  0,  ROOK,    0,     0,     0,    0,    0},
64       {   PAWN,  0,     0,    0,  KING,  PAWN,    0,    0},
65       {   0,     0,     0,    0,     0,     0,    0,    0},
66       {   BPAWN, 0,     0,    0,     0,     0,    0,    PAWN},
67       {  BBISHOP,0,     0,    0,     0,     0,    0,    0},
68     },
69     
70     24,
71     
72     { 
73       {3, 2, 6, 2},
74       {7, 0, 6, 1},
75       {6, 2, 6, 6},
76       {0, 5, 0, 4},
77       {6, 6, 0, 6},
78       {0, 4, 1, 3},
79       {2, 7, 1, 5},
80       {2, 2, 3, 2},
81       {0, 6, 0, 3},
82       {1, 3, 2, 2},
83       {0, 3, 6, 3},
84       {3, 2, 4, 2}, /* pawn to bishop 5 */
85       {1, 5, 0, 3}, /* check */
86       {2, 2, 3, 2},
87       {0, 3, 2, 4}, /* takes pawn */
88       {3, 2, 2, 2},
89       {2, 4, 0, 3},
90       {2, 2, 3, 2},
91       {6, 3, 6, 1}, /* rook takes bishop */
92       {6, 0, 7, 0},
93       {6, 1, 3, 1},
94       {3, 2, 2, 3},
95       {3, 1, 3, 3},
96       {0, 0, 2, 3},
97     }
98   },
99
100   /** 
101       game 2: 
102       
103       K. A. L. Kubbel
104       White to play and win.
105       
106       "Chess in the USSR"
107       1936
108   */
109   {
110     {
111       {   0,     0,     0,    0,     0,     0,    0,    0},
112       {   0,     0,     0,    0,     0,     0,    0,    BPAWN},
113       {   0,     0,     0,    0, BPAWN,  KING,    0,    BKING},
114       {   0,     0,     0,    0,     0,  ROOK,    0,    0},
115       {   0,     0,     0,    0,     0,     0,    0,    0},
116       {  0,BBISHOP,     0,    0, BROOK,     0, PAWN,    0},
117       {   0,     0,     0,    0,     0,     0,    0,    0},
118       {   0,     0,     0,    0,     0,BISHOP,    0,    0},
119     },
120     
121     10,
122     
123     { 
124       {3, 5, 6, 5},
125       {5, 1, 7, 3},
126       {6, 5, 6, 7}, /* check */
127       {7, 3, 3, 7}, 
128       {7, 5, 6, 4}, 
129       {5, 4, 6, 4},
130       {5, 6, 4, 6}, /* ! */
131       {6, 4, 6, 7},
132       {4, 6, 3, 6},
133       {0, 0, 2, 7}
134     }
135   },
136
137   /** 
138       game 3: 
139       
140       J. Hasek
141       White to play and win.
142       
143       "Le Strategie"
144       1929
145   */
146   {
147     {
148       {     0,      0,      0, KNIGHT,      0,      0,      0, KNIGHT},
149       {     0,   KING,  BPAWN,  BPAWN,      0,      0,      0,      0},
150       {     0,      0,      0,      0,      0,      0,      0,      0},
151       {     0,  BKING,      0,      0,      0,      0,      0,      0},
152       {     0,   PAWN,      0,      0,      0,  BPAWN,      0,      0},
153       {  PAWN,      0,   PAWN,      0,      0,      0,      0,      0},
154       {     0,      0,      0,      0,      0,      0,      0,      0},
155       {     0,      0,      0,      0,      0,      0,      0,      0},
156     },
157     
158     11,
159
160     { 
161       {0, 3, 2, 2},
162       {1, 3, 2, 2},
163       {0, 7, 2, 6},
164       {4, 5, 5, 5}, 
165       {2, 6, 3, 4}, 
166       {5, 5, 6, 5},
167       {3, 4, 5, 3}, /* ! */
168       {6, 5, 7, 5},
169       {5, 3, 6, 1},
170       {0, 0, 0, 0}, /* mull it over... */
171       {0, 0, 3, 1}
172     }    
173   }
174 };
175
176 #endif /* __CHESSGAMES_H__ */