Module Name: src Committed By: rillig Date: Sun May 15 22:18:36 UTC 2022
Modified Files: src/games/gomoku: gomoku.h pickmove.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/games/gomoku/gomoku.h cvs rdiff -u -r1.25 -r1.26 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/gomoku.h diff -u src/games/gomoku/gomoku.h:1.22 src/games/gomoku/gomoku.h:1.23 --- src/games/gomoku/gomoku.h:1.22 Sun May 15 22:00:11 2022 +++ src/games/gomoku/gomoku.h Sun May 15 22:18:36 2022 @@ -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)) /* Index: src/games/gomoku/pickmove.c diff -u src/games/gomoku/pickmove.c:1.25 src/games/gomoku/pickmove.c:1.26 --- src/games/gomoku/pickmove.c:1.25 Sun May 15 22:08:05 2022 +++ src/games/gomoku/pickmove.c Sun May 15 22:18:36 2022 @@ -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 @@ pickmove(int us) /* 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 @@ pickmove(int us) 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 @@ scanframes(int color) } /* 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 @@ addframes(int level) /* 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;