Recursion in Hugo

Discuss text adventures here! The classics like those from Infocom, Magnetic Scrolls, Adventure International and Level 9 and the ones we're making today.

Moderators: AArdvark, Ice Cream Jonsey

User avatar
Ice Cream Jonsey
Posts: 28879
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Recursion in Hugo

Post by Ice Cream Jonsey »

I had some code that was like this:

location DoUrinate
{
Perform(&DoUrinate, hole01)
}

hole01 was in the room. Basically, One of the Bruces typed >piss in hole

That caused the game to crash, as the above forms a loop. An endless loop!

This was meant to be a blog post, but I have a billion things to do before my brother's inexplicable wedding, not the least of which is using the word inexplicable in most posts.

Thanks, Bruce.
the dark and gritty...Ice Cream Jonsey!

User avatar
Flack
Posts: 8822
Joined: Tue Nov 18, 2008 3:02 pm
Location: Oklahoma
Contact:

Post by Flack »

Maybe he just had to piss really bad!

Like, really, really, really bad.

Like ...

10 print "really, "
20 goto 10

... bad.
"I failed a savings throw and now I am back."

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Re: Recursion in Hugo

Post by Tdarcos »

Ice Cream Jonsey wrote:I had some code that was like this:

location DoUrinate
{
Perform(&DoUrinate, hole01)
}

hole01 was in the room. Basically, One of the Bruces typed >piss in hole

That caused the game to crash, as the above forms a loop. An endless loop!

This was meant to be a blog post, but I have a billion things to do before my brother's inexplicable wedding, not the least of which is using the word inexplicable in most posts.

Thanks, Bruce.
Actually, you're lucky it's a subroutine call, this uses memory for the stack frame and makes the game (eventually) use all available memory. If it was a branch it would just hang.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Trap Code

Post by Tdarcos »

Tdarcos wrote:
Ice Cream Jonsey wrote:That caused the game to crash, as the above forms a loop. An endless loop!
Thanks, Bruce.
Actually, you're lucky it's a subroutine call, this uses memory for the stack frame and makes the game (eventually) use all available memory. If it was a branch it would just hang.
I have a method I use - I'm writing a cross-reference for Pascal Programs, something that has been really weak compared with what was available back on mainframe compilers - is a "trap code". Any place where something is happening, a global variable called TrapCode is set to 0 the first time it is entering an area. Every time it passes through the critical area, TrapCode is incremented. If it's not supposed to get more than, say, 5 or 6 loops I'll set the check on TrapCode so that if it reaches 50, it raises a flag that causes it to print a message and pause until ENTER is pressed, allowing me to see when a runaway program occurs.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

Flack wrote:Maybe he just had to piss really bad!

Like, really, really, really bad.

Like ...

10 print "really, "
20 goto 10

... bad.
"I'd give a million dollars just to be able to take a piss without it hurting."
- Hyman Roth, The Godfather, Part 2
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

Post Reply