Use getopt instead of hand-rolled options code. Document all the arguments and options. Don't allow the previously undocumented method to change the maximum number of scores kept per user to be used on the system-wide high score file. Sort options list in the man page. Bump its date.diff -r1.29 -r1.30 src/games/robots/main.c
(dholland)
--- src/games/robots/main.c 2009/07/20 06:43:18 1.29
+++ src/games/robots/main.c 2009/08/05 04:03:47 1.30
@@ -1,237 +1,235 @@ | @@ -1,237 +1,235 @@ | |||
1 | /* $NetBSD: main.c,v 1.29 2009/07/20 06:43:18 dholland Exp $ */ | 1 | /* $NetBSD: main.c,v 1.30 2009/08/05 04:03:47 dholland Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1980, 1993 | 4 | * Copyright (c) 1980, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
15 | * 3. Neither the name of the University nor the names of its contributors | 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 | 16 | * may be used to endorse or promote products derived from this software | |
17 | * without specific prior written permission. | 17 | * without specific prior written permission. | |
18 | * | 18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 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 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 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 | 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 | 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 | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #ifndef lint | 33 | #ifndef lint | |
34 | __COPYRIGHT("@(#) Copyright (c) 1980, 1993\ | 34 | __COPYRIGHT("@(#) Copyright (c) 1980, 1993\ | |
35 | The Regents of the University of California. All rights reserved."); | 35 | The Regents of the University of California. All rights reserved."); | |
36 | #endif /* not lint */ | 36 | #endif /* not lint */ | |
37 | 37 | |||
38 | #ifndef lint | 38 | #ifndef lint | |
39 | #if 0 | 39 | #if 0 | |
40 | static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; | 40 | static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; | |
41 | #else | 41 | #else | |
42 | __RCSID("$NetBSD: main.c,v 1.29 2009/07/20 06:43:18 dholland Exp $"); | 42 | __RCSID("$NetBSD: main.c,v 1.30 2009/08/05 04:03:47 dholland Exp $"); | |
43 | #endif | 43 | #endif | |
44 | #endif /* not lint */ | 44 | #endif /* not lint */ | |
45 | 45 | |||
46 | #include <ctype.h> | 46 | #include <ctype.h> | |
47 | #include <curses.h> | 47 | #include <curses.h> | |
48 | #include <err.h> | 48 | #include <err.h> | |
49 | #include <errno.h> | 49 | #include <errno.h> | |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> | |
51 | #include <signal.h> | 51 | #include <signal.h> | |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> | |
53 | #include <time.h> | 53 | #include <time.h> | |
54 | #include <unistd.h> | 54 | #include <unistd.h> | |
55 | #include "robots.h" | 55 | #include "robots.h" | |
56 | 56 | |||
57 | extern const char *Scorefile; | 57 | extern const char *Scorefile; | |
58 | extern int Max_per_uid; | 58 | extern int Max_per_uid; | |
59 | 59 | |||
60 | int | 60 | int | |
61 | main(int ac, char **av) | 61 | main(int argc, char **argv) | |
62 | { | 62 | { | |
63 | const char *sp; | 63 | const char *word; | |
64 | bool bad_arg; | |||
65 | bool show_only; | 64 | bool show_only; | |
66 | int score_wfd; /* high score writable file descriptor */ | 65 | int score_wfd; /* high score writable file descriptor */ | |
67 | int score_err = 0; /* hold errno from score file open */ | 66 | int score_err = 0; /* hold errno from score file open */ | |
67 | int maximum = 0; | |||
68 | char ch; | |||
69 | int i; | |||
68 | 70 | |||
69 | score_wfd = open(Scorefile, O_RDWR); | 71 | score_wfd = open(Scorefile, O_RDWR); | |
70 | if (score_wfd < 0) | 72 | if (score_wfd < 0) | |
71 | score_err = errno; | 73 | score_err = errno; | |
72 | else if (score_wfd < 3) | 74 | else if (score_wfd < 3) | |
73 | exit(1); | 75 | exit(1); | |
74 | 76 | |||
75 | /* Revoke setgid privileges */ | 77 | /* Revoke setgid privileges */ | |
76 | setgid(getgid()); | 78 | setgid(getgid()); | |
77 | 79 | |||
78 | show_only = false; | 80 | show_only = false; | |
79 | Num_games = 1; | 81 | Num_games = 1; | |
80 | if (ac > 1) { | 82 | ||
81 | bad_arg = false; | 83 | while ((ch = getopt(argc, argv, "Aajnrst")) != -1) { | |
82 | for (++av; ac > 1 && *av[0]; av++, ac--) | 84 | switch (ch) { | |
83 | if (av[0][0] != '-') | 85 | case 'A': | |
84 | if (isdigit((unsigned char)av[0][0])) | 86 | Auto_bot = true; | |
85 | Max_per_uid = atoi(av[0]); | 87 | break; | |
86 | else { | 88 | case 'a': | |
87 | Scorefile = av[0]; | 89 | Start_level = 4; | |
88 | if (score_wfd >= 0) | 90 | break; | |
89 | close(score_wfd); | 91 | case 'j': | |
90 | score_wfd = open(Scorefile, O_RDWR); | 92 | Jump = true; | |
91 | if (score_wfd < 0) | 93 | break; | |
92 | score_err = errno; | 94 | case 'n': | |
95 | Num_games++; | |||
96 | break; | |||
97 | case 'r': | |||
98 | Real_time = true; | |||
99 | break; | |||
100 | case 's': | |||
101 | show_only = true; | |||
102 | break; | |||
103 | case 't': | |||
104 | Teleport = true; | |||
105 | break; | |||
106 | default: | |||
107 | errx(1, | |||
108 | "Usage: robots [-Aajnrst] [maximum] [scorefile]"); | |||
109 | break; | |||
110 | } | |||
111 | } | |||
112 | ||||
113 | for (i = optind; i < argc; i++) { | |||
114 | word = argv[i]; | |||
115 | if (isdigit((unsigned char)word[0])) { | |||
116 | maximum = atoi(word); | |||
117 | } else { | |||
118 | Scorefile = word; | |||
119 | Max_per_uid = maximum; | |||
120 | if (score_wfd >= 0) | |||
121 | close(score_wfd); | |||
122 | score_wfd = open(Scorefile, O_RDWR); | |||
123 | if (score_wfd < 0) | |||
124 | score_err = errno; | |||
93 | #ifdef FANCY | 125 | #ifdef FANCY | |
94 | sp = strrchr(Scorefile, '/'); | 126 | word = strrchr(Scorefile, '/'); | |
95 | if (sp == NULL) | 127 | if (word == NULL) | |
96 | sp = Scorefile; | 128 | word = Scorefile; | |
97 | if (strcmp(sp, "pattern_roll") == 0) | 129 | if (strcmp(word, "pattern_roll") == 0) | |
98 | Pattern_roll = true; | 130 | Pattern_roll = true; | |
99 | else if (strcmp(sp, "stand_still") == 0) | 131 | else if (strcmp(word, "stand_still") == 0) | |
100 | Stand_still = true; | 132 | Stand_still = true; | |
101 | if (Pattern_roll || Stand_still) | 133 | if (Pattern_roll || Stand_still) | |
102 | Teleport = true; | 134 | Teleport = true; | |
103 | #endif | 135 | #endif | |
104 | } | |||
105 | else | |||
106 | for (sp = &av[0][1]; *sp; sp++) | |||
107 | switch (*sp) { | |||
108 | case 'A': | |||
109 | Auto_bot = true; | |||
110 | break; | |||
111 | case 's': | |||
112 | show_only = true; | |||
113 | break; | |||
114 | case 'r': | |||
115 | Real_time = true; | |||
116 | break; | |||
117 | case 'a': | |||
118 | Start_level = 4; | |||
119 | break; | |||
120 | case 'n': | |||
121 | Num_games++; | |||
122 | break; | |||
123 | case 'j': | |||
124 | Jump = true; | |||
125 | break; | |||
126 | case 't': | |||
127 | Teleport = true; | |||
128 | break; | |||
129 | ||||
130 | default: | |||
131 | fprintf(stderr, "robots: unknown option: %c\n", *sp); | |||
132 | bad_arg = true; | |||
133 | break; | |||
134 | } | |||
135 | if (bad_arg) { | |||
136 | exit(1); | |||
137 | /* NOTREACHED */ | |||
138 | } | 136 | } | |
139 | } | 137 | } | |
140 | 138 | |||
141 | if (show_only) { | 139 | if (show_only) { | |
142 | show_score(); | 140 | show_score(); | |
143 | exit(0); | 141 | exit(0); | |
144 | /* NOTREACHED */ | 142 | /* NOTREACHED */ | |
145 | } | 143 | } | |
146 | 144 | |||
147 | if (score_wfd < 0) { | 145 | if (score_wfd < 0) { | |
148 | errno = score_err; | 146 | errno = score_err; | |
149 | warn("%s", Scorefile); | 147 | warn("%s", Scorefile); | |
150 | warnx("High scores will not be recorded!"); | 148 | warnx("High scores will not be recorded!"); | |
151 | sleep(2); | 149 | sleep(2); | |
152 | } | 150 | } | |
153 | 151 | |||
154 | if (!initscr()) | 152 | if (!initscr()) | |
155 | errx(0, "couldn't initialize screen"); | 153 | errx(0, "couldn't initialize screen"); | |
156 | signal(SIGINT, quit); | 154 | signal(SIGINT, quit); | |
157 | cbreak(); | 155 | cbreak(); | |
158 | noecho(); | 156 | noecho(); | |
159 | nonl(); | 157 | nonl(); | |
160 | if (LINES != Y_SIZE || COLS != X_SIZE) { | 158 | if (LINES != Y_SIZE || COLS != X_SIZE) { | |
161 | if (LINES < Y_SIZE || COLS < X_SIZE) { | 159 | if (LINES < Y_SIZE || COLS < X_SIZE) { | |
162 | endwin(); | 160 | endwin(); | |
163 | printf("Need at least a %dx%d screen\n", | 161 | printf("Need at least a %dx%d screen\n", | |
164 | Y_SIZE, X_SIZE); | 162 | Y_SIZE, X_SIZE); | |
165 | exit(1); | 163 | exit(1); | |
166 | } | 164 | } | |
167 | delwin(stdscr); | 165 | delwin(stdscr); | |
168 | stdscr = newwin(Y_SIZE, X_SIZE, 0, 0); | 166 | stdscr = newwin(Y_SIZE, X_SIZE, 0, 0); | |
169 | } | 167 | } | |
170 | 168 | |||
171 | srandom(time(NULL)); | 169 | srandom(time(NULL)); | |
172 | if (Real_time) | 170 | if (Real_time) | |
173 | signal(SIGALRM, move_robots); | 171 | signal(SIGALRM, move_robots); | |
174 | do { | 172 | do { | |
175 | while (Num_games--) { | 173 | while (Num_games--) { | |
176 | init_field(); | 174 | init_field(); | |
177 | for (Level = Start_level; !Dead; Level++) { | 175 | for (Level = Start_level; !Dead; Level++) { | |
178 | make_level(); | 176 | make_level(); | |
179 | play_level(); | 177 | play_level(); | |
180 | if (Auto_bot) | 178 | if (Auto_bot) | |
181 | sleep(1); | 179 | sleep(1); | |
182 | } | 180 | } | |
183 | move(My_pos.y, My_pos.x); | 181 | move(My_pos.y, My_pos.x); | |
184 | printw("AARRrrgghhhh...."); | 182 | printw("AARRrrgghhhh...."); | |
185 | refresh(); | 183 | refresh(); | |
186 | if (Auto_bot) | 184 | if (Auto_bot) | |
187 | sleep(1); | 185 | sleep(1); | |
188 | score(score_wfd); | 186 | score(score_wfd); | |
189 | if (Auto_bot) | 187 | if (Auto_bot) | |
190 | sleep(1); | 188 | sleep(1); | |
191 | refresh(); | 189 | refresh(); | |
192 | } | 190 | } | |
193 | Num_games = 1; | 191 | Num_games = 1; | |
194 | } while (!Auto_bot && another()); | 192 | } while (!Auto_bot && another()); | |
195 | quit(0); | 193 | quit(0); | |
196 | /* NOTREACHED */ | 194 | /* NOTREACHED */ | |
197 | return(0); | 195 | return(0); | |
198 | } | 196 | } | |
199 | 197 | |||
200 | /* | 198 | /* | |
201 | * quit: | 199 | * quit: | |
202 | * Leave the program elegantly. | 200 | * Leave the program elegantly. | |
203 | */ | 201 | */ | |
204 | void | 202 | void | |
205 | quit(int dummy __unused) | 203 | quit(int dummy __unused) | |
206 | { | 204 | { | |
207 | endwin(); | 205 | endwin(); | |
208 | exit(0); | 206 | exit(0); | |
209 | /* NOTREACHED */ | 207 | /* NOTREACHED */ | |
210 | } | 208 | } | |
211 | 209 | |||
212 | /* | 210 | /* | |
213 | * another: | 211 | * another: | |
214 | * See if another game is desired | 212 | * See if another game is desired | |
215 | */ | 213 | */ | |
216 | bool | 214 | bool | |
217 | another(void) | 215 | another(void) | |
218 | { | 216 | { | |
219 | int y; | 217 | int y; | |
220 | 218 | |||
221 | #ifdef FANCY | 219 | #ifdef FANCY | |
222 | if ((Stand_still || Pattern_roll) && !Newscore) | 220 | if ((Stand_still || Pattern_roll) && !Newscore) | |
223 | return true; | 221 | return true; | |
224 | #endif | 222 | #endif | |
225 | 223 | |||
226 | if (query("Another game?")) { | 224 | if (query("Another game?")) { | |
227 | if (Full_clear) { | 225 | if (Full_clear) { | |
228 | for (y = 1; y <= Num_scores; y++) { | 226 | for (y = 1; y <= Num_scores; y++) { | |
229 | move(y, 1); | 227 | move(y, 1); | |
230 | clrtoeol(); | 228 | clrtoeol(); | |
231 | } | 229 | } | |
232 | refresh(); | 230 | refresh(); | |
233 | } | 231 | } | |
234 | return true; | 232 | return true; | |
235 | } | 233 | } | |
236 | return false; | 234 | return false; | |
237 | } | 235 | } |
--- src/games/robots/robots.6 2009/04/09 03:52:54 1.14
+++ src/games/robots/robots.6 2009/08/05 04:03:47 1.15
@@ -1,156 +1,169 @@ | @@ -1,156 +1,169 @@ | |||
1 | .\" $NetBSD: robots.6,v 1.14 2009/04/09 03:52:54 joerg Exp $ | 1 | .\" $NetBSD: robots.6,v 1.15 2009/08/05 04:03:47 dholland Exp $ | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 1991, 1993 | 3 | .\" Copyright (c) 1991, 1993 | |
4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | 6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | 7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | 8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | 9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | 10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | 12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | 13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. Neither the name of the University nor the names of its contributors | 14 | .\" 3. Neither the name of the University nor the names of its contributors | |
15 | .\" may be used to endorse or promote products derived from this software | 15 | .\" may be used to endorse or promote products derived from this software | |
16 | .\" without specific prior written permission. | 16 | .\" without specific prior written permission. | |
17 | .\" | 17 | .\" | |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 | .\" SUCH DAMAGE. | 28 | .\" SUCH DAMAGE. | |
29 | .\" | 29 | .\" | |
30 | .\" @(#)robots.6 8.1 (Berkeley) 5/31/93 | 30 | .\" @(#)robots.6 8.1 (Berkeley) 5/31/93 | |
31 | .\" | 31 | .\" | |
32 | .Dd May 31, 1993 | 32 | .Dd August 4, 2009 | |
33 | .Dt ROBOTS 6 | 33 | .Dt ROBOTS 6 | |
34 | .Os | 34 | .Os | |
35 | .Sh NAME | 35 | .Sh NAME | |
36 | .Nm robots | 36 | .Nm robots | |
37 | .Nd fight off villainous robots | 37 | .Nd fight off villainous robots | |
38 | .Sh SYNOPSIS | 38 | .Sh SYNOPSIS | |
39 | .Nm | 39 | .Nm | |
40 | .Op Fl Asjtan | 40 | .Op Fl Aajnrst | |
41 | .Op Ar maximum | |||
41 | .Op Ar scorefile | 42 | .Op Ar scorefile | |
42 | .Sh DESCRIPTION | 43 | .Sh DESCRIPTION | |
43 | .Nm | 44 | .Nm | |
44 | pits you against evil robots, who are trying to kill you (which is why | 45 | pits you against evil robots, who are trying to kill you (which is why | |
45 | they are evil). | 46 | they are evil). | |
46 | Fortunately for you, even though they are evil, they are not very bright | 47 | Fortunately for you, even though they are evil, they are not very bright | |
47 | and have a habit of bumping into each other, thus destroying themselves. | 48 | and have a habit of bumping into each other, thus destroying themselves. | |
48 | In order to survive, you must get them to kill each other off, since you | 49 | In order to survive, you must get them to kill each other off, since you | |
49 | have no offensive weaponry. | 50 | have no offensive weaponry. | |
50 | .Pp | 51 | .Pp | |
51 | Since you are stuck without offensive weaponry, you are endowed with one | 52 | Since you are stuck without offensive weaponry, you are endowed with one | |
52 | piece of defensive weaponry: a teleportation device. | 53 | piece of defensive weaponry: a teleportation device. | |
53 | When two robots run into each other or a junk pile, they die. | 54 | When two robots run into each other or a junk pile, they die. | |
54 | If a robot runs into you, you die. | 55 | If a robot runs into you, you die. | |
55 | When a robot dies, you get 10 points, and when all the robots die, | 56 | When a robot dies, you get 10 points, and when all the robots die, | |
56 | you start on the next field. | 57 | you start on the next field. | |
57 | This keeps up until they finally get you. | 58 | This keeps up until they finally get you. | |
58 | .Pp | 59 | .Pp | |
59 | Robots are represented on the screen by a | 60 | Robots are represented on the screen by a | |
60 | .Sq \&+ , | 61 | .Sq \&+ , | |
61 | the junk heaps from their collisions by a | 62 | the junk heaps from their collisions by a | |
62 | .Sq \(** , | 63 | .Sq \(** , | |
63 | and you | 64 | and you | |
64 | (the good guy) | 65 | (the good guy) | |
65 | by a | 66 | by a | |
66 | .Sq @ . | 67 | .Sq @ . | |
67 | .Pp | 68 | .Pp | |
68 | The commands are: | 69 | The commands are: | |
69 | .Bl -tag -width indent -compact | 70 | .Bl -tag -width indent -compact | |
70 | .It Ic h | 71 | .It Ic h | |
71 | move one square left | 72 | move one square left | |
72 | .It Ic l | 73 | .It Ic l | |
73 | move one square right | 74 | move one square right | |
74 | .It Ic k | 75 | .It Ic k | |
75 | move one square up | 76 | move one square up | |
76 | .It Ic j | 77 | .It Ic j | |
77 | move one square down | 78 | move one square down | |
78 | .It Ic y | 79 | .It Ic y | |
79 | move one square up and left | 80 | move one square up and left | |
80 | .It Ic u | 81 | .It Ic u | |
81 | move one square up and right | 82 | move one square up and right | |
82 | .It Ic b | 83 | .It Ic b | |
83 | move one square down and left | 84 | move one square down and left | |
84 | .It Ic n | 85 | .It Ic n | |
85 | move one square down and right | 86 | move one square down and right | |
86 | .It Ic \&. | 87 | .It Ic \&. | |
87 | (also space) do nothing for one turn | 88 | (also space) do nothing for one turn | |
88 | .It Ic HJKLBNYU | 89 | .It Ic HJKLBNYU | |
89 | run as far as possible in the given direction | 90 | run as far as possible in the given direction | |
90 | .It Ic \*[Gt] | 91 | .It Ic \*[Gt] | |
91 | do nothing for as long as possible | 92 | do nothing for as long as possible | |
92 | .It Ic t | 93 | .It Ic t | |
93 | teleport to a random location | 94 | teleport to a random location | |
94 | .It Ic w | 95 | .It Ic w | |
95 | wait until you die or they all do | 96 | wait until you die or they all do | |
96 | .It Ic q | 97 | .It Ic q | |
97 | quit | 98 | quit | |
98 | .It Ic ^L | 99 | .It Ic ^L | |
99 | redraw the screen | 100 | redraw the screen | |
100 | .El | 101 | .El | |
101 | .Pp | 102 | .Pp | |
102 | All commands can be preceded by a count. | 103 | All commands can be preceded by a count. | |
103 | .Pp | 104 | .Pp | |
104 | If you use the | 105 | If you use the | |
105 | .Sq Ic w | 106 | .Sq Ic w | |
106 | command and survive to the next level, you will get a bonus of 10% | 107 | command and survive to the next level, you will get a bonus of 10% | |
107 | for each robot which died after you decided to wait. | 108 | for each robot which died after you decided to wait. | |
108 | If you die, however, you get nothing. | 109 | If you die, however, you get nothing. | |
109 | For all other commands, the program will save you from typos | 110 | For all other commands, the program will save you from typos | |
110 | by stopping short of being eaten. | 111 | by stopping short of being eaten. | |
111 | However, with | 112 | However, with | |
112 | .Sq Ic w | 113 | .Sq Ic w | |
113 | you take the risk of dying by miscalculation. | 114 | you take the risk of dying by miscalculation. | |
114 | .Pp | 115 | .Pp | |
115 | Only five scores are allowed per user on the score file. | 116 | Only five scores are allowed per user on the score file. | |
116 | If you make it into the score file, you will be shown the list at the end | 117 | If you make it into the score file, you will be shown the list at the end | |
117 | of the game. | 118 | of the game. | |
118 | If an alternative score file is specified, that will be used instead of the | 119 | If an alternative score file is named on the command line, that file | |
119 | standard file for scores. | 120 | will be used instead of the standard file for scores. | |
121 | The score file must be created empty beforehand, e.g. with | |||
122 | .Xr touch 1 . | |||
123 | If the argument | |||
124 | .Ar maximum , | |||
125 | which must be a number, is provided when a score file is first used, | |||
126 | the value given will be used as the maximum number of scores to keep | |||
127 | per user instead of the default five. | |||
128 | This value is a property of the score file and cannot be changed later. | |||
120 | .Pp | 129 | .Pp | |
121 | The options are | 130 | The options are | |
122 | .Bl -tag -width indent | 131 | .Bl -tag -width indent | |
123 | .It Fl s | 132 | .It Fl A | |
124 | Don't play, just show the score file. | 133 | Auto-bot mode. | |
134 | Lets the game play itself. | |||
135 | .It Fl a | |||
136 | Advance into the higher levels directly, skipping the lower, easier levels. | |||
125 | .It Fl j | 137 | .It Fl j | |
126 | Jump, | 138 | Jump, | |
127 | .Em i.e. , | 139 | .Em i.e. , | |
128 | when you run, don't show any intermediate positions; only show things at | 140 | when you run, don't show any intermediate positions; only show things at | |
129 | the end. | 141 | the end. | |
130 | This is useful on slow terminals. | 142 | This is useful on slow terminals. | |
143 | .It Fl n | |||
144 | Increase the number of games played by one; that is, automatically | |||
145 | choose to play again one time per usage of this option. | |||
146 | .It Fl r | |||
147 | Play in real time; that is, if you do nothing for a few seconds the | |||
148 | game will assume you meant to do nothing and move the robots. | |||
149 | .It Fl s | |||
150 | Don't play, just show the score file. | |||
131 | .It Fl t | 151 | .It Fl t | |
132 | Teleport automatically when you have no other option. | 152 | Teleport automatically when you have no other option. | |
133 | This is a little disconcerting until you get used to it, and then it is | 153 | This is a little disconcerting until you get used to it, and then it is | |
134 | very nice. | 154 | very nice. | |
135 | .It Fl a | |||
136 | Advance into the higher levels directly, skipping the lower, easier levels. | |||
137 | .It Fl A | |||
138 | Auto-bot mode. | |||
139 | Lets the game play itself. | |||
140 | .It Fl n | |||
141 | Increase the number of games played by one. | |||
142 | .El | 155 | .El | |
143 | .Sh FILES | 156 | .Sh FILES | |
144 | .Bl -tag -width /var/games/robots_roll -compact | 157 | .Bl -tag -width /var/games/robots_roll -compact | |
145 | .It Pa /var/games/robots_roll | 158 | .It Pa /var/games/robots_roll | |
146 | the score file | 159 | The score file. | |
147 | .El | 160 | .El | |
148 | .Sh AUTHORS | 161 | .Sh AUTHORS | |
149 | .An Ken Arnold | 162 | .An Ken Arnold | |
150 | .An Christos Zoulas | 163 | .An Christos Zoulas | |
151 | (autobot mode) | 164 | (autobot mode) | |
152 | .Sh BUGS | 165 | .Sh BUGS | |
153 | Bugs? | 166 | Bugs? | |
154 | You | 167 | You | |
155 | .Em crazy , | 168 | .Em crazy , | |
156 | man?!? | 169 | man?!? |