Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : Development : The numbers of loop detection
New Topic New Poll Post Reply
Poster Message
averagemoe
Level: Smiter
Avatar
Rank Points: 487
Registered: 03-22-2012
IP: Logged
icon The numbers of loop detection (+1)  
Because I was bored, I decided to test out the exact point when DRODscript decides that too many commands have been executed.

I made a script with 3 commands, a label, a command that adds 1 to a variable, and a GoTo that resets the whole thing.

And it ends up at 10001. The loop was 3 commands long, so it did a total of 30003 commands, give or take two, before giving up.

Now, I may not be a computer scientist, but that's a suspiciously large number.

____________________________
There are two types of sheep in the world. Those who jump off a bridge when told to, and those who jump off a bridge when told not to. Don't be either.
08-15-2020 at 05:38 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Rabscuttle
Level: Smitemaster
Avatar
Rank Points: 2460
Registered: 09-10-2004
IP: Logged
icon Re: The numbers of loop detection (+3)  
There's a 10,000 limit on the number of "set variable" commands you can make, which is what you're hitting here.

The other fail condition is if you go through enough commands without hitting a "set variable" command - I think it's the length of the script. Then you're going to be at a point where you already were with no change in conditions, so you're in an infinite loop.

[Last edited by Rabscuttle at 08-15-2020 05:55 AM]
08-15-2020 at 05:54 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
hyperme
Level: Smitemaster
Avatar
Rank Points: 1062
Registered: 06-23-2006
IP: Logged
icon Re: The numbers of loop detection (+4)  
Rabscuttle is right - if you look at the Character source code, you can see that a script is stopped after it runs more commands that it contains without changing a variable, or after 10000 variable changes.

Also, there's nothing "suspicously large" about the number of variable changes you can make. In fact, for a 32-bit application, 10000 is pretty small. You could easily bump the number up to a billion if you wanted. I suspect the limit chosen is mostly arbitary, with a preference to towards a small value for performance reasons. While a room full of counter NPCs won't lag much, more complex NPCs can.

____________________________
[Insert witty comment here]
Qzvlkx?

[Last edited by hyperme at 08-26-2020 02:54 PM]
08-26-2020 at 02:53 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : Development : The numbers of loop detection
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.