Well, I can believe I fucked up this badly

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

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

Well, I can believe I fucked up this badly

Post by Tdarcos »

Every, every, every time I trust a program, that I think it works, and works correctly, I get fucked in the ass, big time. I'm working with a word processor that's very reliable, and don't frequently save, then it locks up, freezes or dies, and I lose everything since I opened the file. I use Inkscape to do an image, or Trimble Sketchup to do a 3-D image, and don't save frequently, and something goes wrong and I can't get back to a good state, so I have to go back to wherever it was hours before. I lose all the work I did and have to start over from where it was saved.

I make the mistake of trusting programs that when they consistently work great for long periods of time that they won't come back and savage me. And every time I do, they come back and smash me, and smash me, over and over. What's worse is I keep forgetting to mistrust every program and presume it will fuck me up if it can. And extra points if it can really fuck me in the ass good.

And I let myself get sodomized yet again.

This program - Tripkey - got bigger as I fleshed it out, but at one point the compilation time hugely ballooned from about 1 or 2 seconds to 12-14. Well, I got used to that, something I'm doing is causing more work.

Well, anyway, I know that sometimes you can do something that essentially locks up the compiler, and for that reason, I should have known that when I have a version that compiles okay, I must checkpoint those sources and create a backup copy at that point before doing anything else. But, stupido Paulie, fat and lazy, doesn't bother to create a secondary set of frozen sources, then does changes. I wanted to add a score for taking the gate ticket. In this case, it meant adding one constant, copying a piece of code to insert a score for the get command on the ticket object, adding an additional string constant for this item, and one extra array element for the score.

A change of about 30 lines, mostly cut and paste of code used elsewhere, and it locks up the compiler; it still doesn't finish after two minutes. But, El Stupido didn't bother to checkpoint his code from when it was in working condition. So, first, I've got to comment-out the new code I added so that it will compile successfully, then I need to checkpoint this, then add one item at a time until I find which one is causing the compiler to freeze.

But I shall endeavor to say that I won't make this mistake again. And I'll probably get in a comfort zone, be working along with a program and get used to perfection and then get slammed in the balls with a 40 ounce sledge again.
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 »

Apparently, this construct locks up things (note, the array size is 20):

Code: Select all

	scores_Points[1] = 4,	! 1 Water
		 1,		!  2 Breaker
		 2,		!  3 AC on
		 3,		!  4 Sleep
		 1,		!  5 Test
		 4,		!  6 Elevator
		 2,		!  7 Closet
		 3,		!  8 Roof
		 5,		!  9 Smash
		 1,		! 10 Fan
		25,		! 11 Shower
		 2,		! 12 Flush	
		15,		! 13 Coffee
		 5,		! 14 Wash
		 8,		! 15 Plug 
		 5,		! 16 Office			
		 4 		! 17 Ticket
But this does not (adding an extra 0 at the end):

Code: Select all

	scores_Points[1] = 4,	! 1 Water
		 1,		!  2 Breaker
		 2,		!  3 AC on
		 3,		!  4 Sleep
		 1,		!  5 Test
		 4,		!  6 Elevator
		 2,		!  7 Closet
		 3,		!  8 Roof
		 5,		!  9 Smash
		 1,		! 10 Fan
		25,		! 11 Shower
		 2,		! 12 Flush	
		15,		! 13 Coffee
		 5,		! 14 Wash
		 8,		! 15 Plug 
		 5,		! 16 Office			
		 4,		! 17 Ticket
		 0
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

Roody_Yogurt
Posts: 2179
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

It seems most likely that you have some code that looks for a value at scores_Points[18] that is choking when nothing is there. Still strange, though.

Anyhow, I'd compile a debuggable executable and run the game in the debugger. The debugger will often stop the program when such nonexistent references happen, which will help you track it down.

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

Post by Tdarcos »

Roody_Yogurt wrote:It seems most likely that you have some code that looks for a value at scores_Points[18] that is choking when nothing is there. Still strange, though.

