Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/gomoku gomoku: remove column macros
details: https://anonhg.NetBSD.org/src/rev/d34f0fc935be
branches: trunk
changeset: 366144:d34f0fc935be
user: rillig <rillig%NetBSD.org@localhost>
date: Sun May 15 22:18:36 2022 +0000
description:
gomoku: remove column macros
Of the 19 macros, only 3 were actually used. Replace their uses with
expressions based on the board size. It's a small step to making the
board size adjustable. There are still other places using hard-coded
numbers.
No binary change.
diffstat:
games/gomoku/gomoku.h | 22 +---------------------
games/gomoku/pickmove.c | 16 ++++++++--------
2 files changed, 9 insertions(+), 29 deletions(-)
diffs (97 lines):
diff -r 9327890a50e8 -r d34f0fc935be games/gomoku/gomoku.h
--- a/games/gomoku/gomoku.h Sun May 15 22:08:05 2022 +0000
+++ b/games/gomoku/gomoku.h Sun May 15 22:18:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gomoku.h,v 1.22 2022/05/15 22:00:11 rillig Exp $ */
+/* $NetBSD: gomoku.h,v 1.23 2022/05/15 22:18:36 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -75,26 +75,6 @@
#define TIE 4
#define SAVE 5
-#define A 1
-#define B 2
-#define C 3
-#define D 4
-#define E 5
-#define F 6
-#define G 7
-#define H 8
-#define J 9
-#define K 10
-#define L 11
-#define M 12
-#define N 13
-#define O 14
-#define P 15
-#define Q 16
-#define R 17
-#define S 18
-#define T 19
-
#define PT(x, y) ((x) + BSZ1 * (y))
/*
diff -r 9327890a50e8 -r d34f0fc935be games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c Sun May 15 22:08:05 2022 +0000
+++ b/games/gomoku/pickmove.c Sun May 15 22:18:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pickmove.c,v 1.25 2022/05/15 22:08:05 rillig Exp $ */
+/* $NetBSD: pickmove.c,v 1.26 2022/05/15 22:18:36 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)pickmove.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: pickmove.c,v 1.25 2022/05/15 22:08:05 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.26 2022/05/15 22:18:36 rillig Exp $");
#endif
#endif /* not lint */
@@ -88,10 +88,10 @@
/* first move is easy */
if (movenum == 1)
- return PT(K, 10);
+ return PT((BSZ + 1) / 2, (BSZ + 1) / 2);
/* initialize all the board values */
- for (pos = PT(T, 20); pos-- > PT(A, 1); ) {
+ for (pos = PT(BSZ, BSZ + 1); pos-- > PT(1, 1); ) {
sp = &board[pos];
sp->s_combo[BLACK].s = MAXCOMBO + 1;
sp->s_combo[WHITE].s = MAXCOMBO + 1;
@@ -110,9 +110,9 @@
scanframes(WHITE);
/* find the spot with the highest value */
- pos = PT(T, 19);
+ pos = PT(BSZ, BSZ);
sp1 = sp2 = &board[pos];
- for ( ; pos-- > PT(A, 1); ) {
+ for ( ; pos-- > PT(1, 1); ) {
sp = &board[pos];
if (sp->s_occ != EMPTY)
continue;
@@ -352,7 +352,7 @@
}
/* scan for combos at empty spots */
- for (pos = PT(T, 20); pos-- > PT(A, 1); ) {
+ for (pos = PT(BSZ, BSZ + 1); pos-- > PT(1, 1); ) {
sp = &board[pos];
for (ep = sp->s_empty; ep; ep = nep) {
cbp = ep->e_combo;
@@ -562,7 +562,7 @@
/* scan for combos at empty spots */
i = curcolor;
- for (pos = PT(T, 20); pos-- > PT(A, 1); ) {
+ for (pos = PT(BSZ, BSZ + 1); pos-- > PT(1, 1); ) {
sp = &board[pos];
for (ep = sp->s_empty; ep; ep = nep) {
cbp = ep->e_combo;
Home |
Main Index |
Thread Index |
Old Index