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