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