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 write-only members from overlap_...



details:   https://anonhg.NetBSD.org/src/rev/fa73a93557be
branches:  trunk
changeset: 366145:fa73a93557be
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 15 22:41:51 2022 +0000

description:
gomoku: remove write-only members from overlap_info

Since overlap_info is only used in pickmove.c, move it there.

No functional change.  In particular, in the middle of a game, gomoku
still tends to fall into analysis paralysis, thinking about the best
move for more than 3 minutes on modern hardware.  Since the algorithm is
basically unchanged since the 1990s, it must have been a long waiting
time back then, probably an hour per move.

diffstat:

 games/gomoku/gomoku.h   |  14 +-------------
 games/gomoku/pickmove.c |  17 +++++++++++------
 2 files changed, 12 insertions(+), 19 deletions(-)

diffs (87 lines):

diff -r d34f0fc935be -r fa73a93557be games/gomoku/gomoku.h
--- a/games/gomoku/gomoku.h     Sun May 15 22:18:36 2022 +0000
+++ b/games/gomoku/gomoku.h     Sun May 15 22:41:51 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gomoku.h,v 1.23 2022/05/15 22:18:36 rillig Exp $       */
+/*     $NetBSD: gomoku.h,v 1.24 2022/05/15 22:41:51 rillig Exp $       */
 
 /*
  * Copyright (c) 1994
@@ -174,7 +174,6 @@
 #define C_OPEN_0       0x01            /* link[0] is an open ended frame */
 #define C_OPEN_1       0x02            /* link[1] is an open ended frame */
 #define C_LOOP         0x04            /* link[1] intersects previous frame */
-#define C_MARK         0x08            /* indicates combo processed */
 
 /*
  * This structure is used for recording the completion points of
@@ -221,17 +220,6 @@
 #define BFLAG          0x010000        /* frame intersects border or dead */
 #define BFLAGALL       0x0F0000        /* all frames dead */
 
-/*
- * This structure is used to store overlap information between frames.
- */
-struct overlap_info {
-       int             o_intersect;    /* intersection spot */
-       struct combostr *o_fcombo;      /* the connecting combo */
-       u_char          o_link;         /* which link to update (0 or 1) */
-       u_char          o_off;          /* offset in frame of intersection */
-       u_char          o_frameindex;   /* intersection frame index */
-};
-
 extern const char      *letters;
 extern const char      pdir[];
 
diff -r d34f0fc935be -r fa73a93557be games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c   Sun May 15 22:18:36 2022 +0000
+++ b/games/gomoku/pickmove.c   Sun May 15 22:41:51 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pickmove.c,v 1.26 2022/05/15 22:18:36 rillig Exp $     */
+/*     $NetBSD: pickmove.c,v 1.27 2022/05/15 22:41:51 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.26 2022/05/15 22:18:36 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.27 2022/05/15 22:41:51 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -55,6 +55,15 @@
 #define BIT_CLR(a, b)  ((a)[(b)/BITS_PER_INT] &= ~(1 << ((b) % BITS_PER_INT)))
 #define BIT_TEST(a, b) ((a)[(b)/BITS_PER_INT] & (1 << ((b) % BITS_PER_INT)))
 
+/*
+ * This structure is used to store overlap information between frames.
+ */
+struct overlap_info {
+       int             o_intersect;    /* intersection spot */
+       u_char          o_off;          /* offset in frame of intersection */
+       u_char          o_frameindex;   /* intersection frame index */
+};
+
 static struct combostr *hashcombos[FAREA];/* hash list for finding duplicates */
 static struct combostr *sortcombos;    /* combos at higher levels */
 static int combolen;                   /* number of combos in sortcombos */
@@ -1148,8 +1157,6 @@
                                        return -1;      /* invalid overlap */
 
                                vertices->o_intersect = n;
-                               vertices->o_fcombo = cbp;
-                               vertices->o_link = 1;
                                vertices->o_off = (n - tcbp->c_vertex) /
                                        dd[tcbp->c_dir];
                                vertices->o_frameindex = myindex;
@@ -1198,8 +1205,6 @@
                                return -1;      /* invalid overlap */
 
                        vertices->o_intersect = n;
-                       vertices->o_fcombo = lcbp;
-                       vertices->o_link = 0;
                        vertices->o_off = (n - cbp->c_vertex) /
                                dd[cbp->c_dir];
                        vertices->o_frameindex = 0;



Home | Main Index | Thread Index | Old Index