Gold in sack - this is a bug, right?

G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

I've never noticed this behavior before, but I'm assuming it must be a
bug. Briefly:

I had a sack. I had about $1000 in my bag. I was Burdened.

Taking gold ($20) out of the sack made me unBurdened.

I blinked. I tried it again several times. Put gold in, Burdened.
Take gold out, unBurdened. When I YASD'd not many turns later, it
definitely was a sack, _not_ a cursed BoH.

What could possibly explain this?
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

godseyj@planetc.com wrote:
> I've never noticed this behavior before, but I'm assuming it must be a
> bug. Briefly:
>
> I had a sack. I had about $1000 in my bag. I was Burdened.
>
> Taking gold ($20) out of the sack made me unBurdened.
>
> I blinked. I tried it again several times. Put gold in, Burdened.
> Take gold out, unBurdened. When I YASD'd not many turns later, it
> definitely was a sack, _not_ a cursed BoH.
>
> What could possibly explain this?

It's an artifact of integer rounding. Gold weighs 0.01, but this is
rounded to the nearest integer. I tried this myself: with 110 gold I was
unburdened, but putting half this in a sack made me burdened. In the
first case, the gold's weight was rounded down to 1, in the second, both
the 55 gold stacks were rounded up to weight 1 (total weight 2).
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

"David Corbett" <dcorbett42@yahoo.co.nz> wrote:

> It's an artifact of integer rounding. Gold weighs 0.01, but
> this is rounded to the nearest integer. I tried this myself:
> with 110 gold I was unburdened, but putting half this in a
> sack made me burdened.

Interesting. Yes, I'd call it a bug, but it seems unlikely to be
fixed. Programmers are used to integer rounding, and refactoring large
parts of NetHack to store weights to a greater precision probably
isn't worth the effort.

P.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

Paul E Collins wrote:
> "David Corbett" <dcorbett42@yahoo.co.nz> wrote:
>
>>It's an artifact of integer rounding. Gold weighs 0.01, but
>>this is rounded to the nearest integer. I tried this myself:
>>with 110 gold I was unburdened, but putting half this in a
>>sack made me burdened.
>
> Interesting. Yes, I'd call it a bug, but it seems unlikely to be
> fixed. Programmers are used to integer rounding, and refactoring large
> parts of NetHack to store weights to a greater precision probably
> isn't worth the effort.

Why "unlikely to be fixed"? Why "refactoring *large* parts of Nethack"?
You don't need any greater precision, just add all coins in bags and
inventory before rounding.

(IMO, it would be even sufficient to change the rounding of the special
case for coins; i.e. this one line in hack.c:

if (otmp->oclass == COIN_CLASS)
wt += (int)(((long)otmp->quan + 50L) / 100L);

to something, IMO more appropriate, like (the ceiling function):

if (otmp->oclass == COIN_CLASS)
wt += (int)(((long)otmp->quan + 99L) / 100L);

It's not as perfect■ as adding the coins in all bags *and* in inventory
and sum it up before doing the rounding, but I think that would be better
than it is now.)

Janis

■ Since you may get burdened when you take out coins from bags.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

On Thu, 29 Sep 2005 03:55:04 +0200, Janis Papanagnou wrote:
> ■ Since you may get burdened when you take out coins from bags.


Which is not unreasonable - after all, it's harder to carry coins in your
hands then in a sack!

--LWM
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

Janis Papanagnou wrote:

> Paul E Collins wrote:
>
>> "David Corbett" <dcorbett42@yahoo.co.nz> wrote:
>>
>>> It's an artifact of integer rounding. Gold weighs 0.01, but
>>> this is rounded to the nearest integer. I tried this myself:
>>> with 110 gold I was unburdened, but putting half this in a
>>> sack made me burdened.
>>
>>
>> Interesting. Yes, I'd call it a bug, but it seems unlikely to be
>> fixed. Programmers are used to integer rounding, and refactoring large
>> parts of NetHack to store weights to a greater precision probably
>> isn't worth the effort.
>
>
> Why "unlikely to be fixed"? Why "refactoring *large* parts of Nethack"?
> You don't need any greater precision, just add all coins in bags and
> inventory before rounding.

And keeping track which amount is in blessed BoHs, which is in cursed
BoHs, which is in nested blessed BoHs etc. Too complicated.

Topi
--
"The whole problem with the world is that fools and fanatics are
always so certain of themselves, but wiser people so full of doubts."
- Bertrand Russell
"How come he didn't put 'I think' at the end of it?" - Anonymous