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