X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/a853ec0c0184e284cec20544b4f2c0b36ca875e6..3c3f8c0880fed372a83ed917c866247edb974156:/gomoku/makemove.c diff --git a/gomoku/makemove.c b/gomoku/makemove.c index c1be646e..28ad355a 100644 --- a/gomoku/makemove.c +++ b/gomoku/makemove.c @@ -1,4 +1,4 @@ -/* $NetBSD: makemove.c,v 1.3 1997/01/03 01:35:29 cgd Exp $ */ +/* $NetBSD: makemove.c,v 1.11 2009/08/12 06:19:17 dholland Exp $ */ /* * Copyright (c) 1994 @@ -15,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,40 +32,43 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)makemove.c 8.2 (Berkeley) 5/3/95"; #else -static char rcsid[] = "$NetBSD: makemove.c,v 1.3 1997/01/03 01:35:29 cgd Exp $"; +__RCSID("$NetBSD: makemove.c,v 1.11 2009/08/12 06:19:17 dholland Exp $"); #endif #endif /* not lint */ #include "gomoku.h" /* direction deltas */ -int dd[4] = { +const int dd[4] = { MRIGHT, MRIGHT+MDOWN, MDOWN, MDOWN+MLEFT }; -int weight[5] = { 0, 1, 7, 22, 100 }; +static const int weight[5] = { 0, 1, 7, 22, 100 }; + +static void update_overlap(struct spotstr *); /* * Return values: * MOVEOK everything is OK. * RESIGN Player resigned. * ILLEGAL Illegal move. - * WIN The the winning move was just played. + * WIN The winning move was just played. * TIE The game is a tie. */ -makemove(us, mv) - int us, mv; +int +makemove(int us, int mv) { - register struct spotstr *sp, *fsp; - register union comboval *cp; + struct spotstr *sp, *fsp; + union comboval *cp; struct spotstr *osp; struct combostr *cbp, *cbp1; union comboval *cp1; - register int i, f, r, d, n; + int i, f, r, d, n; int space, val, bmask; /* check for end of game */ @@ -97,7 +96,7 @@ makemove(us, mv) for (f = 5; --f >= 0; fsp -= d) { /* for each frame */ if (fsp->s_occ == BORDER) goto nextr; - if (fsp->s_flg & bmask) + if (fsp->s_flags & bmask) continue; /* remove this frame from the sorted list of frames */ @@ -132,7 +131,7 @@ makemove(us, mv) sp->s_wval -= val; else { /* this frame is now blocked, adjust values */ - fsp->s_flg |= bmask; + fsp->s_flags |= bmask; fsp->s_fval[BLACK][r].s = MAXCOMBO; fsp->s_fval[WHITE][r].s = MAXCOMBO; while (--i >= 0) { @@ -218,15 +217,16 @@ makemove(us, mv) /* * fix up the overlap array due to updating spot osp. */ -update_overlap(osp) - struct spotstr *osp; +static void +update_overlap(struct spotstr *osp) { - register struct spotstr *sp, *sp1, *sp2; - register int i, f, r, r1, d, d1, n; + struct spotstr *sp, *sp1, *sp2; + int i, f, r, r1, d, d1, n; int a, b, bmask, bmask1; struct spotstr *esp; - char *str; + u_char *str; + esp = NULL; for (r = 4; --r >= 0; ) { /* for each direction */ d = dd[r]; sp1 = osp; @@ -234,7 +234,7 @@ update_overlap(osp) for (f = 0; f < 6; f++, sp1 -= d) { /* for each frame */ if (sp1->s_occ == BORDER) break; - if (sp1->s_flg & bmask) + if (sp1->s_flags & bmask) continue; /* * Update all other frames that intersect the current one @@ -248,7 +248,7 @@ update_overlap(osp) for (i = f + 1; i < 6; i++, sp2 -= d) { if (sp2->s_occ == BORDER) break; - if (sp2->s_flg & bmask) + if (sp2->s_flags & bmask) continue; /* * count the number of empty spots to see if there is @@ -295,7 +295,7 @@ update_overlap(osp) for (i = 6; --i >= 0; sp -= d1) { /* for each spot */ if (sp->s_occ == BORDER) break; - if (sp->s_flg & bmask1) + if (sp->s_flags & bmask1) continue; b = sp->s_frame[r1] - frames; str[b] = 0;