Author Topic: Bug in Rogue v1.1 for DOS?  (Read 3360 times)

Xerxes314

  • Acolyte
  • *
  • Posts: 3
    • View Profile
Bug in Rogue v1.1 for DOS?
« on: July 11, 2013, 10:35:33 PM »
I was recently playing my childhood version of Rogue, v1.1 for DOS, and contemplating how brutally difficult it is. To help me judge whether my character could go toe-to-toe with trolls, I wrote a combat simulator to give me the probability of winning. The simulator insisted my odds were 90% or better even though I kept dying. So I delved into the source code (for not quite the same version) and discovered that sleep/held status is not properly handled for the player.

When a monster or player is sleeping or held, the to-hit roll for an attacker is supposed to be at +4; this is handled by a flag called ISRUN (for "is the thing up and running around?"). However, although the player can have his ISRUN set to false (by potions of paralysis, scrolls of sleep, starving, etc.), no part of the code ever sets it to true. I checked a Unix version (v5.4) and verified that ISRUN is set true whenever a sleep/hold expires. By tedious bookkeeping, I checked that while a level-1 monster (say, an emu) should hit a starting character 35% of the time, they actually hit 55% of the time.

Now I wonder: Is this a known bug? Was it ever fixed on DOS? If a bug goes undetected for 30 years, does that make it a feature? Do I have to get the amulet of Yendor with this -4 penalty to really win?

Jo

  • Protector of the @
  • *****
  • Posts: 1943
  • Joseph Bradshaw
    • View Profile
    • Email
Re: Bug in Rogue v1.1 for DOS?
« Reply #1 on: July 12, 2013, 04:45:49 AM »
No. Unsure. Yes. And yes.  ;)


Good find. As if the game weren't hard enough!

So if you've EVER in the game had your ISRUN set to false there's not getting back? You are forever getting hit more?

Or is it just never TRUE. Ever?

Fix it dude! Upload the .exe for me.   :-)
Klingon RL, Gunfist 7DRL, Cardlike 7DRL, Cardlike: Quest for the Goat Horn, Sun Crusher 7DRL, The Littlest Princess 7DRL and dozens of board and card games.

Xerxes314

  • Acolyte
  • *
  • Posts: 3
    • View Profile
Re: Bug in Rogue v1.1 for DOS?
« Reply #2 on: July 12, 2013, 05:46:47 AM »
I'm pretty sure that it's never true, though I couldn't find the initialization of the player's flags. It's possible they are all set to 0 using default initialization, which would also be a bug. Monsters have their ISRUN set true when they are set to chase the player. My testing always showed monsters getting the extra 20% hits even on a just-born character.

elwin

  • Priest
  • **
  • Posts: 95
    • View Profile
    • Roguelike Gallery
Re: Bug in Rogue v1.1 for DOS?
« Reply #3 on: August 12, 2013, 05:41:19 PM »
I took a close look at this.  Between Unix Rogue versions 3 and 4, the developers added the behavior where a +4 to-hit bonus is given to an attack on something with the ISRUN flag not set.  The ISRUN flag was originally set only for sleeping/held monsters, so the effect is that the player gets a bonus to hit sleeping monsters and the monsters get a bonus to hit the player all the time.

You're correct that the player's flags are initialized by default.  This isn't actually a bug because the player's attributes are global variables, which are guaranteed to be set to 0 if not explicitly initialized.  The Rogue devs used that fact a lot.

However, the player's ISRUN flag does get set to true in one circumstance: when the player wakes up from some kind of sleep.  I'm not sure why this is done.  I suspect the devs were trying to reuse the ISRUN flag for whether the player is allowed to move, as part of a rewrite of the turn system that never happened.  I verified that the flag does get set in Unix Rogue 5.4, and monsters did seem to hit the player less frequently.  But the flag doesn't stay set for long.  Several events, such as getting hungry, will unset it.

Monsters getting a bonus is probably not a bug.  The Rogue devs extensively tested the game, and I doubt they accidentally made it substantially harder than they intended.  I think setting the player's flag to true in some versions is a bug.  There's no sensible reason why the player should be harder to hit after reading a scroll of sleep, but only until getting hungry.  In fact, when Epyx made DOS Rogue 1.1, they deleted the line that sets the flag.

I probably will delete it from the versions I maintain too.  Thanks for pointing this out.
Roguelike Gallery: play Rogue online.  SSH or in browser.

darkmany

  • Guest
Re: Bug in Rogue v1.1 for DOS?
« Reply #4 on: October 03, 2013, 04:46:34 AM »
I think like Yes. And yes.  :o

Xerxes314

  • Acolyte
  • *
  • Posts: 3
    • View Profile
Re: Bug in Rogue v1.1 for DOS?
« Reply #5 on: October 03, 2013, 06:04:22 AM »
Elwin, sorry I missed your post. Thanks for checking this out. I think you might be mixed up about the hungry status affecting ISRUN in Unix v5.4. When I checked that part of the code, I concluded that ISRUN is only set to false when the player has fainted due to extreme starvation. That would match the expected behavior for conditions where the player is unconscious.

I don't suppose you have the source for my DOS version lying around somewhere? I'd love to check the exact code.