summaryrefslogtreecommitdiffstats
path: root/backgammon/teachgammon/tutor.c
diff options
context:
space:
mode:
Diffstat (limited to 'backgammon/teachgammon/tutor.c')
-rw-r--r--backgammon/teachgammon/tutor.c83
1 files changed, 41 insertions, 42 deletions
diff --git a/backgammon/teachgammon/tutor.c b/backgammon/teachgammon/tutor.c
index 497191ee..06b4d114 100644
--- a/backgammon/teachgammon/tutor.c
+++ b/backgammon/teachgammon/tutor.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tutor.c,v 1.3 1995/03/21 15:06:27 cgd Exp $ */
+/* $NetBSD: tutor.c,v 1.4 1997/10/10 08:59:54 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,26 +33,24 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: tutor.c,v 1.3 1995/03/21 15:06:27 cgd Exp $";
+__RCSID("$NetBSD: tutor.c,v 1.4 1997/10/10 08:59:54 lukem Exp $");
#endif
-#endif /* not lint */
+#endif /* not lint */
#include "back.h"
#include "tutor.h"
-extern int maxmoves;
-extern char *finis[];
+static char better[] = "That is a legal move, but there is a better one.\n";
-extern struct situatn test[];
-
-static char better[] = "That is a legal move, but there is a better one.\n";
-
-tutor () {
- register int i, j;
+void
+tutor()
+{
+ int i, j;
i = 0;
begscr = 18;
@@ -68,40 +66,39 @@ tutor () {
colen = 5;
wrboard();
- while (1) {
- if (! brdeq(test[i].brd,board)) {
+ while (1) {
+ if (!brdeq(test[i].brd, board)) {
if (tflag && curr == 23)
- curmove (18,0);
- writel (better);
+ curmove(18, 0);
+ writel(better);
nexturn();
- movback (mvlim);
- if (tflag) {
+ movback(mvlim);
+ if (tflag) {
refresh();
- clrest ();
+ clrest();
}
- if ((! tflag) || curr == 19) {
+ if ((!tflag) || curr == 19) {
proll();
- writec ('\t');
- }
- else
- curmove (curr > 19? curr-2: curr+4,25);
+ writec('\t');
+ } else
+ curmove(curr > 19 ? curr - 2 : curr + 4, 25);
getmove();
if (cturn == 0)
leave();
continue;
}
if (tflag)
- curmove (18,0);
- text (*test[i].com);
- if (! tflag)
- writec ('\n');
+ curmove(18, 0);
+ text(*test[i].com);
+ if (!tflag)
+ writec('\n');
if (i == maxmoves)
break;
D0 = test[i].roll1;
D1 = test[i].roll2;
d0 = 0;
mvlim = 0;
- for (j = 0; j < 4; j++) {
+ for (j = 0; j < 4; j++) {
if (test[i].mp[j] == test[i].mg[j])
break;
p[j] = test[i].mp[j];
@@ -111,7 +108,7 @@ tutor () {
if (mvlim)
for (j = 0; j < mvlim; j++)
if (makmove(j))
- writel ("AARGH!!!\n");
+ writel("AARGH!!!\n");
if (tflag)
refresh();
nexturn();
@@ -120,7 +117,7 @@ tutor () {
d0 = 0;
i++;
mvlim = movallow();
- if (mvlim) {
+ if (mvlim) {
if (tflag)
clrest();
proll();
@@ -135,27 +132,29 @@ tutor () {
leave();
}
-clrest () {
- register int r, c, j;
+void
+clrest()
+{
+ int r, c, j;
r = curr;
c = curc;
- for (j = r+1; j < 24; j++) {
- curmove (j,0);
+ for (j = r + 1; j < 24; j++) {
+ curmove(j, 0);
cline();
}
- curmove (r,c);
+ curmove(r, c);
}
-brdeq (b1,b2)
-register int *b1, *b2;
-
+int
+brdeq(b1, b2)
+ int *b1, *b2;
{
- register int *e;
+ int *e;
- e = b1+26;
+ e = b1 + 26;
while (b1 < e)
if (*b1++ != *b2++)
- return(0);
- return(1);
+ return (0);
+ return (1);
}