Anyhow, I'd compile a debuggable executable and run the game in the debugger. The debugger will often stop the program when such nonexistent references happen, which will help you track it down.
You're misunderstanding me. (1) The compiler is locking up when the program is being compiled, not when the program is running (2) This construct simply sets values, if the program's code referenced scores_Points[18] it would return the uninitialized value of 0. Remember, I said the array is defined as scores_Points[20] so, even were I referencing element 18 - which I know I'm not - it should not make any difference, if I was going above the dimensions of the array, either the compiler should flag it as an access to an array out of bounds (which it isn't), or the compiler should return the 18th element, which would be zero.

This is a bug in the compiler, clear and simple. I am accessing an array and by not putting an extra array reference on the statement filling some of the elements of the array it is causing the compiler to lock up into "never, never land."
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

Roody_Yogurt
Posts: 2179
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

Really? I just compiled a game with that code with no problem. My point is, your bug is somewhere else.

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

Post by Tdarcos »

Roody_Yogurt wrote:Really? I just compiled a game with that code with no problem. My point is, your bug is somewhere else.
Well, it's tying into this. Put the extra 0 in, and it causes the compile to work okay; take it out and the compiler locked up. So if this ain't the cause I have to believe it's related. Or it could be that this and something else fixed the problem. But I will try taking the extra 0 out and see if anything changes.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

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

Post by Ice Cream Jonsey »

Paul, my guess is that you have another array declared elsewhere in the program that is being overrun. When you add a 0 to that array, it just so happens that what the first array accesses is now an element of an array, so it at least compiles. Can you post all the other arrays in your game? I'll check to see if any have more values than what you've declared.
the dark and gritty...Ice Cream Jonsey!

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

Post by Tdarcos »

Ice Cream Jonsey wrote:Paul, my guess is that you have another array declared elsewhere in the program that is being overrun. When you add a 0 to that array, it just so happens that what the first array accesses is now an element of an array, so it at least compiles. Can you post all the other arrays in your game? I'll check to see if any have more values than what you've declared.
I suppose. The problem is not recurring now. The program compiles ok.

Code: Select all

! Tripkey attributes.hug
array scores[20]							! The different scores that have been used
array scores_names[20]					! and their names
array scores_Points[20]					! and the points for each item

! These are also defined in Scorelist.txt
constant Score_Drink_Water	1
constant Score_Off_Breaker	2
constant Score_On_AC		3
constant Score_Sleep_Bed		4
constant Score_Test_SmokeD	5
constant Score_Use_Elevator	6
constant Score_Lv_Closet		7
constant Score_Visit_Roof		8
constant Score_Smash_TV		9
constant Score_Bath_Fan_On	10
constant Score_Take_Shower	11
constant Score_Flush_used		12
constant Score_Coffee		13
constant Score_Wash_Hands	14
constant Score_Plug_Vending	15
constant Score_CM_Office		16
constant Score_Take_Ticket		17
constant Score_Use_Rev_Door	18

! From Tripkey.hug (in routine Init)
	Scores_Names[1] ="Drink Water",
		"Turn a breaker off",
		"Start AC after turning it off",
		"Sleep in the bed",
		"Test smoke detector",
		"Use an elevator",
		"Come out of the closet",
		"Go Up the Ladder to the Roof",
		"Turn TV on, then smash it",
		"Turn Bathroom Fan on",
		"Take a shower",
		"Flush a toilet or urinal after we used it",
		"Purchase a cup of coffee and drink it",
		"Wash hands",
		"Plug vending machine in",
		"Get into Casino Manager's office", 
		"Take ticket",
		"Use revolving door",
		""
		
	scores_Points[1] = 4,	! 1 Water
		 1,		!  2 Breaker
		 2,		!  3 AC on
		 3,		!  4 Sleep
		 1,		!  5 Test
		 4,		!  6 Elevator
		 2,		!  7 Closet
		 3,		!  8 Roof
		 5,		!  9 Smash
		 1,		! 10 Fan
		25,		! 11 Shower
		 2,		! 12 Flush	
		15,		! 13 Coffee
		 5,		! 14 Wash
		 8,		! 15 Plug 
		 5,		! 16 Office			
		 4,		! 17 Ticket
		 5,		! 18 Door
		 0
	


