diff options
author | lukem <lukem@NetBSD.org> | 1997-10-10 13:36:01 +0000 |
---|---|---|
committer | lukem <lukem@NetBSD.org> | 1997-10-10 13:36:01 +0000 |
commit | 3936117409cf27503dff2c5d4d2ba20840a85873 (patch) | |
tree | 36799758f37408f4211a1a72c734889dc0eac7fe /gomoku/pickmove.c | |
parent | 34ef7ac7fd8bd4c426cd292ac4eb658d67867eab (diff) | |
download | bsdgames-darwin-3936117409cf27503dff2c5d4d2ba20840a85873.tar.gz bsdgames-darwin-3936117409cf27503dff2c5d4d2ba20840a85873.tar.zst bsdgames-darwin-3936117409cf27503dff2c5d4d2ba20840a85873.zip |
WARNSify
Diffstat (limited to 'gomoku/pickmove.c')
-rw-r--r-- | gomoku/pickmove.c | 101 |
1 files changed, 60 insertions, 41 deletions
diff --git a/gomoku/pickmove.c b/gomoku/pickmove.c index 925e5ef2..4a762927 100644 --- a/gomoku/pickmove.c +++ b/gomoku/pickmove.c @@ -1,4 +1,4 @@ -/* $NetBSD: pickmove.c,v 1.4 1997/01/03 01:35:30 cgd Exp $ */ +/* $NetBSD: pickmove.c,v 1.5 1997/10/10 13:36:06 lukem Exp $ */ /* * Copyright (c) 1994 @@ -36,15 +36,15 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)pickmove.c 8.2 (Berkeley) 5/3/95"; #else -static char rcsid[] = "$NetBSD: pickmove.c,v 1.4 1997/01/03 01:35:30 cgd Exp $"; +__RCSID("$NetBSD: pickmove.c,v 1.5 1997/10/10 13:36:06 lukem Exp $"); #endif #endif /* not lint */ -#include <stdio.h> #include <stdlib.h> #include <string.h> #include <curses.h> @@ -69,13 +69,13 @@ int forcemap[MAPSZ]; /* map for blocking <1,x> combos */ int tmpmap[MAPSZ]; /* map for blocking <1,x> combos */ int nforce; /* count of opponent <1,x> combos */ +int pickmove(us) int us; { - register struct spotstr *sp, *sp1, *sp2; - register union comboval *Ocp, *Tcp; - char *str; - int i, j, m; + struct spotstr *sp, *sp1, *sp2; + union comboval *Ocp, *Tcp; + int m; /* first move is easy */ if (movenum == 1) @@ -122,14 +122,14 @@ pickmove(us) } if (debug) { - sprintf(fmtbuf, "B %s %x/%d %d %x/%d %d %d %d", + sprintf(fmtbuf, "B %s %x/%d %d %x/%d %d %d", stoc(sp1 - board), sp1->s_combo[BLACK].s, sp1->s_level[BLACK], sp1->s_nforce[BLACK], sp1->s_combo[WHITE].s, sp1->s_level[WHITE], sp1->s_nforce[WHITE], sp1->s_wval); dlog(fmtbuf); - sprintf(fmtbuf, "W %s %x/%d %d %x/%d %d %d %d", + sprintf(fmtbuf, "W %s %x/%d %d %x/%d %d %d", stoc(sp2 - board), sp2->s_combo[WHITE].s, sp2->s_level[WHITE], sp2->s_nforce[WHITE], @@ -169,6 +169,7 @@ pickmove(us) /* * Return true if spot 'sp' is better than spot 'sp1' for color 'us'. */ +int better(sp, sp1, us) struct spotstr *sp; struct spotstr *sp1; @@ -229,14 +230,15 @@ int curlevel; /* implicit parameter to makecombo() */ * update the minimum combo values for each empty spot. * Also, try to combine frames to find more complex (chained) moves. */ +void scanframes(color) int color; { - register struct combostr *cbp, *ecbp; - register struct spotstr *sp; - register union comboval *cp; - register struct elist *ep, *nep; - register int i, r, d, n; + struct combostr *cbp, *ecbp; + struct spotstr *sp; + union comboval *cp; + struct elist *ep, *nep; + int i, r, d, n; union comboval cb; curcolor = color; @@ -413,15 +415,16 @@ scanframes(color) * Compute all level 2 combos of frames intersecting spot 'osp' * within the frame 'ocbp' and combo value 's'. */ +void makecombo2(ocbp, osp, off, s) struct combostr *ocbp; struct spotstr *osp; int off; int s; { - register struct spotstr *sp, *fsp; - register struct combostr *ncbp; - register int f, r, d, c; + struct spotstr *fsp; + struct combostr *ncbp; + int f, r, d, c; int baseB, fcnt, emask, bmask, n; union comboval ocb, fcb; struct combostr **scbpp, *fcbp; @@ -460,7 +463,7 @@ makecombo2(ocbp, osp, off, s) * If this is the end point of the frame, * use the closed ended value for the frame. */ - if (f == 0 && fcb.c.b || fcb.s == 0x101) { + if ((f == 0 && fcb.c.b) || fcb.s == 0x101) { fcb.c.a++; fcb.c.b = 0; } @@ -507,7 +510,7 @@ makecombo2(ocbp, osp, off, s) ((fcb.c.b ? 0x1E : 0x1F) & ~(1 << f)) : 0; combocnt++; - if (c == 1 && debug > 1 || debug > 3) { + if ((c == 1 && debug > 1) || debug > 3) { sprintf(fmtbuf, "%c c %d %d m %x %x o %d %d", "bw"[curcolor], ncbp->c_framecnt[0], ncbp->c_framecnt[1], @@ -544,13 +547,14 @@ makecombo2(ocbp, osp, off, s) * Scan the sorted list of frames and try to add a frame to * combinations of 'level' number of frames. */ +void addframes(level) int level; { - register struct combostr *cbp, *ecbp; - register struct spotstr *sp, *fsp; - register struct elist *ep, *nep; - register int i, r, d; + struct combostr *cbp, *ecbp; + struct spotstr *sp, *fsp; + struct elist *ep, *nep; + int i, r, d; struct combostr **cbpp, *pcbp; union comboval fcb, cb; @@ -644,20 +648,21 @@ addframes(level) * Compute all level N combos of frames intersecting spot 'osp' * within the frame 'ocbp' and combo value 's'. */ +void makecombo(ocbp, osp, off, s) struct combostr *ocbp; struct spotstr *osp; int off; int s; { - register struct combostr *cbp, *ncbp; - register struct spotstr *sp; - register struct elist *ep; - register int n, c; - struct elist *nep, **epp; + struct combostr *cbp, *ncbp; + struct spotstr *sp; + struct elist *ep; + int n, c; + struct elist *nep; struct combostr **scbpp; - int baseB, fcnt, emask, verts, d; - union comboval ocb, cb; + int baseB, fcnt, emask, verts; + union comboval ocb; struct ovlp_info vertices[1]; ocb.s = s; @@ -755,7 +760,7 @@ makecombo(ocbp, osp, off, s) ncbp->c_voff[0] = ep->e_off; } - if (c == 1 && debug > 1 || debug > 3) { + if ((c == 1 && debug > 1) || debug > 3) { sprintf(fmtbuf, "%c v%d i%d d%d c %d %d m %x %x o %d %d", "bw"[curcolor], verts, ncbp->c_frameindex, ncbp->c_dir, ncbp->c_framecnt[0], ncbp->c_framecnt[1], @@ -792,11 +797,12 @@ struct combostr *ecombo[MAXDEPTH]; /* separate from elist to save space */ * Add the combostr 'ocbp' to the empty spots list for each empty spot * in 'ocbp' that will complete the combo. */ +void makeempty(ocbp) struct combostr *ocbp; { struct combostr *cbp, *tcbp, **cbpp; - struct elist *ep, *nep, **epp; + struct elist *ep, *nep; struct spotstr *sp; int s, d, m, emask, i; int nframes; @@ -824,7 +830,8 @@ makeempty(ocbp) */ ep = &einfo[nframes]; cbpp = &ecombo[nframes]; - for (cbp = ocbp; tcbp = cbp->c_link[1]; cbp = cbp->c_link[0]) { + for (cbp = ocbp; (tcbp = cbp->c_link[1]) != NULL; + cbp = cbp->c_link[0]) { ep--; ep->e_combo = cbp; *--cbpp = cbp->c_link[1]; @@ -947,17 +954,18 @@ makeempty(ocbp) * We handle things differently depending on whether the next move * would be trying to "complete" the combo or trying to block it. */ +void updatecombo(cbp, color) struct combostr *cbp; int color; { - register struct framestr *fp; - register struct spotstr *sp; - register struct combostr *tcbp; - register int i, d; + struct spotstr *sp; + struct combostr *tcbp; + int i, d; int nframes, flg, s; union comboval cb; + flg = 0; /* save the top level value for the whole combo */ cb.c.a = cbp->c_combo.c.a; nframes = cbp->c_nframes; @@ -965,7 +973,7 @@ updatecombo(cbp, color) if (color != nextcolor) memset(tmpmap, 0, sizeof(tmpmap)); - for (; tcbp = cbp->c_link[1]; cbp = cbp->c_link[0]) { + for (; (tcbp = cbp->c_link[1]) != NULL; cbp = cbp->c_link[0]) { flg = cbp->c_flg; cb.c.b = cbp->c_combo.c.b; if (color == nextcolor) { @@ -1037,6 +1045,7 @@ updatecombo(cbp, color) /* * Add combo to the end of the list. */ +void appendcombo(cbp, color) struct combostr *cbp; int color; @@ -1067,6 +1076,7 @@ appendcombo(cbp, color) * Return -1 if 'fcbp' should not be combined with 'cbp'. * 's' is the combo value for frame 'fcpb'. */ +int checkframes(cbp, fcbp, osp, s, vertices) struct combostr *cbp; struct combostr *fcbp; @@ -1080,6 +1090,9 @@ checkframes(cbp, fcbp, osp, s, vertices) u_char *str; short *ip; + lcbp = NULL; + flg = 0; + cb.s = s; fcnt = cb.c.a - 2; verts = 0; @@ -1093,7 +1106,8 @@ checkframes(cbp, fcbp, osp, s, vertices) * an open or closed frame. */ i = cb.c.b ? 2 : 0; - for (; tcbp = cbp->c_link[1]; lcbp = cbp, cbp = cbp->c_link[0]) { + for (; (tcbp = cbp->c_link[1]) != NULL; + lcbp = cbp, cbp = cbp->c_link[0]) { if (tcbp == fcbp) return (-1); /* fcbp is already included */ @@ -1204,6 +1218,7 @@ checkframes(cbp, fcbp, osp, s, vertices) * Return true if this list of frames is already in the hash list. * Otherwise, add the new combo to the hash list. */ +int sortcombo(scbpp, cbpp, fcbp) struct combostr **scbpp; struct combostr **cbpp; @@ -1317,6 +1332,7 @@ inserted: /* * Print the combo into string 'str'. */ +void printcombo(cbp, str) struct combostr *cbp; char *str; @@ -1325,7 +1341,7 @@ printcombo(cbp, str) sprintf(str, "%x/%d", cbp->c_combo.s, cbp->c_nframes); str += strlen(str); - for (; tcbp = cbp->c_link[1]; cbp = cbp->c_link[0]) { + for (; (tcbp = cbp->c_link[1]) != NULL; cbp = cbp->c_link[0]) { sprintf(str, " %s%c%x", stoc(tcbp->c_vertex), pdir[tcbp->c_dir], cbp->c_flg); str += strlen(str); @@ -1334,6 +1350,7 @@ printcombo(cbp, str) } #ifdef DEBUG +void markcombo(ocbp) struct combostr *ocbp; { @@ -1448,11 +1465,12 @@ markcombo(ocbp) } } +void clearcombo(cbp, open) struct combostr *cbp; int open; { - register struct spotstr *sp; + struct spotstr *sp; struct combostr *tcbp; int d, n, mask; @@ -1468,6 +1486,7 @@ clearcombo(cbp, open) sp->s_flg &= mask; } +int list_eq(scbpp, cbpp, n) struct combostr **scbpp; struct combostr **cbpp; |