summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-05-29 18:05:25 +0000
committerrillig <rillig@NetBSD.org>2022-05-29 18:05:25 +0000
commitd2d4ab53e5fec97c40bf208106124691beb7d027 (patch)
treedcca700dab447a9bbf5e99900331995a8decba44 /games
parent16dd548a7e497df17115db0854aa4d0959fad621 (diff)
gomoku: do not scan the upper border for combos
Adding the '+ 1' to the row coordinate added an offset of 20, while the intended offset was 1. No functional change, just a bit faster.
Diffstat (limited to 'games')
-rw-r--r--games/gomoku/pickmove.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/games/gomoku/pickmove.c b/games/gomoku/pickmove.c
index 543b29ef3ed..e5aa8f43928 100644
--- a/games/gomoku/pickmove.c
+++ b/games/gomoku/pickmove.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pickmove.c,v 1.62 2022/05/29 17:01:42 rillig Exp $ */
+/* $NetBSD: pickmove.c,v 1.63 2022/05/29 18:05:25 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.62 2022/05/29 17:01:42 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.63 2022/05/29 18:05:25 rillig Exp $");
#include <stdlib.h>
#include <string.h>
@@ -92,8 +92,8 @@ pickmove(player_color us)
return PT((BSZ + 1) / 2, (BSZ + 1) / 2);
/* initialize all the board values */
- for (unsigned pos = PT(BSZ, BSZ + 1); pos-- > PT(1, 1); ) {
- struct spotstr *sp = &board[pos];
+ for (spot_index s = PT(BSZ, BSZ) + 1; s-- > PT(1, 1); ) {
+ struct spotstr *sp = &board[s];
sp->s_combo[BLACK].s = 0x601;
sp->s_combo[WHITE].s = 0x601;
sp->s_level[BLACK] = 255;
@@ -358,8 +358,8 @@ scanframes(int color)
}
/* scan for combos at empty spots */
- for (unsigned pos = PT(BSZ, BSZ + 1); pos-- > PT(1, 1); ) {
- sp = &board[pos];
+ for (spot_index s = PT(BSZ, BSZ) + 1; s-- > PT(1, 1); ) {
+ sp = &board[s];
for (struct elist *ep = sp->s_empty; ep != NULL; ep = nep) {
cbp = ep->e_combo;
if (cbp->c_combo.s <= sp->s_combo[color].s) {
@@ -566,8 +566,8 @@ addframes(unsigned int level)
/* scan for combos at empty spots */
int c = curcolor;
- for (unsigned pos = PT(BSZ, BSZ + 1); pos-- > PT(1, 1); ) {
- struct spotstr *sp = &board[pos];
+ for (spot_index s = PT(BSZ, BSZ) + 1; s-- > PT(1, 1); ) {
+ struct spotstr *sp = &board[s];
for (struct elist *ep = sp->s_empty; ep != NULL; ep = nep) {
cbp = ep->e_combo;
if (cbp->c_combo.s <= sp->s_combo[c].s) {