Forum
Not sure what's going on here - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16)
+---- Thread: Not sure what's going on here (/showthread.php?tid=496)



Not sure what's going on here - britlion - 09-13-2012

My alien breeder program seems to lock up, on pass two through the data - on fight 27, too.

Not sure if this is a compiler error, or my messing up - though adding one to a dimensioned variable (the line it seems to stop on) shouldn't be too stressful.

Locks up on this bit:
Code:
print at 21,16;2
        alienRankings(i+1,SCORE)=alienRankings(i+1,SCORE)+1
    END IF
    print at 21,17,"+"

It prints the 2, and doesn't print the "+".

What I don't understand is why it locks up on the 3rd loop round? There's nothing different there, which is why I suspect there's a compiler error.


Re: Not sure what's going on here - boriel - 10-27-2012

I've been *TERA*busy these last days, sorry for the delay (it's been exhausting).
I've fixed another *nasty* bug (see this thread) that might be related to this one.
Please, could you check it and see if the program still crashes??

Update: It still crashed to me. :oops: Anyway, can you check if you see something different this time?
Still debugging...
Update II: apparently the problem lies within the fightAliens function. Removing these function (e.g. returning always 1), makes the program to work again.
Will investigate it further...


Re: Not sure what's going on here - boriel - 10-28-2012

Update III: After some more investigation, it seems it's a bug in your code.
The While condition:
Code:
while tempAlienStatBlocks(0,DHP) > 0 AND tempAlienStatBlocks(1,DHP) > 0
is always true for some reason. Printing these values within the loop shows they're 60 and 70 respectively. :?:


Re: Not sure what's going on here - britlion - 11-11-2012

boriel Wrote:Update III: After some more investigation, it seems it's a bug in your code.
The While condition:
Code:
while tempAlienStatBlocks(0,DHP) > 0 AND tempAlienStatBlocks(1,DHP) > 0
is always true for some reason. Printing these values within the loop shows they're 60 and 70 respectively. :?:

Aha!

Sorry. That was completely my cockup in debugging. Despite thinking I'd checked for a case of attack strength=0 it was coming through with one anyway - as a result, each alien was having their hit points reduced by 0 each round. And so neither was winning!


Kludged with: IF attackStrength=0 THEN attackStrength=1 : END IF

And it doesn't get stuck.

Edit: better yet, check for >= in the initial check, not > only! doh!