! from Tripkey.h
! Examples of how they're used verb is "wash" 
! options are nothing or "hands"

routine DoWash		! wash or Wash hands 
{
local obj

	! find the sink here
	for obj in location
	{
		if obj.type = watersupply
		{
			print "You ";
			if obj is not open
				print "turn the water on, ";
			print "wet your hands, apply soap, scrub, and rinse. You use the auto
				dryer to dry them off. Your hands are now clean, dry and 
				sanitary. You turn the water off."
			obj is not open
			obj is not switchedon
			if scores[Score_Wash_Hands]=0
			{
				Print "Your cleanliness does not go unrewarded.  You get ";
				print number Scores_Points[Score_Wash_Hands]; " point";
				if Scores_Points[Score_Wash_Hands]>1 
					print "s";
				print "."
				score += Scores_Points[Score_Wash_Hands]	! Score Code S14
				scores[Score_Wash_Hands]=1			! Score only once
				PrintStatusLine
			}
			return true
		}
	}
	print "You need a sink to wash in.  There isn't one here."
	return true
}

routine DoScoreNames
{
local I, YourTotal, ScoreTotal
	I = 1
	print "Task  Point Your  Task"
	Print "Done? Value Count Name"
	while Scores_Names[I] ~=""
	{
		print "\_ ";
		if scores[i]=0
			print "NO  ";
		else
			print "YES ";
		print "  ";
		if scores_points&#91;I&#93; < 10 
			print " ";
		print number Scores_Points&#91;I&#93;;
		ScoreTotal += Scores_Points&#91;I&#93;
		print "    ";
		if scores&#91;i&#93;=0
			print "    ";	
		else
		&#123;
			if Scores_Points&#91;I&#93;<10
				print " ";
			print number Scores_Points&#91;I&#93;;
			YourTotal += Scores_Points&#91;I&#93;			
			print "  ";
		&#125;
		print Scores_Names&#91;I&#93;
		I++
	&#125;
	print "\nTotal  ";
	if scoretotal <100
		print " ";
	if scoretotal <10
		print " ";
	print number ScoreTotal;"   ";
	if yourtotal <100
		print " ";
	if yourtotal <10
		print " ";
	print number YourTotal	
	
&#125;
Simple point, in no case am I going above the 20th element of the array. I'm using the standard rule: avoid using manifest constants, use defined constants.

Here's how the game looks when it starts:

Code: Select all

Paul Robinson's 'Tripkey'
An Interactive Fiction Game from Viridian Development Corporation

Written by Paul Robinson 09/09/2012, released by Viridian Development Corporation 10/10/2012.
IFID&#58;  B3489732-AA18-4B1B-8516-217BAFF81DDB

Hugo v3.1 / Library 31031
Game Version 0.30 of October 10, 2012
Copyright 2012 by Viridian Development Corporation. Released under version 2 of the GNU 
Public License.



If you need assistance, type HELP


You're in the control center
  You can go in any of the twelve directions from here.
  A smoke detector with a test button, a 34" LCD HD-TV mounted on the wall, and a room map 
attached to the wall are here.

>scores
Task  Point Your  Task
Done? Value Count Name
  NO     4        Drink Water
  NO     1        Turn a breaker off
  NO     2        Start AC after turning it off
  NO     3        Sleep in the bed
  NO     1        Test smoke detector
  NO     4        Use an elevator
  NO     2        Come out of the closet
  NO     3        Go Up the Ladder to the Roof
  NO     5        Turn TV on, then smash it
  NO     1        Turn Bathroom Fan on
  NO    25        Take a shower
  NO     2        Flush a toilet or urinal after we used it
  NO    15        Purchase a cup of coffee and drink it
  NO     5        Wash hands
  NO     8        Plug vending machine in
  NO     5        Get into Casino Manager's office
  NO     4        Take ticket
  NO     5        Use revolving door

Total   95     0

Only need to pick one more task - of 5 points - to give the player 100 points. I might pick something else. Or I might set the game at 95, who knows.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

Post Reply