fuzzer tweaks

Prevent the fuzzer from randomly toggling the 'silent' option.  If
you use the default value of True then this eliminates most--but not
all--of the beeping that happens when it is running.  I'm not sure
where the remaining beeps are coming from.

Modify the random keystroke selection to implement some bias towards
direction keys that I thought had already been there, plus a higher
chance to entering digits to initiate number responses.
This commit is contained in:
PatR
2019-06-17 09:31:01 -07:00
parent 820320ba55
commit 24d6d6b070
2 changed files with 46 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 cmd.c $NHDT-Date: 1559382745 2019/06/01 09:52:25 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.335 $ */
/* NetHack 3.6 cmd.c $NHDT-Date: 1560789049 2019/06/17 16:30:49 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.336 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -4530,21 +4530,50 @@ int NDECL((*cmd_func));
char
randomkey()
{
static int i = 0;
static unsigned i = 0;
char c;
switch (rn2(12)) {
default: c = '\033'; break;
case 0: c = '\n'; break;
switch (rn2(16)) {
default:
c = '\033';
break;
case 0:
c = '\n';
break;
case 1:
case 2:
case 3:
case 4: c = (char)(' ' + rn2((int)('~' - ' '))); break;
case 5: c = '\t'; break;
case 6: c = (char)('a' + rn2((int)('z' - 'a'))); break;
case 7: c = (char)('A' + rn2((int)('Z' - 'A'))); break;
case 8: c = extcmdlist[(i++) % SIZE(extcmdlist)].key; break;
case 9: c = '#'; break;
case 4:
c = (char) rn1('~' - ' ' + 1, ' ');
break;
case 5:
c = (char) (rn2(2) ? '\t' : ' ');
break;
case 6:
c = (char) rn1('z' - 'a' + 1, 'a');
break;
case 7:
c = (char) rn1('Z' - 'A' + 1, 'A');
break;
case 8:
c = extcmdlist[i++ % SIZE(extcmdlist)].key;
break;
case 9:
c = '#';
break;
case 10:
case 11:
case 12:
c = Cmd.dirchars[rn2(8)];
if (!rn2(7))
c = !Cmd.num_pad ? (!rn2(3) ? C(c) : (c + 'A' - 'a')) : M(c);
break;
case 13:
c = (char) rn1('9' - '0' + 1, '0');
break;
case 14:
c = (char) rn2(iflags.wc_eight_bit_input ? 256 : 128);
break;
}
return c;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1554591224 2019/04/06 22:53:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.363 $ */
/* NetHack 3.6 options.c $NHDT-Date: 1560789054 2019/06/17 16:30:54 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.364 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3993,7 +3993,6 @@ boolean tinitial, tfrom_file;
}
op = string_for_opt(opts, TRUE);
if (op) {
if (negated) {
config_error_add(
@@ -4010,6 +4009,11 @@ boolean tinitial, tfrom_file;
return FALSE;
}
}
if (iflags.debug_fuzzer && !initial) {
/* don't randomly toggle this/these */
if (boolopt[i].addr == &flags.silent)
return TRUE;
}
*(boolopt[i].addr) = !negated;