Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/gomoku gomoku: prevent thinking for too long
details: https://anonhg.NetBSD.org/src/rev/8c39080a28ff
branches: trunk
changeset: 366265:8c39080a28ff
user: rillig <rillig%NetBSD.org@localhost>
date: Sat May 21 10:01:49 2022 +0000
description:
gomoku: prevent thinking for too long
At search depth 9, picking a move takes about a minute on modern
hardware, which is enough for casual game play. Even then, gomoku does
not always find the perfect move, so investing that much time seems
questionable. Limiting the search depth also puts an upper bound on the
memory usage, which is quite high with 150 MB.
diffstat:
games/gomoku/pickmove.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diffs (27 lines):
diff -r 45b7cb81e220 -r 8c39080a28ff games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c Sat May 21 09:57:53 2022 +0000
+++ b/games/gomoku/pickmove.c Sat May 21 10:01:49 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pickmove.c,v 1.39 2022/05/20 19:30:17 rillig Exp $ */
+/* $NetBSD: pickmove.c,v 1.40 2022/05/21 10:01:49 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.39 2022/05/20 19:30:17 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.40 2022/05/21 10:01:49 rillig Exp $");
#include <stdlib.h>
#include <string.h>
@@ -332,6 +332,8 @@
d = 2;
/* LINTED 117: bitwise '>>' on signed value possibly nonportable */
while (d <= ((movenum + 1) >> 1) && combolen > n) {
+ if (d >= 9)
+ break; /* Do not think too long. */
if (debug != 0) {
debuglog("%cL%d %d %d %d", "BW"[color],
d, combolen - n, combocnt, elistcnt);
Home |
Main Index |
Thread Index |
Old Index