Module Name: src Committed By: rillig Date: Sat May 21 15:11:24 UTC 2022
Modified Files: src/games/gomoku: bdinit.c gomoku.h makemove.c pickmove.c Log Message: gomoku: inline macro MAXCOMBO The name of the macro was not descriptive enough, the other constants in bdinit also don't have names. No binary change. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/games/gomoku/bdinit.c cvs rdiff -u -r1.34 -r1.35 src/games/gomoku/gomoku.h cvs rdiff -u -r1.18 -r1.19 src/games/gomoku/makemove.c cvs rdiff -u -r1.40 -r1.41 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.19 src/games/gomoku/bdinit.c:1.20 --- src/games/gomoku/bdinit.c:1.19 Thu May 19 22:29:36 2022 +++ src/games/gomoku/bdinit.c Sat May 21 15:11:24 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bdinit.c,v 1.19 2022/05/19 22:29:36 rillig Exp $ */ +/* $NetBSD: bdinit.c,v 1.20 2022/05/21 15:11:24 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.19 2022/05/19 22:29:36 rillig Exp $"); +__RCSID("$NetBSD: bdinit.c,v 1.20 2022/05/21 15:11:24 rillig Exp $"); #include <string.h> #include "gomoku.h" @@ -68,12 +68,12 @@ bdinit(struct spotstr *bp) /* directions 1, 2, 3 are blocked */ sp->s_flags |= (BFLAG << 1) | (BFLAG << 2) | (BFLAG << 3); - sp->s_fval[BLACK][1].s = MAXCOMBO; - sp->s_fval[BLACK][2].s = MAXCOMBO; - sp->s_fval[BLACK][3].s = MAXCOMBO; - sp->s_fval[WHITE][1].s = MAXCOMBO; - sp->s_fval[WHITE][2].s = MAXCOMBO; - sp->s_fval[WHITE][3].s = MAXCOMBO; + sp->s_fval[BLACK][1].s = 0x600; + sp->s_fval[BLACK][2].s = 0x600; + sp->s_fval[BLACK][3].s = 0x600; + sp->s_fval[WHITE][1].s = 0x600; + sp->s_fval[WHITE][2].s = 0x600; + sp->s_fval[WHITE][3].s = 0x600; } else if (j == 5) { /* five spaces, blocked on one side */ sp->s_fval[BLACK][1].s = 0x500; @@ -94,10 +94,10 @@ bdinit(struct spotstr *bp) if (i > (BSZ - 4)) { /* directions 0, 1 are blocked */ sp->s_flags |= BFLAG | (BFLAG << 1); - sp->s_fval[BLACK][0].s = MAXCOMBO; - sp->s_fval[BLACK][1].s = MAXCOMBO; - sp->s_fval[WHITE][0].s = MAXCOMBO; - sp->s_fval[WHITE][1].s = MAXCOMBO; + sp->s_fval[BLACK][0].s = 0x600; + sp->s_fval[BLACK][1].s = 0x600; + sp->s_fval[WHITE][0].s = 0x600; + sp->s_fval[WHITE][1].s = 0x600; } else if (i == (BSZ - 4)) { sp->s_fval[BLACK][0].s = 0x500; sp->s_fval[WHITE][0].s = 0x500; @@ -112,8 +112,8 @@ bdinit(struct spotstr *bp) if (i < 5) { /* direction 3 is blocked */ sp->s_flags |= (BFLAG << 3); - sp->s_fval[BLACK][3].s = MAXCOMBO; - sp->s_fval[WHITE][3].s = MAXCOMBO; + sp->s_fval[BLACK][3].s = 0x600; + sp->s_fval[WHITE][3].s = 0x600; } else if (i == 5 && (sp->s_flags & (BFLAG << 3)) == 0) { sp->s_fval[BLACK][3].s = 0x500; Index: src/games/gomoku/gomoku.h diff -u src/games/gomoku/gomoku.h:1.34 src/games/gomoku/gomoku.h:1.35 --- src/games/gomoku/gomoku.h:1.34 Sat May 21 14:55:26 2022 +++ src/games/gomoku/gomoku.h Sat May 21 15:11:24 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: gomoku.h,v 1.34 2022/05/21 14:55:26 rillig Exp $ */ +/* $NetBSD: gomoku.h,v 1.35 2022/05/21 15:11:24 rillig Exp $ */ /* * Copyright (c) 1994 @@ -114,8 +114,6 @@ * complete which takes fewer or the same number of moves to win). */ -#define MAXCOMBO 0x600 - union comboval { struct { #if BYTE_ORDER == BIG_ENDIAN Index: src/games/gomoku/makemove.c diff -u src/games/gomoku/makemove.c:1.18 src/games/gomoku/makemove.c:1.19 --- src/games/gomoku/makemove.c:1.18 Thu May 19 22:19:18 2022 +++ src/games/gomoku/makemove.c Sat May 21 15:11:24 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: makemove.c,v 1.18 2022/05/19 22:19:18 rillig Exp $ */ +/* $NetBSD: makemove.c,v 1.19 2022/05/21 15:11:24 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.18 2022/05/19 22:19:18 rillig Exp $"); +__RCSID("$NetBSD: makemove.c,v 1.19 2022/05/21 15:11:24 rillig Exp $"); #include "gomoku.h" @@ -128,8 +128,8 @@ makemove(int us, int mv) else { /* this frame is now blocked, adjust values */ fsp->s_flags |= bmask; - fsp->s_fval[BLACK][r].s = MAXCOMBO; - fsp->s_fval[WHITE][r].s = MAXCOMBO; + fsp->s_fval[BLACK][r].s = 0x600; + fsp->s_fval[WHITE][r].s = 0x600; while (--i >= 0) { sp += d; if (sp->s_occ == EMPTY) @@ -144,7 +144,7 @@ makemove(int us, int mv) return(WIN); /* compute new value & combo number for this frame & color */ - fsp->s_fval[us != BLACK ? BLACK : WHITE][r].s = MAXCOMBO; + fsp->s_fval[us != BLACK ? BLACK : WHITE][r].s = 0x600; cp = &fsp->s_fval[us][r]; /* both ends open? */ if (space && sp->s_occ == EMPTY) { Index: src/games/gomoku/pickmove.c diff -u src/games/gomoku/pickmove.c:1.40 src/games/gomoku/pickmove.c:1.41 --- src/games/gomoku/pickmove.c:1.40 Sat May 21 10:01:49 2022 +++ src/games/gomoku/pickmove.c Sat May 21 15:11:24 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pickmove.c,v 1.40 2022/05/21 10:01:49 rillig Exp $ */ +/* $NetBSD: pickmove.c,v 1.41 2022/05/21 15:11:24 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.40 2022/05/21 10:01:49 rillig Exp $"); +__RCSID("$NetBSD: pickmove.c,v 1.41 2022/05/21 15:11:24 rillig Exp $"); #include <stdlib.h> #include <string.h> @@ -98,8 +98,8 @@ pickmove(int us) /* initialize all the board values */ for (unsigned 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; + sp->s_combo[BLACK].s = 0x601; + sp->s_combo[WHITE].s = 0x601; sp->s_level[BLACK] = 255; sp->s_level[WHITE] = 255; sp->s_nforce[BLACK] = 0;