From 40b35c4f300ebd47a419e90a30b32ec62b738153 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 28 Jan 2004 19:30:15 +0000 Subject: [PATCH] (guerrilla): Give wandering che inexact, somewhat randomized information on military. Closes #750533. Why? Wandering che pick a sector with minimal military from the adjacent sectors that can get che. Ties are broken in favour of the first sector examined. Since sectors are examined in the order given by by diroff[], che prefer directions with low index in diroff[]. This tends to channel che towards the northeast. But the change makes ties very unlikely. --- src/lib/update/revolt.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/lib/update/revolt.c b/src/lib/update/revolt.c index 763abba1..382f6474 100644 --- a/src/lib/update/revolt.c +++ b/src/lib/update/revolt.c @@ -399,11 +399,12 @@ guerrilla(struct sctstr *sp) } domove: if (move && che > 0) { - struct sctstr *maybe_sp = 0; + struct sctstr *nicest_sp = 0; if (convert) min_mil = 999; else min_mil = mil; + /* search adjacent sectors for a nice one */ for (n = 1; n <= 6; n++) { nsp = getsectp(sp->sct_x + diroff[n][0], sp->sct_y + diroff[n][1]); @@ -419,22 +420,23 @@ guerrilla(struct sctstr *sp) continue; } val = getvar(V_MILIT, (s_char *)nsp, EF_SECTOR); + /* don't give che more precise info than spy */ + val = roundintby(val, 10); + /* inject a modicum of indeterminism; also + * avoids che preferring certain directions */ + val += random() % 10 - 5; if (val >= min_mil) continue; - maybe_sp = nsp; + nicest_sp = nsp; min_mil = val; } - /* - * if n <= 6, we found a sector owned by TARGET which - * is a nice sector. Otherwise, we move to the first - * one we find ("maybe_sp"). - */ - if (maybe_sp != 0) { - che_combo = getvar(V_CHE, (s_char *)maybe_sp, EF_SECTOR); + /* if we found a nice sector, go there */ + if (nicest_sp != 0) { + che_combo = getvar(V_CHE, (s_char *)nicest_sp, EF_SECTOR); che += get_che_value(che_combo); set_che_value(che_combo, che); set_che_cnum(che_combo, target); - putvar(V_CHE, (int)che_combo, (s_char *)maybe_sp, EF_SECTOR); + putvar(V_CHE, (int)che_combo, (s_char *)nicest_sp, EF_SECTOR); che = 0; } }