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