Module Name: src
Committed By: rillig
Date: Sun May 29 00:38:26 UTC 2022
Modified Files:
src/games/gomoku: bdinit.c gomoku.h main.c makemove.c pickmove.c
Log Message:
gomoku: migrate spot_index from int to unsigned short
This matches the type of 'intersect'.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/games/gomoku/bdinit.c
cvs rdiff -u -r1.47 -r1.48 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.67 -r1.68 src/games/gomoku/main.c
cvs rdiff -u -r1.33 -r1.34 src/games/gomoku/makemove.c
cvs rdiff -u -r1.49 -r1.50 src/games/gomoku/pickmove.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/gomoku/bdinit.c
diff -u src/games/gomoku/bdinit.c:1.28 src/games/gomoku/bdinit.c:1.29
--- src/games/gomoku/bdinit.c:1.28 Sun May 29 00:12:11 2022
+++ src/games/gomoku/bdinit.c Sun May 29 00:38:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: bdinit.c,v 1.28 2022/05/29 00:12:11 rillig Exp $ */
+/* $NetBSD: bdinit.c,v 1.29 2022/05/29 00:38:26 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
/* from: @(#)bdinit.c 8.2 (Berkeley) 5/3/95 */
-__RCSID("$NetBSD: bdinit.c,v 1.28 2022/05/29 00:12:11 rillig Exp $");
+__RCSID("$NetBSD: bdinit.c,v 1.29 2022/05/29 00:38:26 rillig Exp $");
#include <string.h>
#include "gomoku.h"
@@ -248,7 +248,7 @@ init_overlap_frame(int fia, int ra, int
continue;
int fib = (int)(spb0->s_frame[rb] - frames);
- intersect[fia * FAREA + fib] = (short)s;
+ intersect[fia * FAREA + fib] = s;
u_char *op = &overlap[fia * FAREA + fib];
*op = adjust_overlap(*op, ra, sia, rb, sib, mask);
}
Index: src/games/gomoku/gomoku.h
diff -u src/games/gomoku/gomoku.h:1.47 src/games/gomoku/gomoku.h:1.48
--- src/games/gomoku/gomoku.h:1.47 Sun May 29 00:12:11 2022
+++ src/games/gomoku/gomoku.h Sun May 29 00:38:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: gomoku.h,v 1.47 2022/05/29 00:12:11 rillig Exp $ */
+/* $NetBSD: gomoku.h,v 1.48 2022/05/29 00:38:26 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -59,8 +59,9 @@
#define EMPTY 2
#define BORDER 3
+/* A spot on the board, or in some cases one of the below special values. */
+typedef unsigned short spot_index;
/* return values for makemove, readinput */
-typedef int spot_index;
#define MOVEOK 0
#define RESIGN 1
#define ILLEGAL 2
@@ -232,7 +233,7 @@ extern struct spotstr board[BAREA]; /*
extern struct combostr frames[FAREA]; /* storage for single frames */
extern struct combostr *sortframes[2]; /* sorted, non-empty frames */
extern u_char overlap[FAREA * FAREA];
-extern short intersect[FAREA * FAREA]; /* frame [a][b] intersection */
+extern spot_index intersect[FAREA * FAREA]; /* frame [a][b] intersection */
extern struct game game;
extern int debug;
@@ -256,7 +257,7 @@ void debuglog(const char *, ...) __print
void whatsup(int);
const char *stoc(spot_index);
spot_index ctos(const char *);
-int makemove(int, int);
+int makemove(int, spot_index);
void clearcombo(struct combostr *, int);
void markcombo(struct combostr *);
int pickmove(int);
Index: src/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.67 src/games/gomoku/main.c:1.68
--- src/games/gomoku/main.c:1.67 Sun May 29 00:12:11 2022
+++ src/games/gomoku/main.c Sun May 29 00:38:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.67 2022/05/29 00:12:11 rillig Exp $ */
+/* $NetBSD: main.c,v 1.68 2022/05/29 00:38:26 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -36,7 +36,7 @@
__COPYRIGHT("@(#) Copyright (c) 1994\
The Regents of the University of California. All rights reserved.");
/* @(#)main.c 8.4 (Berkeley) 5/4/95 */
-__RCSID("$NetBSD: main.c,v 1.67 2022/05/29 00:12:11 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.68 2022/05/29 00:38:26 rillig Exp $");
#include <sys/stat.h>
#include <curses.h>
@@ -78,7 +78,7 @@ struct combostr frames[FAREA]; /* stora
struct combostr *sortframes[2]; /* sorted list of non-empty frames */
u_char overlap[FAREA * FAREA]; /* non-zero if frame [a][b] overlap;
* see init_overlap */
-short intersect[FAREA * FAREA]; /* frame [a][b] intersection */
+spot_index intersect[FAREA * FAREA]; /* frame [a][b] intersection */
struct game game;
const char *plyr[2] = { "???", "???" }; /* who's who */
Index: src/games/gomoku/makemove.c
diff -u src/games/gomoku/makemove.c:1.33 src/games/gomoku/makemove.c:1.34
--- src/games/gomoku/makemove.c:1.33 Sat May 28 08:32:55 2022
+++ src/games/gomoku/makemove.c Sun May 29 00:38:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: makemove.c,v 1.33 2022/05/28 08:32:55 rillig Exp $ */
+/* $NetBSD: makemove.c,v 1.34 2022/05/29 00:38:26 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
/* @(#)makemove.c 8.2 (Berkeley) 5/3/95 */
-__RCSID("$NetBSD: makemove.c,v 1.33 2022/05/28 08:32:55 rillig Exp $");
+__RCSID("$NetBSD: makemove.c,v 1.34 2022/05/29 00:38:26 rillig Exp $");
#include "gomoku.h"
@@ -97,7 +97,7 @@ old_weight_value(const struct spotstr *s
* TIE The game is a tie.
*/
int
-makemove(int us, int mv)
+makemove(int us, spot_index mv)
{
/* check for end of game */
Index: src/games/gomoku/pickmove.c
diff -u src/games/gomoku/pickmove.c:1.49 src/games/gomoku/pickmove.c:1.50
--- src/games/gomoku/pickmove.c:1.49 Sun May 29 00:12:11 2022
+++ src/games/gomoku/pickmove.c Sun May 29 00:38:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pickmove.c,v 1.49 2022/05/29 00:12:11 rillig Exp $ */
+/* $NetBSD: pickmove.c,v 1.50 2022/05/29 00:38:26 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
/* @(#)pickmove.c 8.2 (Berkeley) 5/3/95 */
-__RCSID("$NetBSD: pickmove.c,v 1.49 2022/05/29 00:12:11 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.50 2022/05/29 00:38:26 rillig Exp $");
#include <stdlib.h>
#include <string.h>
@@ -1078,7 +1078,6 @@ checkframes(struct combostr *cbp, struct
int i, n, mask, flags, verts, myindex, fcnt;
union comboval cb;
u_char *str;
- short *ip;
lcbp = NULL;
flags = 0;
@@ -1089,7 +1088,7 @@ checkframes(struct combostr *cbp, struct
myindex = cbp->c_nframes;
n = (int)(fcbp - frames) * FAREA;
str = &overlap[n];
- ip = &intersect[n];
+ spot_index *ip = &intersect[n];
/*
* i == which overlap bit to test based on whether 'fcbp' is
* an open or closed frame.
@@ -1119,8 +1118,8 @@ checkframes(struct combostr *cbp, struct
* 'fcbp' to, and it is a reasonable intersection
* spot, then there might be a loop.
*/
- n = ip[tcbp - frames];
- if (osp != &board[n]) {
+ spot_index s = ip[tcbp - frames];
+ if (osp != &board[s]) {
/* check to see if this is a valid loop */
if (verts != 0)
return -1;
@@ -1132,16 +1131,16 @@ checkframes(struct combostr *cbp, struct
* open-ended frame.
*/
if ((flags & C_OPEN_1) != 0 &&
- (n == tcbp->c_vertex ||
- n == tcbp->c_vertex + 5 * dd[tcbp->c_dir]))
+ (s == tcbp->c_vertex ||
+ s == tcbp->c_vertex + 5 * dd[tcbp->c_dir]))
return -1; /* invalid overlap */
if (cb.cv_win != 0 &&
- (n == fcbp->c_vertex ||
- n == fcbp->c_vertex + 5 * dd[fcbp->c_dir]))
+ (s == fcbp->c_vertex ||
+ s == fcbp->c_vertex + 5 * dd[fcbp->c_dir]))
return -1; /* invalid overlap */
- vertices->o_intersect = n;
- vertices->o_off = (n - tcbp->c_vertex) /
+ vertices->o_intersect = s;
+ vertices->o_off = (s - tcbp->c_vertex) /
dd[tcbp->c_dir];
vertices->o_frameindex = myindex;
verts++;
@@ -1167,8 +1166,8 @@ checkframes(struct combostr *cbp, struct
* 'fcbp' to, and it is a reasonable intersection
* spot, then there might be a loop.
*/
- n = ip[cbp - frames];
- if (osp != &board[n]) {
+ spot_index s = ip[cbp - frames];
+ if (osp != &board[s]) {
/* check to see if this is a valid loop */
if (verts != 0)
return -1;
@@ -1180,16 +1179,16 @@ checkframes(struct combostr *cbp, struct
* frame.
*/
if ((flags & C_OPEN_0) != 0 &&
- (n == cbp->c_vertex ||
- n == cbp->c_vertex + 5 * dd[cbp->c_dir]))
+ (s == cbp->c_vertex ||
+ s == cbp->c_vertex + 5 * dd[cbp->c_dir]))
return -1; /* invalid overlap */
if (cb.cv_win != 0 &&
- (n == fcbp->c_vertex ||
- n == fcbp->c_vertex + 5 * dd[fcbp->c_dir]))
+ (s == fcbp->c_vertex ||
+ s == fcbp->c_vertex + 5 * dd[fcbp->c_dir]))
return -1; /* invalid overlap */
- vertices->o_intersect = n;
- vertices->o_off = (n - cbp->c_vertex) /
+ vertices->o_intersect = s;
+ vertices->o_off = (s - cbp->c_vertex) /
dd[cbp->c_dir];
vertices->o_frameindex = 0;
verts++;