diff options
| author | lukem <lukem@NetBSD.org> | 1997-10-10 08:59:32 +0000 |
|---|---|---|
| committer | lukem <lukem@NetBSD.org> | 1997-10-10 08:59:32 +0000 |
| commit | af857c197b393612bf159ea798009c9b1bf5200a (patch) | |
| tree | 7cd6f97280a9887610e2221a083496d876206488 /backgammon/teachgammon | |
| parent | 3895ec385efe2f9eb9901519a2e4488af0ac3913 (diff) | |
| download | bsdgames-darwin-af857c197b393612bf159ea798009c9b1bf5200a.tar.gz bsdgames-darwin-af857c197b393612bf159ea798009c9b1bf5200a.zip | |
KNF & WARNSify, and only compile common_source once/* (compiles 25% faster)
Diffstat (limited to 'backgammon/teachgammon')
| -rw-r--r-- | backgammon/teachgammon/Makefile | 12 | ||||
| -rw-r--r-- | backgammon/teachgammon/data.c | 179 | ||||
| -rw-r--r-- | backgammon/teachgammon/teach.c | 127 | ||||
| -rw-r--r-- | backgammon/teachgammon/ttext1.c | 284 | ||||
| -rw-r--r-- | backgammon/teachgammon/ttext2.c | 239 | ||||
| -rw-r--r-- | backgammon/teachgammon/tutor.c | 83 | ||||
| -rw-r--r-- | backgammon/teachgammon/tutor.h | 29 |
7 files changed, 494 insertions, 459 deletions
diff --git a/backgammon/teachgammon/Makefile b/backgammon/teachgammon/Makefile index b97c6796..cd53994f 100644 --- a/backgammon/teachgammon/Makefile +++ b/backgammon/teachgammon/Makefile @@ -1,16 +1,8 @@ -# $NetBSD: Makefile,v 1.7 1997/05/08 21:11:06 gwr Exp $ +# $NetBSD: Makefile,v 1.8 1997/10/10 08:59:50 lukem Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= teachgammon -CFLAGS+=-DV7 -I${.CURDIR}/../common_source -SRCS= allow.c board.c check.c data.c fancy.c init.c odds.c one.c save.c \ - subs.c table.c teach.c ttext1.c ttext2.c tutor.c -DPADD= ${LIBTERM} ${LIBCOMPAT} -LDADD= -ltermcap -lcompat -HIDEGAME=hidegame +SRCS= data.c teach.c ttext1.c ttext2.c tutor.c NOMAN= noman -.PATH: ${.CURDIR}/../common_source - -.include "../../Makefile.inc" .include <bsd.prog.mk> diff --git a/backgammon/teachgammon/data.c b/backgammon/teachgammon/data.c index 0c7b724c..94b1d43e 100644 --- a/backgammon/teachgammon/data.c +++ b/backgammon/teachgammon/data.c @@ -1,4 +1,4 @@ -/* $NetBSD: data.c,v 1.3 1995/03/21 15:06:10 cgd Exp $ */ +/* $NetBSD: data.c,v 1.4 1997/10/10 08:59:51 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,19 +33,20 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: data.c,v 1.3 1995/03/21 15:06:10 cgd Exp $"; +__RCSID("$NetBSD: data.c,v 1.4 1997/10/10 08:59:51 lukem Exp $"); #endif -#endif /* not lint */ +#endif /* not lint */ #include "tutor.h" -int maxmoves = 23; +int maxmoves = 23; -char *text0[] = { +char *text0[] = { "To start the game, I roll a 3, and you roll a 1. This means", "that I get to start first. I move 8-5,6-5 since this makes a", "new point and helps to trap your back men on 1. You should be", @@ -53,7 +54,7 @@ char *text0[] = { 0 }; -char *text1[] = { +char *text1[] = { "Now you shall see a move using doubles. I just rolled double", "5's. I will move two men from position 13 to position 3. The", "notation for this is 13-8,13-8,8-3,8-3. You will also roll dou-", @@ -61,7 +62,7 @@ char *text1[] = { 0 }; -char *text2[] = { +char *text2[] = { "Excellent! As you can see, you are beginning to develop a wall", "which is trapping my men on position 24. Also, moving your back", "men forward not only improves your board position safely, but it", @@ -74,7 +75,7 @@ char *text2[] = { 0 }; -char *text3[] = { +char *text3[] = { "As you can see, although you left a man open, it is a rela-", "tively safe move to an advantageous position, which might help", "you make a point later. Only two rolls (4 5 or 5 4) will allow", @@ -83,13 +84,13 @@ char *text3[] = { 0 }; -char *text4[] = { +char *text4[] = { "You're pretty lucky yourself, you know. I follow by rolling 2 3", "and moving 25-22,24-22, forming a new point.", 0 }; -char *text5[] = { +char *text5[] = { "Not a spectacular move, but a safe one. I follow by rolling 6 1.", "I decide to use this roll to move 22-16,16-17. It leaves me with", "one man still open, but the blot is farther back on the board, and", @@ -97,7 +98,7 @@ char *text5[] = { 0 }; -char *text6[] = { +char *text6[] = { "By moving your two men from 17 to 20, you lessen my chance of", "getting my man off the board. In fact, the odds are 5 to 4", "against me getting off. I roll with the odds and helplessly", @@ -105,7 +106,7 @@ char *text6[] = { 0 }; -char *text7[] = { +char *text7[] = { "Note that the blot on 7 cannot be hit unless I get off the bar", "and have a 1 or a 6 left over, and doing so will leave two of", "my men open. Also, the blot on 16 cannot be hit at all! With", @@ -113,27 +114,27 @@ char *text7[] = { 0 }; -char *text8[] = { +char *text8[] = { "See, you did not get hit and, you got to 'cover up' your open men.", "Quite an accomplishment. Finally, I get off the bar by rolling", "6 2 and moving 25-23,23-17.", 0 }; -char *text9[] = { +char *text9[] = { "My venture off the bar did not last long. However, I got lucky", "and rolled double 1's, allowing me to move 0-1,1-2,15-14,15-14.", 0 }; -char *text10[] = { +char *text10[] = { "You are improving your position greatly and safely, and are well", "on the way to winning the game. I roll a 6 2 and squeak past", "your back man. Now the game becomes a race to the finish.", 0 }; -char *text11[] = { +char *text11[] = { "Now that it is merely a race, you are trying to get as many men", "as possible into the inner table, so you can start removing them.", "I roll a 3 4 and move my two men farthest back to position 11", @@ -141,20 +142,20 @@ char *text11[] = { 0 }; -char *text12[] = { +char *text12[] = { "The race is still on, and you have seem to be doing all right.", "I roll 6 1 and move 14-8,13-12.", 0 }; -char *text13[] = { +char *text13[] = { "Notice that you get to remove men the instant you have all of", "them at your inner table, even if it is the middle of a turn.", "I roll 1 2 and move 13-11,12-11.", 0 }; -char *text14[] = { +char *text14[] = { "Although you could have removed a man, this move illustrates two", "points: 1) You never have to remove men, and 2) You should try", "to spread out your men on your inner table. Since you have one", @@ -163,25 +164,25 @@ char *text14[] = { 0 }; -char *text15[] = { +char *text15[] = { "This time you were able to remove men. I roll 3 4 and move", "11-7,11-8. The race continues.", 0 }; -char *text16[] = { +char *text16[] = { "More holes are opening up in your inner table, but you are", "still very much ahead. If we were doubling, you would have", "doubled long ago. I roll 2 6 and move 8-6,11-5.", 0 }; -char *text17[] = { +char *text17[] = { "It pays to spread out your men. I roll 3 5 and move 7-4,8-3.", 0 }; -char *text18[] = { +char *text18[] = { "You can only remove some men, but you spread out more and", "more, in order to be able to remove men more efficiently.", "I roll double 3's, which help, but not that much. I move", @@ -189,30 +190,30 @@ char *text18[] = { 0 }; -char *text19[] = { +char *text19[] = { "I roll 1 4 and move 5-4,4-0.", 0 }; -char *text20[] = { +char *text20[] = { "You are now nicely spread out to win a game. I roll 5 6 and", "move 5-0,6-0.", 0 }; -char *text21[] = { +char *text21[] = { "Any minute now. Just a few short steps from victory. I roll", "2 4 and move 6-4,4-0.", 0 }; -char *text22[] = { +char *text22[] = { "It looks pretty hopeless for me, but I play on, rolling 1 3 and", "moving 4-3,3-0.", 0 }; -char *text23[] = { +char *text23[] = { "Congratulations! You just won a game of backgammon against the", "computer! You will now be able to play a game, but remember,", "when you start playing, that doubling will be enabled, which", @@ -221,101 +222,125 @@ char *text23[] = { 0 }; -struct situatn test[] = { +struct situatn test[] = { { - {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}, - 3, 1, {8,6,0,0}, {5,5,0,0}, 4, 2, text0 + {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}, + 3, 1, {8, 6, 0, 0}, {5, 5, 0, 0}, 4, 2, {text0} }, { - {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}, - 5, 5, {13,13,8,8}, {8,8,3,3}, 6, 6, text1 + {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}, + 5, 5, {13, 13, 8, 8}, {8, 8, 3, 3}, 6, 6, {text1} }, { - {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}, - 6, 5, {13,8,0,0}, {8,2,0,0}, 1, 2, text2 + {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}, + 6, 5, {13, 8, 0, 0}, {8, 2, 0, 0}, 1, 2, {text2} }, { - {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}, - 4, 5, {24,20,0,0}, {20,15,0,0}, 2, 5, text3 + {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}, + 4, 5, {24, 20, 0, 0}, {20, 15, 0, 0}, 2, 5, {text3} }, { - {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}, - 2, 3, {25,24,0,0}, {22,22,0,0}, 4, 1, text4 + {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}, + 2, 3, {25, 24, 0, 0}, {22, 22, 0, 0}, 4, 1, {text4} }, { - {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}, - 6, 1, {22,16,0,0}, {16,15,0,0}, 3, 3, text5 + {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}, + 6, 1, {22, 16, 0, 0}, {16, 15, 0, 0}, 3, 3, {text5} }, { - {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}, - 3, 5, {0,0,0,0}, {0,0,0,0}, 5, 4, text6 + {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}, + 3, 5, {0, 0, 0, 0}, {0, 0, 0, 0}, 5, 4, {text6} }, { - {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}, - 6, 6, {0,0,0,0}, {0,0,0,0}, 3, 6, text7 + {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}, + 6, 6, {0, 0, 0, 0}, {0, 0, 0, 0}, 3, 6, {text7} }, { - {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}, - 2, 6, {25,23,0,0}, {23,17,0,0}, 5, 1, text8 + {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}, + 2, 6, {25, 23, 0, 0}, {23, 17, 0, 0}, 5, 1, {text8} }, { - {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}, - 1, 1, {25,24,15,15}, {24,23,14,14}, 4, 6, text9 + {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}, + 1, 1, {25, 24, 15, 15}, {24, 23, 14, 14}, 4, 6, {text9} }, { - {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}, - 6, 2, {23,17,0,0}, {17,15,0,0}, 1, 3, text10 + {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}, + 6, 2, {23, 17, 0, 0}, {17, 15, 0, 0}, 1, 3, {text10} }, { - {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}, - 4, 3, {15,14,0,0}, {11,11,0,0}, 5, 3, text11 + {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}, + 4, 3, {15, 14, 0, 0}, {11, 11, 0, 0}, 5, 3, {text11} }, { - {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}, - 6, 1, {14,13,0,0}, {8,12,0,0}, 4, 4, text12 + {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}, + 6, 1, {14, 13, 0, 0}, {8, 12, 0, 0}, 4, 4, {text12} }, { - {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}, - 2, 1, {13,12,0,0}, {11,11,0,0}, 2, 1, text13 + {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}, + 2, 1, {13, 12, 0, 0}, {11, 11, 0, 0}, 2, 1, {text13} }, { - {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}, - 2, 5, {8,11,0,0}, {6,6,0,0}, 6, 3, text14 + {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}, + 2, 5, {8, 11, 0, 0}, {6, 6, 0, 0}, 6, 3, {text14} }, { - {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}, - 4, 3, {11,11,0,0}, {7,8,0,0}, 2, 5, text15 + {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}, + 4, 3, {11, 11, 0, 0}, {7, 8, 0, 0}, 2, 5, {text15} }, { - {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}, - 2, 6, {8,11,0,0}, {6,5,0,0}, 6, 1, text16 + {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}, + 2, 6, {8, 11, 0, 0}, {6, 5, 0, 0}, 6, 1, {text16} }, { - {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}, - 5, 3, {8,7,0,0}, {3,4,0,0}, 5, 2, text17 + {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}, + 5, 3, {8, 7, 0, 0}, {3, 4, 0, 0}, 5, 2, {text17} }, { - {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}, - 3, 3, {8,3,3,3}, {5,0,0,0}, 1, 6, text18 + {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}, + 3, 3, {8, 3, 3, 3}, {5, 0, 0, 0}, 1, 6, {text18} }, { - {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}, - 1, 4, {4,5,0,0}, {0,4,0,0}, 2, 3, text19 + {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}, + 1, 4, {4, 5, 0, 0}, {0, 4, 0, 0}, 2, 3, {text19} }, { - {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}, - 5, 6, {6,5,0,0}, {0,0,0,0}, 1, 4, text20 + {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}, + 5, 6, {6, 5, 0, 0}, {0, 0, 0, 0}, 1, 4, {text20} }, { - {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}, - 2, 4, {4,6,0,0}, {0,4,0,0}, 6, 2, text21 + {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}, + 2, 4, {4, 6, 0, 0}, {0, 4, 0, 0}, 6, 2, {text21} }, { - {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}, - 3, 1, {4,3,0,0}, {3,0,0,0}, 4, 3, text22 + {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}, + 3, 1, {4, 3, 0, 0}, {3, 0, 0, 0}, 4, 3, {text22} }, { - {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}, - 0, 0, {0,0,0,0}, {0,0,0,0}, 0, 0, text23 + {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}, + 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, {text23} } }; diff --git a/backgammon/teachgammon/teach.c b/backgammon/teachgammon/teach.c index 3eaf2739..f473d044 100644 --- a/backgammon/teachgammon/teach.c +++ b/backgammon/teachgammon/teach.c @@ -1,4 +1,4 @@ -/* $NetBSD: teach.c,v 1.4 1995/04/29 00:44:18 mycroft Exp $ */ +/* $NetBSD: teach.c,v 1.5 1997/10/10 08:59:52 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,38 +33,26 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ +__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); +#endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: teach.c,v 1.4 1995/04/29 00:44:18 mycroft Exp $"; +__RCSID("$NetBSD: teach.c,v 1.5 1997/10/10 08:59:52 lukem Exp $"); #endif -#endif /* not lint */ +#endif /* not lint */ #include "back.h" +#include "tutor.h" -char *hello[]; -char *list[]; -char *intro1[]; -char *intro2[]; -char *moves[]; -char *remove[]; -char *hits[]; -char *endgame[]; -char *doubl[]; -char *stragy[]; -char *prog[]; -char *lastch[]; - -extern speed_t ospeed; /* tty output speed for termlib */ - -char *helpm[] = { +extern speed_t ospeed; /* tty output speed for termlib */ + +char *helpm[] = { "\nEnter a space or newline to roll, or", " b to display the board", " d to double", @@ -72,99 +60,102 @@ char *helpm[] = { 0 }; -char *contin[] = { +char *contin[] = { "", 0 }; -main (argc,argv) -int argc; -char **argv; - +int +main(argc, argv) + int argc; + char *argv[]; { - register int i; + int i; - signal (2,getout); - if (tcgetattr (0, &old) == -1) /* get old tty mode */ - errexit ("teachgammon(gtty)"); + signal(2, getout); + if (tcgetattr(0, &old) == -1) /* get old tty mode */ + errexit("teachgammon(gtty)"); noech = old; noech.c_lflag &= ~ECHO; raw = noech; - raw.c_lflag &= ~ICANON; /* set up modes */ - ospeed = cfgetospeed (&old); /* for termlib */ - tflag = getcaps (getenv ("TERM")); + raw.c_lflag &= ~ICANON; /* set up modes */ + ospeed = cfgetospeed(&old); /* for termlib */ + tflag = getcaps(getenv("TERM")); #ifdef V7 while (*++argv != 0) #else while (*++argv != -1) #endif - getarg (&argv); - if (tflag) { - noech.c_oflag &= ~(ONLCR|OXTABS); - raw.c_oflag &= ~(ONLCR|OXTABS); + getarg(&argv); + if (tflag) { + noech.c_oflag &= ~(ONLCR | OXTABS); + raw.c_oflag &= ~(ONLCR | OXTABS); clear(); } - text (hello); - text (list); - i = text (contin); + text(hello); + text(list); + i = text(contin); if (i == 0) i = 2; init(); while (i) - switch (i) { - + switch (i) { case 1: leave(); - + case 2: - if (i = text(intro1)) + if ((i = text(intro1)) != 0) break; wrboard(); - if (i = text(intro2)) + if ((i = text(intro2)) != 0) break; - + case 3: - if (i = text(moves)) + if ((i = text(moves)) != 0) break; - + case 4: - if (i = text(remove)) + if ((i = text(removepiece)) != 0) break; - + case 5: - if (i = text(hits)) + if ((i = text(hits)) != 0) break; - + case 6: - if (i = text(endgame)) + if ((i = text(endgame)) != 0) break; - + case 7: - if (i = text(doubl)) + if ((i = text(doubl)) != 0) break; - + case 8: - if (i = text(stragy)) + if ((i = text(stragy)) != 0) break; - + case 9: - if (i = text(prog)) + if ((i = text(prog)) != 0) break; - + case 10: - if (i = text(lastch)) + if ((i = text(lastch)) != 0) break; } tutor(); + /* NOTREACHED */ + return (0); } -leave() { +void +leave() +{ if (tflag) clear(); else - writec ('\n'); + writec('\n'); fixtty(&old); - execl (EXEC,"backgammon",args,"n",0); - writel ("Help! Backgammon program is missing\007!!\n"); - exit (-1); + execl(EXEC, "backgammon", args, "n", 0); + writel("Help! Backgammon program is missing\007!!\n"); + exit(-1); } diff --git a/backgammon/teachgammon/ttext1.c b/backgammon/teachgammon/ttext1.c index 100b5e45..33a96253 100644 --- a/backgammon/teachgammon/ttext1.c +++ b/backgammon/teachgammon/ttext1.c @@ -1,4 +1,4 @@ -/* $NetBSD: ttext1.c,v 1.3 1995/03/21 15:06:17 cgd Exp $ */ +/* $NetBSD: ttext1.c,v 1.4 1997/10/10 08:59:53 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,158 +33,160 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: ttext1.c,v 1.3 1995/03/21 15:06:17 cgd Exp $"; +__RCSID("$NetBSD: ttext1.c,v 1.4 1997/10/10 08:59:53 lukem Exp $"); #endif -#endif /* not lint */ +#endif /* not lint */ #include "back.h" +#include "tutor.h" -char *opts = " QIMRHEDSPT"; -char *prompt = "-->"; +char *opts = " QIMRHEDSPT"; +char *prompt = "-->"; -char *list[] = { - "\n\n\tI\tIntroduction to Backgammon", - "\tM\tMoves and Points", - "\tR\tRemoving Men from the Board", - "\tH\tHitting Blots", - "\tE\tEnding the Game and Scoring", - "\tD\tDoubling", - "\tS\tStrategy", - "\tP\tThe Program and How to Use It", - "\nalso, you can type:", - "\t?\tto get this list", - "\tQ\tto go start playing", - "\tT\tto go straight to the tutorial", - 0 +char *list[] = { + "\n\n\tI\tIntroduction to Backgammon", + "\tM\tMoves and Points", + "\tR\tRemoving Men from the Board", + "\tH\tHitting Blots", + "\tE\tEnding the Game and Scoring", + "\tD\tDoubling", + "\tS\tStrategy", + "\tP\tThe Program and How to Use It", + "\nalso, you can type:", + "\t?\tto get this list", + "\tQ\tto go start playing", + "\tT\tto go straight to the tutorial", + 0 }; -char *hello[] = { - "\n\032 These rules consist of text describing how to play Backgammon", - "followed by a tutorial session where you play a practice game", - "against the computer. When using this program, think carefuly", - "before typing, since it reacts as soon as you type something. In", - "addition, the program presents text output, such as these rules,", - "in small blocks that will not roll off the top of the screen.", - "Frequently, you will see the characters '-->' indicating that the", - "program is waiting for you to finish reading, and will continue", - "printing when you type a space or newline. Also, the rules are", - "divided into sections, and although you should read them in or-", - "der, you can go directly to any of them by typing one of the fol-", - "lowing letters:", - "(Remember to hit a space or a newline to continue.)", - "", - 0 +char *hello[] = { + "\n\032 These rules consist of text describing how to play Backgammon", + "followed by a tutorial session where you play a practice game", + "against the computer. When using this program, think carefuly", + "before typing, since it reacts as soon as you type something. In", + "addition, the program presents text output, such as these rules,", + "in small blocks that will not roll off the top of the screen.", + "Frequently, you will see the characters '-->' indicating that the", + "program is waiting for you to finish reading, and will continue", + "printing when you type a space or newline. Also, the rules are", + "divided into sections, and although you should read them in or-", + "der, you can go directly to any of them by typing one of the fol-", + "lowing letters:", + "(Remember to hit a space or a newline to continue.)", + "", + 0 }; -char *intro1[] = { - "\nIntroduction:", - "\n Backgammon is a game involving the skill of two players and", - "the luck of two dice. There are two players, red and white, and", - "each player gets fifteen men. The object of the game is to re-", - "move all your men from the board before the opponent does. The", - "board consists of twenty-four positions, a 'bar' and a 'home' for", - "each player. It looks like this:", - "", - 0}; +char *intro1[] = { + "\nIntroduction:", + "\n Backgammon is a game involving the skill of two players and", + "the luck of two dice. There are two players, red and white, and", + "each player gets fifteen men. The object of the game is to re-", + "move all your men from the board before the opponent does. The", + "board consists of twenty-four positions, a 'bar' and a 'home' for", + "each player. It looks like this:", + "", +0}; -char *intro2[] = { - "", - "\n Although not indicated on the board, the players' homes are", - "located just to the right of the board. A player's men are placed", - "there when they are removed from the board. The board you just", - "saw was in it's initial position. All games start with the board", - "looking like this. Notice that red's pieces are represented by the", - "letter 'r' and white's pieces are represented by the letter 'w'.", - "Also, a position may have zero or more pieces on it, e.g. posi-", - "tion 12 has five red pieces on it, while position 11 does not", - "have any pieces of either color.", - "", - 0}; - -char *moves[] = { - "\nMoves and Points:", - "\n Moves are made along the positions on the board according to", - "their numbers. Red moves in the positive direction (clockwise", - "from 1 to 24), and white moves in the negative direction (coun-", - "terclockwise from 24 to 1).", - "\n A turn consists of rolling the dice, and moving the number of", - "positions indicated on each die. The two numbers can be used to", - "move one man the sum of the two rolls, or two men the number on", - "each individual die. For example, if red rolled 6 3 at the start", - "of the game, he might move a man from 1 to 7 to 10, using both", - "dice for one man, or he might move two men from position 12, one", - "to 15 and one to 18. (Red did not have to choose two men start-", - "ing from the same position.) In addition, doubles are treated", - "specially in backgammon. When a player rolls doubles, he gets to", - "move as if he had four dice instead of two. For instance, if you", - "rolled double 2's, you could move one man eight positions, four", - "men two positions each, or any permutation in between.", - "", - "\n However, there are certain limitations, called 'points.' A", - "player has a point when he has two or more men on the same posi-", - "tion. This gives him custody of that position, and his opponent", - "cannot place his men there, even if passing through on the way to", - "another position. When a player has six points in a row, it is", - "called a 'wall,' since any of his opponent's men behind the wall", - "cannot pass it and are trapped, at least for the moment. Notice", - "that this could mean that a player could not use part or all of", - "his roll. However, he must use as much of his roll as possible.", - "", - 0}; +char *intro2[] = { + "", + "\n Although not indicated on the board, the players' homes are", + "located just to the right of the board. A player's men are placed", + "there when they are removed from the board. The board you just", + "saw was in it's initial position. All games start with the board", + "looking like this. Notice that red's pieces are represented by the", + "letter 'r' and white's pieces are represented by the letter 'w'.", + "Also, a position may have zero or more pieces on it, e.g. posi-", + "tion 12 has five red pieces on it, while position 11 does not", + "have any pieces of either color.", + "", +0}; -char *remove[] = { - "\nRemoving Men from the Board:", - "\n The most important part of the game is removing men, since", - "that is how you win the game. Once a man is removed, he stays", - "off the board for the duration of the game. However, a player", - "cannot remove men until all his men are on his 'inner table,' or", - "the last six positions of the board (19-24 for red, 6-1 for", - "white).", - "\n To get off the board, a player must roll the exact number to", - "get his man one position past the last position on the board, or", - "his 'home.' Hence, if red wanted to remove a man from position", - "23, he would have to roll a 2, anything else would be used for", - "another man, or for another purpose. However, there is one ex-", - "ception. If the player rolling has no men far enough to move the", - "roll made, he may move his farthest man off the board. For exam-", - "ple, if red's farthest man back was on position 21, he could re-", - "move men from that position if he rolled a 5 or a 6, as well as a", - "4. Since he does not have men on 20 (where he could use a 5) or", - "on 19 (where he could use a 6), he can use these rolls for posi-", - "tion 21. A player never has to remove men, but he must make as", - "many moves as possible.", - "", - 0}; - -char *hits[] = { - "\nHitting Blots:", - "\n Although two men on a position form an impenetrable point, a", - "lone man is not so secure. Such a man is called a 'blot' and has", - "the potential of getting hit by an opposing man. When a player's", - "blot is hit, he is placed on the bar, and the first thing that", - "player must do is move the man off the bar. Such moves are", - "counted as if the bar is one position behind the first position", - "on the board. Thus if red has a man on the bar and rolls 2 3, he", - "must move the man on the bar to position 2 or 3 before moving any", - "other man. If white had points on positions 2 and 3, then red", - "would forfeit his turn. Being on the bar is a very bad position,", - "for often a player can lose many turns trying to move off the", - "bar, as well as being set back the full distance of the board.", - "", - 0}; - -char *endgame[] = { - "\nEnding the Game and Scoring:", - "\n Winning a game usually wins one point, the normal value of a", - "game. However, if the losing player has not removed any men yet,", - "then the winning player wins double the game value, called a", - "'gammon.' If the losing player has a player on the bar or on the", - "winner's inner table, then the winner gets triple the game value,", - "which is called a 'backgammon.' (So that's where the name comes", - "from!)", - "", - 0}; +char *moves[] = { + "\nMoves and Points:", + "\n Moves are made along the positions on the board according to", + "their numbers. Red moves in the positive direction (clockwise", + "from 1 to 24), and white moves in the negative direction (coun-", + "terclockwise from 24 to 1).", + "\n A turn consists of rolling the dice, and moving the number of", + "positions indicated on each die. The two numbers can be used to", + "move one man the sum of the two rolls, or two men the number on", + "each individual die. For example, if red rolled 6 3 at the start", + "of the game, he might move a man from 1 to 7 to 10, using both", + "dice for one man, or he might move two men from position 12, one", + "to 15 and one to 18. (Red did not have to choose two men start-", + "ing from the same position.) In addition, doubles are treated", + "specially in backgammon. When a player rolls doubles, he gets to", + "move as if he had four dice instead of two. For instance, if you", + "rolled double 2's, you could move one man eight positions, four", + "men two positions each, or any permutation in between.", + "", + "\n However, there are certain limitations, called 'points.' A", + "player has a point when he has two or more men on the same posi-", + "tion. This gives him custody of that position, and his opponent", + "cannot place his men there, even if passing through on the way to", + "another position. When a player has six points in a row, it is", + "called a 'wall,' since any of his opponent's men behind the wall", + "cannot pass it and are trapped, at least for the moment. Notice", + "that this could mean that a player could not use part or all of", + "his roll. However, he must use as much of his roll as possible.", + "", +0}; + +char *removepiece[] = { + "\nRemoving Men from the Board:", + "\n The most important part of the game is removing men, since", + "that is how you win the game. Once a man is removed, he stays", + "off the board for the duration of the game. However, a player", + "cannot remove men until all his men are on his 'inner table,' or", + "the last six positions of the board (19-24 for red, 6-1 for", + "white).", + "\n To get off the board, a player must roll the exact number to", + "get his man one position past the last position on the board, or", + "his 'home.' Hence, if red wanted to remove a man from position", + "23, he would have to roll a 2, anything else would be used for", + "another man, or for another purpose. However, there is one ex-", + "ception. If the player rolling has no men far enough to move the", + "roll made, he may move his farthest man off the board. For exam-", + "ple, if red's farthest man back was on position 21, he could re-", + "move men from that position if he rolled a 5 or a 6, as well as a", + "4. Since he does not have men on 20 (where he could use a 5) or", + "on 19 (where he could use a 6), he can use these rolls for posi-", + "tion 21. A player never has to remove men, but he must make as", + "many moves as possible.", + "", +0}; + +char *hits[] = { + "\nHitting Blots:", + "\n Although two men on a position form an impenetrable point, a", + "lone man is not so secure. Such a man is called a 'blot' and has", + "the potential of getting hit by an opposing man. When a player's", + "blot is hit, he is placed on the bar, and the first thing that", + "player must do is move the man off the bar. Such moves are", + "counted as if the bar is one position behind the first position", + "on the board. Thus if red has a man on the bar and rolls 2 3, he", + "must move the man on the bar to position 2 or 3 before moving any", + "other man. If white had points on positions 2 and 3, then red", + "would forfeit his turn. Being on the bar is a very bad position,", + "for often a player can lose many turns trying to move off the", + "bar, as well as being set back the full distance of the board.", + "", +0}; + +char *endgame[] = { + "\nEnding the Game and Scoring:", + "\n Winning a game usually wins one point, the normal value of a", + "game. However, if the losing player has not removed any men yet,", + "then the winning player wins double the game value, called a", + "'gammon.' If the losing player has a player on the bar or on the", + "winner's inner table, then the winner gets triple the game value,", + "which is called a 'backgammon.' (So that's where the name comes", + "from!)", + "", +0}; diff --git a/backgammon/teachgammon/ttext2.c b/backgammon/teachgammon/ttext2.c index afb431c1..01eafaee 100644 --- a/backgammon/teachgammon/ttext2.c +++ b/backgammon/teachgammon/ttext2.c @@ -1,4 +1,4 @@ -/* $NetBSD: ttext2.c,v 1.4 1995/04/29 00:44:20 mycroft Exp $ */ +/* $NetBSD: ttext2.c,v 1.5 1997/10/10 08:59:53 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,167 +33,168 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: ttext2.c,v 1.4 1995/04/29 00:44:20 mycroft Exp $"; +__RCSID("$NetBSD: ttext2.c,v 1.5 1997/10/10 08:59:53 lukem Exp $"); #endif -#endif /* not lint */ +#endif /* not lint */ #include "back.h" +#include "tutor.h" -char *prompt, *list, *opts; +char *doubl[] = { + "\nDoubling:", + "\n If a player thinks he is in a good position, he may double the", + "value of the game. However, his opponent may not accept the pro-", + "posal and forfeit the game before the price gets too high. A", + "player must double before he rolls, and once his double has been", + "accepted, he cannot double again, until his opponent has doubled.", + "Thus, unless the game swings back and forth in advantage between", + "the two players a great deal, the value of the game should be", + "low. At any rate, the value of the game will never go above 64,", + "or six doubles. However, if a player wins a backgammon at 64", + "points, he wins 192 points!", + "", +0}; -char *doubl[] = { - "\nDoubling:", - "\n If a player thinks he is in a good position, he may double the", - "value of the game. However, his opponent may not accept the pro-", - "posal and forfeit the game before the price gets too high. A", - "player must double before he rolls, and once his double has been", - "accepted, he cannot double again, until his opponent has doubled.", - "Thus, unless the game swings back and forth in advantage between", - "the two players a great deal, the value of the game should be", - "low. At any rate, the value of the game will never go above 64,", - "or six doubles. However, if a player wins a backgammon at 64", - "points, he wins 192 points!", - "", - 0}; +char *stragy[] = { + "\nStrategy:", + "\n Some general hints when playing: Try not to leave men open", + "unless absolutely necessary. Also, it is good to make as many", + "points as possible. Often, two men from different positions can", + "be brought together to form a new point. Although walls (six", + "points in a row) are difficult to form, many points nestled close-", + "ly together produce a formidable barrier. Also, while it is good", + "to move back men forward, doing so lessens the opportunity for you", + "to hit men. Finally, remember that once the two player's have", + "passed each other on the board, there is no chance of either team", + "being hit, so the game reduces to a race off the board. Addi-", + "tional hints on strategy are presented in the practice game.", + "", +0}; -char *stragy[] = { - "\nStrategy:", - "\n Some general hints when playing: Try not to leave men open", - "unless absolutely necessary. Also, it is good to make as many", - "points as possible. Often, two men from different positions can", - "be brought together to form a new point. Although walls (six", - "points in a row) are difficult to form, many points nestled close-", - "ly together produce a formidable barrier. Also, while it is good", - "to move back men forward, doing so lessens the opportunity for you", - "to hit men. Finally, remember that once the two player's have", - "passed each other on the board, there is no chance of either team", - "being hit, so the game reduces to a race off the board. Addi-", - "tional hints on strategy are presented in the practice game.", - "", - 0}; - -char *prog[] = { - "\nThe Program and How It Works:", - "\n A general rule of thumb is when you don't know what to do,", - "type a question mark, and you should get some help. When it is", - "your turn, only your color will be printed out, with nothing", - "after it. You may double by typing a 'd', but if you type a", - "space or newline, you will get your roll. (Remember, you must", - "double before you roll.) Also, typing a 'r' will reprint the", - "board, and a 'q' will quit the game. The program will type", - "'Move:' when it wants your move, and you may indicate each die's", - "move with <s>-<f>, where <s> is the starting position and <f> is", - "the finishing position, or <s>/<r> where <r> is the roll made.", - "<s>-<f1>-<f2> is short for <s>-<f1>,<f1>-<f2> and <s>/<r1><r2> is", - "short for <s>/<r1>,<s>/<r2>. Moves may be separated by a comma", - "or a space.", - "", - "\n While typing, any input which does not make sense will not be", - "echoed, and a bell will sound instead. Also, backspacing and", - "killing lines will echo differently than normal. You may examine", - "the board by typing a 'r' if you have made a partial move, or be-", - "fore you type a newline, to see what the board looks like. You", - "must end your move with a newline. If you cannot double, your", - "roll will always be printed, and you will not be given the oppor-", - "tunity to double. Home and bar are represented by the appropri-", - "ate number, 0 or 25 as the case may be, or by the letters 'h' or", - "'b' as appropriate. You may also type 'r' or 'q' when the program", - "types 'Move:', which has the same effect as above. Finally, you", - "will get to decide if you want to play red or white (or both if you", - "want to play a friend) at the beginning of the session, and you", - "will not get to change your mind later, since the computer keeps", - "score.", - "", - 0}; +char *prog[] = { + "\nThe Program and How It Works:", + "\n A general rule of thumb is when you don't know what to do,", + "type a question mark, and you should get some help. When it is", + "your turn, only your color will be printed out, with nothing", + "after it. You may double by typing a 'd', but if you type a", + "space or newline, you will get your roll. (Remember, you must", + "double before you roll.) Also, typing a 'r' will reprint the", + "board, and a 'q' will quit the game. The program will type", + "'Move:' when it wants your move, and you may indicate each die's", + "move with <s>-<f>, where <s> is the starting position and <f> is", + "the finishing position, or <s>/<r> where <r> is the roll made.", + "<s>-<f1>-<f2> is short for <s>-<f1>,<f1>-<f2> and <s>/<r1><r2> is", + "short for <s>/<r1>,<s>/<r2>. Moves may be separated by a comma", + "or a space.", + "", + "\n While typing, any input which does not make sense will not be", + "echoed, and a bell will sound instead. Also, backspacing and", + "killing lines will echo differently than normal. You may examine", + "the board by typing a 'r' if you have made a partial move, or be-", + "fore you type a newline, to see what the board looks like. You", + "must end your move with a newline. If you cannot double, your", + "roll will always be printed, and you will not be given the oppor-", + "tunity to double. Home and bar are represented by the appropri-", + "ate number, 0 or 25 as the case may be, or by the letters 'h' or", + "'b' as appropriate. You may also type 'r' or 'q' when the program", + "types 'Move:', which has the same effect as above. Finally, you", + "will get to decide if you want to play red or white (or both if you", + "want to play a friend) at the beginning of the session, and you", + "will not get to change your mind later, since the computer keeps", + "score.", + "", +0}; -char *lastch[] = { - "\nTutorial (Practice Game):", - "\n This tutorial, for simplicity's sake, will let you play one", - "predetermined game. All the rolls have been pre-arranged, and", - "only one response will let you advance to the next move.", - "Although a given roll will may have several legal moves, the tu-", - "torial will only accept one (not including the same moves in a", - "different order), claiming that that move is 'best.' Obviously,", - "a subjective statement. At any rate, be patient with it and have", - "fun learning about backgammon. Also, to speed things up a lit-", - "tle, doubling will not take place in the tutorial, so you will", - "never get that opportunity, and quitting only leaves the tutori-", - "al, not the game. You will still be able to play backgammon", - "after quitting.", - "\n This is your last chance to look over the rules before the tu-", - "torial starts.", - "", - 0}; - -text (txt) -char **txt; +char *lastch[] = { + "\nTutorial (Practice Game):", + "\n This tutorial, for simplicity's sake, will let you play one", + "predetermined game. All the rolls have been pre-arranged, and", + "only one response will let you advance to the next move.", + "Although a given roll will may have several legal moves, the tu-", + "torial will only accept one (not including the same moves in a", + "different order), claiming that that move is 'best.' Obviously,", + "a subjective statement. At any rate, be patient with it and have", + "fun learning about backgammon. Also, to speed things up a lit-", + "tle, doubling will not take place in the tutorial, so you will", + "never get that opportunity, and quitting only leaves the tutori-", + "al, not the game. You will still be able to play backgammon", + "after quitting.", + "\n This is your last chance to look over the rules before the tu-", + "torial starts.", + "", +0}; + +int +text(txt) + char **txt; { - char **begin; - char *a; - char b; - char *c; - int i; + char **begin; + char *a; + char b; + char *c; + int i; - fixtty (&noech); + fixtty(&noech); begin = txt; - while (*txt) { + while (*txt) { a = *(txt++); - if (*a != '\0') { + if (*a != '\0') { c = a; for (i = 0; *(c++) != '\0'; i--); - writel (a); - writec ('\n'); - } else { - fixtty (&raw); - writel (prompt); - for (;;) { - if ((b = readc()) == '?') { - if (tflag) { - if (begscr) { - curmove (18,0); + writel(a); + writec('\n'); + } else { + fixtty(&raw); + writel(prompt); + for (;;) { + if ((b = readc()) == '?') { + if (tflag) { + if (begscr) { + curmove(18, 0); clend(); } else clear(); } else - writec ('\n'); - text (list); - writel (prompt); + writec('\n'); + text(list); + writel(prompt); continue; } i = 0; if (b == '\n') break; - while (i < 11) { + while (i < 11) { if (b == opts[i]) break; i++; } if (i == 11) - writec ('\007'); + writec('\007'); else break; } - if (tflag) { - if (begscr) { - curmove (18,0); + if (tflag) { + if (begscr) { + curmove(18, 0); clend(); } else clear(); } else - writec ('\n'); + writec('\n'); if (i) - return(i); - fixtty (&noech); + return (i); + fixtty(&noech); if (tflag) - curmove (curr,0); + curmove(curr, 0); begin = txt; } } - fixtty (&raw); + fixtty(&raw); return (0); } diff --git a/backgammon/teachgammon/tutor.c b/backgammon/teachgammon/tutor.c index 497191ee..06b4d114 100644 --- a/backgammon/teachgammon/tutor.c +++ b/backgammon/teachgammon/tutor.c @@ -1,4 +1,4 @@ -/* $NetBSD: tutor.c,v 1.3 1995/03/21 15:06:27 cgd Exp $ */ +/* $NetBSD: tutor.c,v 1.4 1997/10/10 08:59:54 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,26 +33,24 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: tutor.c,v 1.3 1995/03/21 15:06:27 cgd Exp $"; +__RCSID("$NetBSD: tutor.c,v 1.4 1997/10/10 08:59:54 lukem Exp $"); #endif -#endif /* not lint */ +#endif /* not lint */ #include "back.h" #include "tutor.h" -extern int maxmoves; -extern char *finis[]; +static char better[] = "That is a legal move, but there is a better one.\n"; -extern struct situatn test[]; - -static char better[] = "That is a legal move, but there is a better one.\n"; - -tutor () { - register int i, j; +void +tutor() +{ + int i, j; i = 0; begscr = 18; @@ -68,40 +66,39 @@ tutor () { colen = 5; wrboard(); - while (1) { - if (! brdeq(test[i].brd,board)) { + while (1) { + if (!brdeq(test[i].brd, board)) { if (tflag && curr == 23) - curmove (18,0); - writel (better); + curmove(18, 0); + writel(better); nexturn(); - movback (mvlim); - if (tflag) { + movback(mvlim); + if (tflag) { refresh(); - clrest (); + clrest(); } - if ((! tflag) || curr == 19) { + if ((!tflag) || curr == 19) { proll(); - writec ('\t'); - } - else - curmove (curr > 19? curr-2: curr+4,25); + writec('\t'); + } else + curmove(curr > 19 ? curr - 2 : curr + 4, 25); getmove(); if (cturn == 0) leave(); continue; } if (tflag) - curmove (18,0); - text (*test[i].com); - if (! tflag) - writec ('\n'); + curmove(18, 0); + text(*test[i].com); + if (!tflag) + writec('\n'); if (i == maxmoves) break; D0 = test[i].roll1; D1 = test[i].roll2; d0 = 0; mvlim = 0; - for (j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { if (test[i].mp[j] == test[i].mg[j]) break; p[j] = test[i].mp[j]; @@ -111,7 +108,7 @@ tutor () { if (mvlim) for (j = 0; j < mvlim; j++) if (makmove(j)) - writel ("AARGH!!!\n"); + writel("AARGH!!!\n"); if (tflag) refresh(); nexturn(); @@ -120,7 +117,7 @@ tutor () { d0 = 0; i++; mvlim = movallow(); - if (mvlim) { + if (mvlim) { if (tflag) clrest(); proll(); @@ -135,27 +132,29 @@ tutor () { leave(); } -clrest () { - register int r, c, j; +void +clrest() +{ + int r, c, j; r = curr; c = curc; - for (j = r+1; j < 24; j++) { - curmove (j,0); + for (j = r + 1; j < 24; j++) { + curmove(j, 0); cline(); } - curmove (r,c); + curmove(r, c); } -brdeq (b1,b2) -register int *b1, *b2; - +int +brdeq(b1, b2) + int *b1, *b2; { - register int *e; + int *e; - e = b1+26; + e = b1 + 26; while (b1 < e) if (*b1++ != *b2++) - return(0); - return(1); + return (0); + return (1); } diff --git a/backgammon/teachgammon/tutor.h b/backgammon/teachgammon/tutor.h index bfafd43f..caf40e38 100644 --- a/backgammon/teachgammon/tutor.h +++ b/backgammon/teachgammon/tutor.h @@ -1,4 +1,4 @@ -/* $NetBSD: tutor.h,v 1.3 1995/03/21 15:06:30 cgd Exp $ */ +/* $NetBSD: tutor.h,v 1.4 1997/10/10 08:59:55 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -35,7 +35,7 @@ * @(#)tutor.h 8.1 (Berkeley) 5/31/93 */ -struct situatn { +struct situatn { int brd[26]; int roll1; int roll2; @@ -45,3 +45,28 @@ struct situatn { int new2; char *(*com[8]); }; + + +extern char *doubl[]; +extern char *endgame[]; +extern char *finis[]; +extern char *hello[]; +extern char *hits[]; +extern char *intro1[]; +extern char *intro2[]; +extern char *lastch[]; +extern char *list[]; +extern int maxmoves; +extern char *moves[]; +extern char *opts; +extern char *prog[]; +extern char *prompt; +extern char *removepiece[]; +extern char *stragy[]; +extern struct situatn test[]; + + +int brdeq __P((int *, int *)); +void clrest __P((void)); +void leave __P((void)); +void tutor __P((void)); |
