Initial import from FreeBSD RELENG_4:
[dragonfly.git] / games / backgammon / teachgammon / data.c
1 /*
2  * Copyright (c) 1980, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the University of
16  *      California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33
34 #ifndef lint
35 #if 0
36 static char sccsid[] = "@(#)data.c      8.1 (Berkeley) 5/31/93";
37 #endif
38 static const char rcsid[] =
39  "$FreeBSD: src/games/backgammon/teachgammon/data.c,v 1.4 1999/11/30 03:48:29 billf Exp $";
40 #endif /* not lint */
41
42 #include "tutor.h"
43
44 int     maxmoves = 23;
45
46 const char  *const text0[] = {
47         "To start the game, I roll a 3, and you roll a 1.  This means",
48         "that I get to start first.  I move 8-5,6-5 since this makes a",
49         "new point and helps to trap your back men on 1.  You should be",
50         "able to do a similar move with your roll.",
51         0
52 };
53
54 const char  *const text1[] = {
55         "Now you shall see a move using doubles.  I just rolled double",
56         "5's.  I will move two men from position 13 to position 3.  The",
57         "notation for this is 13-8,13-8,8-3,8-3.  You will also roll dou-",
58         "bles, but you will be able to make a much stronger move.",
59         0
60 };
61
62 const char  *const text2[] = {
63         "Excellent!  As you can see, you are beginning to develop a wall",
64         "which is trapping my men on position 24.  Also, moving your back",
65         "men forward not only improves your board position safely, but it",
66         "thwarts my effort to make a wall.",
67         "",
68         "My roll now is 5 6.  Normally, I would use that roll to move from",
69         "position 24 to position 13 (24-18-13), but your new point prevents",
70         "that.  Instead, I am forced to move from 13 to 2, where my man is",
71         "open but cannot be hit.",
72         0
73 };
74
75 const char  *const text3[] = {
76         "As you can see, although you left a man open, it is a rela-",
77         "tively safe move to an advantageous position, which might help",
78         "you make a point later.  Only two rolls (4 5 or 5 4) will allow",
79         "me to hit you.  With an unprecedented amount of luck, I happen",
80         "to roll a 4 5 and hit you as just mentioned.",
81         0
82 };
83
84 const char  *const text4[] = {
85         "You're pretty lucky yourself, you know.  I follow by rolling 2 3",
86         "and moving 25-22,24-22, forming a new point.",
87         0
88 };
89
90 const char  *const text5[] = {
91         "Not a spectacular move, but a safe one.  I follow by rolling 6 1.",
92         "I decide to use this roll to move 22-16,16-15.  It leaves me with",
93         "one man still open, but the blot is farther back on the board, and",
94         "would suffer less of a loss by being hit.",
95         0
96 };
97
98 const char  *const text6[] = {
99         "By moving your two men from 17 to 20, you lessen my chance of",
100         "getting my man off the board.  In fact, the odds are 5 to 4",
101         "against me getting off.  I roll with the odds and helplessly",
102         "receive a 3 5.",
103         0
104 };
105
106 const char  *const text7[] = {
107         "Note that the blot on 7 cannot be hit unless I get off the bar",
108         "and have a 1 or a 6 left over, and doing so will leave two of",
109         "my men open.  Also, the blot on 16 cannot be hit at all!  With",
110         "a sigh of frustration, I roll double 6's and remain immobile.",
111         0
112 };
113
114 const char  *const text8[] = {
115         "See, you did not get hit and, you got to 'cover up' your open men.",
116         "Quite an accomplishment.  Finally, I get off the bar by rolling",
117         "6 2 and moving 25-23,23-17.",
118         0
119 };
120
121 const char  *const text9[] = {
122         "My venture off the bar did not last long.  However, I got lucky",
123         "and rolled double 1's, allowing me to move 25-24,24-23,15-14,15-14.",
124         0
125 };
126
127 const char  *const text10[] = {
128         "You are improving your position greatly and safely, and are well",
129         "on the way to winning the game.  I roll a 6 2 and squeak past",
130         "your back man.  Now the game becomes a race to the finish.",
131         0
132 };
133
134 const char  *const text11[] = {
135         "Now that it is merely a race, you are trying to get as many men",
136         "as possible into the inner table, so you can start removing them.",
137         "I roll a 3 4 and move my two men farthest back to position 11",
138         "(15-11,14-11).",
139         0
140 };
141
142 const char  *const text12[] = {
143         "The race is still on, and you have seem to be doing all right.",
144         "I roll 6 1 and move 14-8,13-12.",
145         0
146 };
147
148 const char  *const text13[] = {
149         "Notice that you get to remove men the instant you have all of",
150         "them at your inner table, even if it is the middle of a turn.",
151         "I roll 1 2 and move 13-11,12-11.",
152         0
153 };
154
155 const char  *const text14[] = {
156         "Although you could have removed a man, this move illustrates two",
157         "points:  1) You never have to remove men, and 2) You should try",
158         "to spread out your men on your inner table.  Since you have one",
159         "man on each position, you should be able to remove at least two",
160         "men next turn.  I roll 2 5 and move 8-6,11-6.",
161         0
162 };
163
164 const char  *const text15[] = {
165         "This time you were able to remove men.  I roll 3 4 and move",
166         "11-7,11-8.  The race continues.",
167         0
168 };
169
170 const char  *const text16[] = {
171         "More holes are opening up in your inner table, but you are",
172         "still very much ahead.  If we were doubling, you would have",
173         "doubled long ago.  I roll 2 6 and move 8-6,11-5.",
174         0
175 };
176
177 const char  *const text17[] = {
178         "It pays to spread out your men.  I roll 3 5 and move 7-4,8-3.",
179         0
180 };
181
182 const char  *const text18[] = {
183         "You can only remove some men, but you spread out more and",
184         "more, in order to be able to remove men more efficiently.",
185         "I roll double 3's, which help, but not that much.  I move",
186         "8-5,3-0,3-0,3-0.",
187         0
188 };
189
190 const char  *const text19[] = {
191         "I roll 1 4 and move 5-4,4-0.",
192         0
193 };
194
195 const char  *const text20[] = {
196         "You are now nicely spread out to win a game.  I roll 5 6 and",
197         "move 5-0,6-0.",
198         0
199 };
200
201 const char  *const text21[] = {
202         "Any minute now.  Just a few short steps from victory.  I roll",
203         "2 4 and move 6-4,4-0.",
204         0
205 };
206
207 const char  *const text22[] = {
208         "It looks pretty hopeless for me, but I play on, rolling 1 3 and",
209         "moving 4-3,3-0.",
210         0
211 };
212
213 const char  *const text23[] = {
214         "Congratulations!  You just won a game of backgammon against the",
215         "computer!  You will now be able to play a game, but remember,",
216         "when you start playing, that doubling will be enabled, which",
217         "will add another factor to the game...  Good luck!!",
218         "",
219         0
220 };
221
222 const struct situatn  test[] = {
223         {
224                 {0,2,0,0,0,0,-5,0,-3,0,0,0,5,-5,0,0,0,3,0,5,0,0,0,0,-2,0},
225                 3, 1, {8,6,0,0}, {5,5,0,0}, 4, 2, text0
226         },
227         {
228                 {0,2,0,0,0,-2,-4,0,-2,0,0,0,5,-5,0,0,0,2,0,4,0,2,0,0,-2,0},
229                 5, 5, {13,13,8,8}, {8,8,3,3}, 6, 6, text1
230         },
231         {
232                 {0,0,0,-2,0,-2,-4,2,-2,0,0,0,3,-3,0,0,0,2,2,4,0,2,0,0,-2,0},
233                 6, 5, {13,8,0,0}, {8,2,0,0}, 1, 2, text2
234         },
235         {
236                 {0,0,-1,-2,0,-2,-4,2,-2,0,0,0,2,-2,0,1,0,2,2,4,0,2,0,0,-2,0},
237                 4, 5, {24,20,0,0}, {20,15,0,0}, 2, 5, text3
238         },
239         {
240                 {0,0,0,-2,0,-2,-4,3,-2,0,0,0,2,-2,0,-1,0,2,2,4,0,2,0,0,-1,-1},
241                 2, 3, {25,24,0,0}, {22,22,0,0}, 4, 1, text4
242         },
243         {
244                 {0,0,0,-2,0,-2,-4,2,-2,0,0,0,3,-2,0,-1,0,2,2,4,0,2,-2,0,0,0},
245                 6, 1, {22,16,0,0}, {16,15,0,0}, 3, 3, text5
246         },
247         {
248                 {0,0,0,-2,0,-2,-4,2,-2,0,0,0,3,-2,0,-2,0,0,2,2,2,2,2,0,0,-1},
249                 3, 5, {0,0,0,0}, {0,0,0,0}, 5, 4, text6
250         },
251         {
252                 {0,0,0,-2,0,-2,-4,1,-2,0,0,0,3,-2,0,-2,1,0,2,2,2,2,2,0,0,-1},
253                 6, 6, {0,0,0,0}, {0,0,0,0}, 3, 6, text7
254         },
255         {
256                 {0,0,0,-2,0,-2,-4,0,-2,0,0,0,3,-2,0,-2,2,0,2,2,2,2,2,0,0,-1},
257                 2, 6, {25,23,0,0}, {23,17,0,0}, 5, 1, text8
258         },
259         {
260                 {0,0,0,-2,0,-2,-4,0,-2,0,0,0,2,-2,0,-2,2,0,3,2,2,2,2,0,0,-1},
261                 1, 1, {25,24,15,15}, {24,23,14,14}, 4, 6, text9
262         },
263         {
264                 {0,0,0,-2,0,-2,-4,0,-2,0,0,0,0,-2,-2,0,3,0,4,2,2,2,2,-1,0,0},
265                 6, 2, {23,17,0,0}, {17,15,0,0}, 1, 3, text10
266         },
267         {
268                 {0,0,0,-2,0,-2,-4,0,-2,0,0,0,0,-2,-2,-1,2,0,3,4,2,2,2,0,0,0},
269                 4, 3, {15,14,0,0}, {11,11,0,0}, 5, 3, text11
270         },
271         {
272                 {0,0,0,-2,0,-2,-4,0,-2,0,0,-2,0,-2,-1,0,0,0,3,5,2,3,2,0,0,0},
273                 6, 1, {14,13,0,0}, {8,12,0,0}, 4, 4, text12
274         },
275         {
276                 {0,0,0,-2,0,-2,-4,0,-3,0,0,-2,-1,-1,0,0,0,0,0,5,2,2,5,0,0,0},
277                 2, 1, {13,12,0,0}, {11,11,0,0}, 2, 1, text13
278         },
279         {
280                 {0,0,0,-2,0,-2,-4,0,-3,0,0,-4,0,0,0,0,0,0,0,5,2,2,3,1,1,0},
281                 2, 5, {8,11,0,0}, {6,6,0,0}, 6, 3, text14
282         },
283         {
284                 {0,0,0,-2,0,-2,-6,0,-2,0,0,-3,0,0,0,0,0,0,0,4,2,2,2,1,1,0},
285                 4, 3, {11,11,0,0}, {7,8,0,0}, 2, 5, text15
286         },
287         {
288                 {0,0,0,-2,0,-2,-6,-1,-3,0,0,-1,0,0,0,0,0,0,0,4,1,2,2,0,1,0},
289                 2, 6, {8,11,0,0}, {6,5,0,0}, 6, 1, text16
290         },
291         {
292                 {0,0,0,-2,0,-3,-7,-1,-2,0,0,0,0,0,0,0,0,0,0,3,1,2,2,0,0,0},
293                 5, 3, {8,7,0,0}, {3,4,0,0}, 5, 2, text17
294         },
295         {
296                 {0,0,0,-3,-1,-3,-7,0,-1,0,0,0,0,0,0,0,0,0,0,3,0,1,2,1,0,0},
297                 3, 3, {8,3,3,3}, {5,0,0,0}, 1, 6, text18
298         },
299         {
300                 {0,0,0,0,-1,-4,-7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,1,0,0},
301                 1, 4, {4,5,0,0}, {0,4,0,0}, 2, 3, text19
302         },
303         {
304                 {0,0,0,0,-1,-3,-7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0},
305                 5, 6, {6,5,0,0}, {0,0,0,0}, 1, 4, text20
306         },
307         {
308                 {0,0,0,0,-1,-2,-6,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0},
309                 2, 4, {4,6,0,0}, {0,4,0,0}, 6, 2, text21
310         },
311         {
312                 {0,0,0,0,-1,-2,-5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0},
313                 3, 1, {4,3,0,0}, {3,0,0,0}, 4, 3, text22
314         },
315         {
316                 {0,0,0,0,0,-2,-5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
317                 0, 0, {0,0,0,0}, {0,0,0,0}, 0, 0, text23
318         }
319 };