Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / games / backgammon / teachgammon / ttext1.c
blob73ea6ee83bfa7fbb4a9e8d299da46bb07a665ec7
1 /* $NetBSD: ttext1.c,v 1.7 2003/08/07 09:36:58 agc Exp $ */
3 /*
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
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.
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.
32 #include <sys/cdefs.h>
33 #ifndef lint
34 #if 0
35 static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93";
36 #else
37 __RCSID("$NetBSD: ttext1.c,v 1.7 2003/08/07 09:36:58 agc Exp $");
38 #endif
39 #endif /* not lint */
41 #include "back.h"
42 #include "tutor.h"
44 const char *const opts = " QIMRHEDSPT";
45 const char *const prompt = "-->";
47 const char *const list[] = {
48 "\n\n\tI\tIntroduction to Backgammon",
49 "\tM\tMoves and Points",
50 "\tR\tRemoving Men from the Board",
51 "\tH\tHitting Blots",
52 "\tE\tEnding the Game and Scoring",
53 "\tD\tDoubling",
54 "\tS\tStrategy",
55 "\tP\tThe Program and How to Use It",
56 "\nalso, you can type:",
57 "\t?\tto get this list",
58 "\tQ\tto go start playing",
59 "\tT\tto go straight to the tutorial",
63 const char *const hello[] = {
64 "\n These rules consist of text describing how to play Backgammon",
65 "followed by a tutorial session where you play a practice game",
66 "against the computer. When using this program, think carefuly",
67 "before typing, since it reacts as soon as you type something. In",
68 "addition, the program presents text output, such as these rules,",
69 "in small blocks that will not roll off the top of the screen.",
70 "Frequently, you will see the characters '-->' indicating that the",
71 "program is waiting for you to finish reading, and will continue",
72 "printing when you type a space or newline. Also, the rules are",
73 "divided into sections, and although you should read them in or-",
74 "der, you can go directly to any of them by typing one of the fol-",
75 "lowing letters:",
76 "(Remember to hit a space or a newline to continue.)",
77 "",
81 const char *const intro1[] = {
82 "\nIntroduction:",
83 "\n Backgammon is a game involving the skill of two players and",
84 "the luck of two dice. There are two players, red and white, and",
85 "each player gets fifteen men. The object of the game is to re-",
86 "move all your men from the board before the opponent does. The",
87 "board consists of twenty-four positions, a 'bar' and a 'home' for",
88 "each player. It looks like this:",
89 "",
90 0};
92 const char *const intro2[] = {
93 "",
94 "\n Although not indicated on the board, the players' homes are",
95 "located just to the right of the board. A player's men are placed",
96 "there when they are removed from the board. The board you just",
97 "saw was in its initial position. All games start with the board",
98 "looking like this. Notice that red's pieces are represented by the",
99 "letter 'r' and white's pieces are represented by the letter 'w'.",
100 "Also, a position may have zero or more pieces on it, e.g. posi-",
101 "tion 12 has five red pieces on it, while position 11 does not",
102 "have any pieces of either color.",
106 const char *const moves[] = {
107 "\nMoves and Points:",
108 "\n Moves are made along the positions on the board according to",
109 "their numbers. Red moves in the positive direction (clockwise",
110 "from 1 to 24), and white moves in the negative direction (coun-",
111 "terclockwise from 24 to 1).",
112 "\n A turn consists of rolling the dice, and moving the number of",
113 "positions indicated on each die. The two numbers can be used to",
114 "move one man the sum of the two rolls, or two men the number on",
115 "each individual die. For example, if red rolled 6 3 at the start",
116 "of the game, he might move a man from 1 to 7 to 10, using both",
117 "dice for one man, or he might move two men from position 12, one",
118 "to 15 and one to 18. (Red did not have to choose two men start-",
119 "ing from the same position.) In addition, doubles are treated",
120 "specially in backgammon. When a player rolls doubles, he gets to",
121 "move as if he had four dice instead of two. For instance, if you",
122 "rolled double 2's, you could move one man eight positions, four",
123 "men two positions each, or any permutation in between.",
125 "\n However, there are certain limitations, called 'points.' A",
126 "player has a point when he has two or more men on the same posi-",
127 "tion. This gives him custody of that position, and his opponent",
128 "cannot place his men there, even if passing through on the way to",
129 "another position. When a player has six points in a row, it is",
130 "called a 'wall,' since any of his opponent's men behind the wall",
131 "cannot pass it and are trapped, at least for the moment. Notice",
132 "that this could mean that a player could not use part or all of",
133 "his roll. However, he must use as much of his roll as possible.",
137 const char *const removepiece[] = {
138 "\nRemoving Men from the Board:",
139 "\n The most important part of the game is removing men, since",
140 "that is how you win the game. Once a man is removed, he stays",
141 "off the board for the duration of the game. However, a player",
142 "cannot remove men until all his men are on his 'inner table,' or",
143 "the last six positions of the board (19-24 for red, 6-1 for",
144 "white).",
145 "\n To get off the board, a player must roll the exact number to",
146 "get his man one position past the last position on the board, or",
147 "his 'home.' Hence, if red wanted to remove a man from position",
148 "23, he would have to roll a 2, anything else would be used for",
149 "another man, or for another purpose. However, there is one ex-",
150 "ception. If the player rolling has no men far enough to move the",
151 "roll made, he may move his farthest man off the board. For exam-",
152 "ple, if red's farthest man back was on position 21, he could re-",
153 "move men from that position if he rolled a 5 or a 6, as well as a",
154 "4. Since he does not have men on 20 (where he could use a 5) or",
155 "on 19 (where he could use a 6), he can use these rolls for posi-",
156 "tion 21. A player never has to remove men, but he must make as",
157 "many moves as possible.",
161 const char *const hits[] = {
162 "\nHitting Blots:",
163 "\n Although two men on a position form an impenetrable point, a",
164 "lone man is not so secure. Such a man is called a 'blot' and has",
165 "the potential of getting hit by an opposing man. When a player's",
166 "blot is hit, he is placed on the bar, and the first thing that",
167 "player must do is move the man off the bar. Such moves are",
168 "counted as if the bar is one position behind the first position",
169 "on the board. Thus if red has a man on the bar and rolls 2 3, he",
170 "must move the man on the bar to position 2 or 3 before moving any",
171 "other man. If white had points on positions 2 and 3, then red",
172 "would forfeit his turn. Being on the bar is a very bad position,",
173 "for often a player can lose many turns trying to move off the",
174 "bar, as well as being set back the full distance of the board.",
178 const char *const endgame[] = {
179 "\nEnding the Game and Scoring:",
180 "\n Winning a game usually wins one point, the normal value of a",
181 "game. However, if the losing player has not removed any men yet,",
182 "then the winning player wins double the game value, called a",
183 "'gammon.' If the losing player has a player on the bar or on the",
184 "winner's inner table, then the winner gets triple the game value,",
185 "which is called a 'backgammon.' (So that's where the name comes",
186 "from!)",