fix github issue #752 - characteristics init
Issue #752 by vultur-cadens: initialization of characteristics had off by one errors when reducing over-allocation and when increasing under-allocation, biasing Str over Cha. This simplifies the code very slightly but it still seems somewhat confusing to me. A couple of reformatting bits are included. Closes #752
This commit is contained in:
+5
-1
@@ -1,4 +1,4 @@
|
|||||||
HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.906 $ $NHDT-Date: 1651886993 2022/05/07 01:29:53 $
|
HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.907 $ $NHDT-Date: 1651908301 2022/05/07 07:25:01 $
|
||||||
|
|
||||||
General Fixes and Modified Features
|
General Fixes and Modified Features
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
@@ -903,6 +903,10 @@ using wizard mode ^V in endgame to return to previously visited Plane of Water
|
|||||||
likewise for clouds on Plane of Air
|
likewise for clouds on Plane of Air
|
||||||
on tty at least, "version incompatibility for save/123xyzzy" was invisible:
|
on tty at least, "version incompatibility for save/123xyzzy" was invisible:
|
||||||
a blank message of appropriate length followed by --More--
|
a blank message of appropriate length followed by --More--
|
||||||
|
fix a pair of off-by-one bugs when doling out initial characteristics points,
|
||||||
|
resulting in an unintentional bias toward Str and away from Cha;
|
||||||
|
negligible effect on individual games but had a minor cumulative
|
||||||
|
effect across a large set of games
|
||||||
|
|
||||||
|
|
||||||
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
|
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
|
||||||
|
|||||||
+26
-36
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 attrib.c $NHDT-Date: 1626312521 2021/07/15 01:28:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.79 $ */
|
/* NetHack 3.7 attrib.c $NHDT-Date: 1651908297 2022/05/07 07:24:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.86 $ */
|
||||||
/* Copyright 1988, 1989, 1990, 1992, M. Stephenson */
|
/* Copyright 1988, 1989, 1990, 1992, M. Stephenson */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -459,14 +459,11 @@ exerper(void)
|
|||||||
{
|
{
|
||||||
if (!(g.moves % 10)) {
|
if (!(g.moves % 10)) {
|
||||||
/* Hunger Checks */
|
/* Hunger Checks */
|
||||||
|
int hs = (u.uhunger > 1000) ? SATIATED
|
||||||
int hs = (u.uhunger > 1000) ? SATIATED : (u.uhunger > 150)
|
: (u.uhunger > 150) ? NOT_HUNGRY
|
||||||
? NOT_HUNGRY
|
: (u.uhunger > 50) ? HUNGRY
|
||||||
: (u.uhunger > 50)
|
: (u.uhunger > 0) ? WEAK
|
||||||
? HUNGRY
|
: FAINTING;
|
||||||
: (u.uhunger > 0)
|
|
||||||
? WEAK
|
|
||||||
: FAINTING;
|
|
||||||
|
|
||||||
debugpline0("exerper: Hunger checks");
|
debugpline0("exerper: Hunger checks");
|
||||||
switch (hs) {
|
switch (hs) {
|
||||||
@@ -578,19 +575,13 @@ exerchk(void)
|
|||||||
goto nextattrib;
|
goto nextattrib;
|
||||||
|
|
||||||
debugpline2("exerchk: testing %s (%d).",
|
debugpline2("exerchk: testing %s (%d).",
|
||||||
(i == A_STR)
|
(i == A_STR) ? "Str"
|
||||||
? "Str"
|
: (i == A_INT) ? "Int?"
|
||||||
: (i == A_INT)
|
: (i == A_WIS) ? "Wis"
|
||||||
? "Int?"
|
: (i == A_DEX) ? "Dex"
|
||||||
: (i == A_WIS)
|
: (i == A_CON) ? "Con"
|
||||||
? "Wis"
|
: (i == A_CHA) ? "Cha?"
|
||||||
: (i == A_DEX)
|
: "???",
|
||||||
? "Dex"
|
|
||||||
: (i == A_CON)
|
|
||||||
? "Con"
|
|
||||||
: (i == A_CHA)
|
|
||||||
? "Cha?"
|
|
||||||
: "???",
|
|
||||||
ax);
|
ax);
|
||||||
/*
|
/*
|
||||||
* Law of diminishing returns (Part III):
|
* Law of diminishing returns (Part III):
|
||||||
@@ -617,10 +608,12 @@ exerchk(void)
|
|||||||
AEXE(i) = (abs(ax) / 2) * mod_val;
|
AEXE(i) = (abs(ax) / 2) * mod_val;
|
||||||
}
|
}
|
||||||
g.context.next_attrib_check += rn1(200, 800);
|
g.context.next_attrib_check += rn1(200, 800);
|
||||||
debugpline1("exerchk: next check at %ld.", g.context.next_attrib_check);
|
debugpline1("exerchk: next check at %ld.",
|
||||||
|
g.context.next_attrib_check);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* allocate hero's initial characteristics */
|
||||||
void
|
void
|
||||||
init_attr(int np)
|
init_attr(int np)
|
||||||
{
|
{
|
||||||
@@ -632,15 +625,15 @@ init_attr(int np)
|
|||||||
np -= g.urole.attrbase[i];
|
np -= g.urole.attrbase[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 3.7: the x -= ... calculation used to have an off by 1 error that
|
||||||
|
resulted in the values being biased toward Str and away from Cha */
|
||||||
tryct = 0;
|
tryct = 0;
|
||||||
while (np > 0 && tryct < 100) {
|
while (np > 0 && tryct < 100) {
|
||||||
x = rn2(100);
|
x = rn2(100);
|
||||||
for (i = 0; (i < A_MAX) && ((x -= g.urole.attrdist[i]) > 0); i++)
|
for (i = 0; i < A_MAX; ++i)
|
||||||
;
|
if ((x -= g.urole.attrdist[i]) < 0)
|
||||||
if (i >= A_MAX)
|
break;
|
||||||
continue; /* impossible */
|
if (i >= A_MAX || ABASE(i) >= ATTRMAX(i)) {
|
||||||
|
|
||||||
if (ABASE(i) >= ATTRMAX(i)) {
|
|
||||||
tryct++;
|
tryct++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -652,14 +645,11 @@ init_attr(int np)
|
|||||||
|
|
||||||
tryct = 0;
|
tryct = 0;
|
||||||
while (np < 0 && tryct < 100) { /* for redistribution */
|
while (np < 0 && tryct < 100) { /* for redistribution */
|
||||||
|
|
||||||
x = rn2(100);
|
x = rn2(100);
|
||||||
for (i = 0; (i < A_MAX) && ((x -= g.urole.attrdist[i]) > 0); i++)
|
for (i = 0; i < A_MAX; ++i)
|
||||||
;
|
if ((x -= g.urole.attrdist[i]) < 0)
|
||||||
if (i >= A_MAX)
|
break;
|
||||||
continue; /* impossible */
|
if (i >= A_MAX || ABASE(i) <= ATTRMIN(i)) {
|
||||||
|
|
||||||
if (ABASE(i) <= ATTRMIN(i)) {
|
|
||||||
tryct++;
|
tryct++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user