xref: /openbsd-src/games/backgammon/teachgammon/data.c (revision 82114a2f3f1347b64c53af77a94ac7942272c714)
1 /*	$OpenBSD: data.c,v 1.8 2017/01/20 01:55:25 tb Exp $	*/
2 
3 /*
4  * Copyright (c) 1980, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 #include <sys/types.h>
33 
34 #include "tutor.h"
35 
36 int     maxmoves = 23;
37 
38 const char   *const text0[] = {
39 	"To start the game, I roll a 3 and you roll a 1.  This means",
40 	"that I get to start first.  I move 8-5,6-5 since this makes a",
41 	"new point and helps to trap your back men on 1.  You should be",
42 	"able to do a similar move with your roll.",
43 	"",
44 	0
45 };
46 
47 const char   *const text1[] = {
48 	"Now you shall see a move using doubles.  I just rolled double",
49 	"5's.  I will move two men from position 13 to position 3.  The",
50 	"notation for this is 13-8,13-8,8-3,8-3.  You will also roll dou-",
51 	"bles, but you will be able to make a much stronger move.",
52 	"",
53 	0
54 };
55 
56 const char   *const text2[] = {
57 	"Excellent!  As you can see, you are beginning to develop a wall",
58 	"which is trapping my men on position 24.  Also, moving your back",
59 	"men forward not only improves your board position safely, but it",
60 	"thwarts my effort to make a wall.",
61 	"",
62 	"My roll now is 5 6.  Normally, I would use that roll to move from",
63 	"position 24 to position 13 (24-18-13), but your new point prevents",
64 	"that.  Instead, I am forced to move from 13 to 2, where my man is",
65 	"open but cannot be hit.",
66 	"",
67 	0
68 };
69 
70 const char   *const text3[] = {
71 	"As you can see, although you left a man open, it is a rela-",
72 	"tively safe move to an advantageous position, which might help",
73 	"you make a point later.  Only two rolls (4 5 or 5 4) will allow",
74 	"me to hit you.  With an unprecedented amount of luck, I happen",
75 	"to roll a 4 5 and hit you as just mentioned.",
76 	"",
77 	0
78 };
79 
80 const char   *const text4[] = {
81 	"You're pretty lucky yourself, you know.  I follow by rolling 2 3",
82 	"and moving 25-22,24-22, forming a new point.",
83 	"",
84 	0
85 };
86 
87 const char   *const text5[] = {
88 	"Not a spectacular move, but a safe one.  I follow by rolling 6 1.",
89 	"I decide to use this roll to move 22-16,16-15.  It leaves me with",
90 	"one man still open, but the blot is farther back on the board, and",
91 	"would suffer less of a loss by being hit.",
92 	"",
93 	0
94 };
95 
96 const char   *const text6[] = {
97 	"By moving your two men from 17 to 20, you lessen my chance of",
98 	"getting my man off the board.  In fact, the odds are 5 to 4",
99 	"against me getting off.  I roll with the odds and helplessly",
100 	"receive a 3 5.",
101 	"",
102 	0
103 };
104 
105 const char   *const text7[] = {
106 	"Note that the blot on 7 cannot be hit unless I get off the bar",
107 	"and have a 1 or a 6 left over, and doing so will leave two of",
108 	"my men open.  Also, the blot on 16 cannot be hit at all!  With",
109 	"a sigh of frustration, I roll double 6's and remain immobile.",
110 	"",
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 	"",
119 	0
120 };
121 
122 const char   *const text9[] = {
123 	"My venture off the bar did not last long.  However, I got lucky",
124 	"and rolled double 1's, allowing me to move 25-24,24-23,15-14,15-14.",
125 	"",
126 	0
127 };
128 
129 const char   *const text10[] = {
130 	"You are improving your position greatly and safely, and are well",
131 	"on the way to winning the game.  I roll a 6 2 and squeak past",
132 	"your back man.  Now the game becomes a race to the finish.",
133 	"",
134 	0
135 };
136 
137 const char   *const text11[] = {
138 	"Now that it is merely a race, you are trying to get as many men",
139 	"as possible into the inner table, so you can start removing them.",
140 	"I roll a 3 4 and move my two men farthest back to position 11",
141 	"(15-11,14-11).",
142 	"",
143 	0
144 };
145 
146 const char   *const text12[] = {
147 	"The race is still on, and you seem to be doing all right.",
148 	"I roll 6 1 and move 14-8,13-12.",
149 	"",
150 	0
151 };
152 
153 const char   *const text13[] = {
154 	"Notice that you get to remove men the instant you have all of",
155 	"them at your inner table, even if it is the middle of a turn.",
156 	"I roll 1 2 and move 13-11,12-11.",
157 	"",
158 	0
159 };
160 
161 const char   *const text14[] = {
162 	"Although you could have removed a man, this move illustrates two",
163 	"points:  1) You never have to remove men, and 2) You should try",
164 	"to spread out your men on your inner table.  Since you have one",
165 	"man on each position, you should be able to remove at least two",
166 	"men next turn.  I roll 2 5 and move 8-6,11-6.",
167 	"",
168 	0
169 };
170 
171 const char   *const text15[] = {
172 	"This time you were able to remove men.  I roll 3 4 and move",
173 	"11-7,11-8.  The race continues.",
174 	"",
175 	0
176 };
177 
178 const char   *const text16[] = {
179 	"More holes are opening up in your inner table, but you are",
180 	"still very much ahead.  If we were doubling, you would have",
181 	"doubled long ago.  I roll 2 6 and move 8-6,11-5.",
182 	"",
183 	0
184 };
185 
186 const char   *const text17[] = {
187 	"It pays to spread out your men.  I roll 3 5 and move 7-4,8-3.",
188 	"",
189 	0
190 };
191 
192 const char   *const text18[] = {
193 	"You can only remove some men, but you spread out more and",
194 	"more, in order to be able to remove men more efficiently.",
195 	"I roll double 3's, which help, but not that much.  I move",
196 	"8-5,3-0,3-0,3-0.",
197 	"",
198 	0
199 };
200 
201 const char   *const text19[] = {
202 	"I roll 1 4 and move 5-4,4-0.",
203 	"",
204 	0
205 };
206 
207 const char   *const text20[] = {
208 	"You are now nicely spread out to win a game.  I roll 5 6 and",
209 	"move 5-0,6-0.",
210 	"",
211 	0
212 };
213 
214 const char   *const text21[] = {
215 	"Any minute now.  Just a few short steps from victory.  I roll",
216 	"2 4 and move 6-4,4-0.",
217 	"",
218 	0
219 };
220 
221 const char   *const text22[] = {
222 	"It looks pretty hopeless for me, but I play on, rolling 1 3 and",
223 	"moving 4-3,3-0.",
224 	"",
225 	0
226 };
227 
228 const char   *const text23[] = {
229 	"Congratulations!  You just won a game of backgammon against the",
230 	"computer!  This ends the tutorial; next is a real game.  Remember",
231 	"when you start playing that doubling will be enabled, which",
232 	"will add another factor to the game...  Good luck!!",
233 	"",
234 	0
235 };
236 
237 const char   *const ans0[] = {
238 	"Never seen",
239 	"",
240 	0
241 	};
242 
243 const char   *const ans1[] = {
244 	"No, that's still not it.  Here's the move that you should have made:",
245 	"17/4,19/2.  That makes a new point at position 21.  I will make the",
246 	"move for you now, and continue with my own move after that.",
247 	"",
248 	0
249 	};
250 
251 const char   *const ans2[] = {
252 	"Okay, I'll tell you the move that I consider best:  1/66,12/66.  All",
253 	"points, no blots.  I'll make that move now and continue on.",
254 	"",
255 	0
256 	};
257 
258 const char   *const ans3[] = {
259 	"That's not it.  The move I will make for you is 12-14-15.",
260 	"",
261 	0
262 	};
263 
264 const char   *const ans4[] = {
265 	"It's clear that the only move you can do is 0-2-7.",
266 	"",
267 	0
268 	};
269 
270 const char   *const ans5[] = {
271 	"Not optimal.  Your best move is 7-11-12.",
272 	"",
273 	0
274 	};
275 
276 const char   *const ans6[] = {
277 	"There are many passable moves, but the best is 17/33,19/33, which",
278 	"I will do for you now.",
279 	"",
280 	0
281 	};
282 
283 const char   *const ans7[] = {
284 	"That's still not the move I consider best.  I'll force you to play",
285 	"7/5,12/4 and justify it later.",
286 	"",
287 	0
288 	};
289 
290 const char   *const ans8[] = {
291 	"No.  It's pretty clear that 7-10-16, which removes your blots, is best.",
292 	"",
293 	0
294 	};
295 
296 const char   *const ans9[] = {
297 	"No.  Why not 12-17-18?",
298 	"",
299 	0
300 	};
301 
302 const char   *const ans10[] = {
303 	"No.  Your best move is 12/46.",
304 	"",
305 	0
306 	};
307 
308 const char   *const ans11[] = {
309 	"No.  Your best move is 16/3,18/1.",
310 	"",
311 	0
312 	};
313 
314 const char   *const ans12[] = {
315 	"No.  Your best move is 16/35.",
316 	"",
317 	0
318 	};
319 
320 const char   *const ans13[] = {
321 	"No.  Your best move is 18/444,21/4.",
322 	"",
323 	0
324 	};
325 
326 const char   *const ans14[] = {
327 	"No.  Your best move is 22/12.",
328 	"",
329 	0
330 	};
331 
332 const char   *const ans15[] = {
333 	"No.  Your best move is 19-H,22-H.",
334 	"",
335 	0
336 	};
337 
338 const char   *const ans16[] = {
339 	"No.  Your best move is 20/5,23/2.",
340 	"",
341 	0
342 	};
343 
344 const char   *const ans17[] = {
345 	"No.  Your best move is 19-H,24-H.",
346 	"",
347 	0
348 	};
349 
350 const char   *const ans18[] = {
351 	"No.  I think your best move is 20/5,21/2.  I'll move that now.",
352 	"",
353 	0
354 	};
355 
356 const char   *const ans19[] = {
357 	"No.  Your best move is 19/16.",
358 	"",
359 	0
360 	};
361 
362 const char   *const ans20[] = {
363 	"No.  Your best move is 22/3,23/2.",
364 	"",
365 	0
366 	};
367 
368 const char   *const ans21[] = {
369 	"No.  Your best move is 20/1,21-H.",
370 	"",
371 	0
372 	};
373 
374 const char   *const ans22[] = {
375 	"No.  Your best move is 19-H,21-23.",
376 	"",
377 	0
378 	};
379 
380 const char   *const ans23[] = {
381 	"No.  Your best move is 22-H,23-H.",
382 	"",
383 	0
384 	};
385 
386 const struct situatn  test[] = {
387 	{
388 		{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},
389 		3, 1, {8,6,0,0}, {5,5,0,0}, 4, 2, {text0}, {ans0}
390 	},
391 	{
392 		{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},
393 		5, 5, {13,13,8,8}, {8,8,3,3}, 6, 6, {text1}, {ans1}
394 	},
395 	{
396 		{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},
397 		6, 5, {13,8,0,0}, {8,2,0,0}, 1, 2, {text2}, {ans2}
398 	},
399 	{
400 		{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},
401 		4, 5, {24,20,0,0}, {20,15,0,0}, 2, 5, {text3}, {ans3}
402 	},
403 	{
404 		{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},
405 		2, 3, {25,24,0,0}, {22,22,0,0}, 4, 1, {text4}, {ans4}
406 	},
407 	{
408 		{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},
409 		6, 1, {22,16,0,0}, {16,15,0,0}, 3, 3, {text5}, {ans5}
410 	},
411 	{
412 		{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},
413 		3, 5, {0,0,0,0}, {0,0,0,0}, 5, 4, {text6}, {ans6}
414 	},
415 	{
416 		{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},
417 		6, 6, {0,0,0,0}, {0,0,0,0}, 3, 6, {text7}, {ans7}
418 	},
419 	{
420 		{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},
421 		2, 6, {25,23,0,0}, {23,17,0,0}, 5, 1, {text8}, {ans8}
422 	},
423 	{
424 		{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},
425 		1, 1, {25,24,15,15}, {24,23,14,14}, 4, 6, {text9}, {ans9}
426 	},
427 	{
428 		{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},
429 		6, 2, {23,17,0,0}, {17,15,0,0}, 1, 3, {text10}, {ans10}
430 	},
431 	{
432 		{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},
433 		4, 3, {15,14,0,0}, {11,11,0,0}, 5, 3, {text11}, {ans11}
434 	},
435 	{
436 		{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},
437 		6, 1, {14,13,0,0}, {8,12,0,0}, 4, 4, {text12}, {ans12}
438 	},
439 	{
440 		{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},
441 		2, 1, {13,12,0,0}, {11,11,0,0}, 2, 1, {text13}, {ans13}
442 	},
443 	{
444 		{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},
445 		2, 5, {8,11,0,0}, {6,6,0,0}, 6, 3, {text14}, {ans14}
446 	},
447 	{
448 		{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},
449 		4, 3, {11,11,0,0}, {7,8,0,0}, 2, 5, {text15}, {ans15}
450 	},
451 	{
452 		{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},
453 		2, 6, {8,11,0,0}, {6,5,0,0}, 6, 1, {text16}, {ans16}
454 	},
455 	{
456 		{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},
457 		5, 3, {8,7,0,0}, {3,4,0,0}, 5, 2, {text17}, {ans17}
458 	},
459 	{
460 		{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},
461 		3, 3, {8,3,3,3}, {5,0,0,0}, 1, 6, {text18}, {ans18}
462 	},
463 	{
464 		{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},
465 		1, 4, {4,5,0,0}, {0,4,0,0}, 2, 3, {text19}, {ans19}
466 	},
467 	{
468 		{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},
469 		5, 6, {6,5,0,0}, {0,0,0,0}, 1, 4, {text20}, {ans20}
470 	},
471 	{
472 		{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},
473 		2, 4, {4,6,0,0}, {0,4,0,0}, 6, 2, {text21}, {ans21}
474 	},
475 	{
476 		{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},
477 		3, 1, {4,3,0,0}, {3,0,0,0}, 4, 3, {text22}, {ans22}
478 	},
479 	{
480 		{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},
481 		0, 0, {0,0,0,0}, {0,0,0,0}, 0, 0, {text23}, {ans23}
482 	}
483 };
484