Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/gomoku gomoku: inline macro MAXCOMBO
details: https://anonhg.NetBSD.org/src/rev/3ec848f6d532
branches: trunk
changeset: 366279:3ec848f6d532
user: rillig <rillig%NetBSD.org@localhost>
date: Sat May 21 15:11:24 2022 +0000
description:
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.
diffstat:
games/gomoku/bdinit.c | 28 ++++++++++++++--------------
games/gomoku/gomoku.h | 4 +---
games/gomoku/makemove.c | 10 +++++-----
games/gomoku/pickmove.c | 8 ++++----
4 files changed, 24 insertions(+), 26 deletions(-)
diffs (148 lines):
diff -r 1b4530fce4df -r 3ec848f6d532 games/gomoku/bdinit.c
--- a/games/gomoku/bdinit.c Sat May 21 15:03:08 2022 +0000
+++ b/games/gomoku/bdinit.c Sat May 21 15:11:24 2022 +0000
@@ -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 @@
/* 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 @@
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 @@
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;
diff -r 1b4530fce4df -r 3ec848f6d532 games/gomoku/gomoku.h
--- a/games/gomoku/gomoku.h Sat May 21 15:03:08 2022 +0000
+++ b/games/gomoku/gomoku.h Sat May 21 15:11:24 2022 +0000
@@ -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
diff -r 1b4530fce4df -r 3ec848f6d532 games/gomoku/makemove.c
--- a/games/gomoku/makemove.c Sat May 21 15:03:08 2022 +0000
+++ b/games/gomoku/makemove.c Sat May 21 15:11:24 2022 +0000
@@ -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 @@
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 @@
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) {
diff -r 1b4530fce4df -r 3ec848f6d532 games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c Sat May 21 15:03:08 2022 +0000
+++ b/games/gomoku/pickmove.c Sat May 21 15:11:24 2022 +0000
@@ -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 @@
/* 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;
Home |
Main Index |
Thread Index |
Old Index