Hit a snag: "max recourse limit reached"

Developer discussion regarding MapTool 1.4

Moderators: dorpond, trevor, Azhrei

Forum rules
Posting now open to all registered forum users.
User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Hit a snag: "max recourse limit reached"

Post by aliasmask »

Do you have a simple visual sample. Ie 10x10 grid with 2 rooms. So, you pick a random spot inside one room and then try to find another room and whatever path you created to find that path is the corridor? How do you not cross your own path and determine when you're in a room?

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Hit a snag: "max recourse limit reached"

Post by Full Bleed »

Craig wrote:I have created the following changes that will go into the next build.
Nice. I'll be able to revisit how I wanted to use my spell library after bumping into the loop limit a while back.

I'm sure people will start taxing tables as a database more as well, so this is a well timed upgrade.

Thanks.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Hit a snag: "max recourse limit reached"

Post by aliasmask »

Full Bleed wrote:
Craig wrote:I have created the following changes that will go into the next build.
Nice. I'll be able to revisit how I wanted to use my spell library after bumping into the loop limit a while back.

I'm sure people will start taxing tables as a database more as well, so this is a well timed upgrade.

Thanks.
I plan on revisiting some old code and making some updates to take advantage of these new functions. PF spell library is one and the lib:players is another.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Hit a snag: "max recourse limit reached"

Post by wolph42 »

aliasmask wrote:Do you have a simple visual sample. Ie 10x10 grid with 2 rooms. So, you pick a random spot inside one room and then try to find another room and whatever path you created to find that path is the corridor? How do you not cross your own path and determine when you're in a room?
60x60 grid multiple rooms.
I donca't re that they cross
Determine by simple json.intersection(roomCoords, coord)
Coords A re stored as an array of objects: {x:2,y:3}

O and I ironed out all the bugs and now I hit the recursion limit once more...

edit: updated the recursive function to count its recursions and kill the thread when it hits 90 (that is: return empty corridor to parent). Its now running for a couple of minutes... curious what the result will be. I'm guessing that if I made some fundamental wrong assumption this routine will probly run for hours without getting to a result (in the end all direction have been tested and the routine will kill itself).

edit: 10 minutes, no corridors...sigh...

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Hit a snag: "max recourse limit reached"

Post by wolph42 »

IT WORKS !!! <SENSORED> that was a real pain in the but. I made far mistakes than I expected (...? duh!).
@AM: thanks for the tip to test it in a 10x10 with 2 rooms.

Now a couple of challenges remain:
- for some reason with some corridors I'm missing one coord (first or final one), really weird as ALL corridors are of odd length (Edit: fixed)
- although now all rooms are connected to at least one room, its still possible two have separate sections. These still need to be 1. detected, 2, connected
suggestions are welcome.

User avatar
Venatius
Dragon
Posts: 256
Joined: Mon Feb 16, 2009 7:12 pm

Re: Hit a snag: "max recourse limit reached"

Post by Venatius »

I hope this rather noobish question is forgivable, but does this change anything regarding the maximum level of nested if-statements? That's been a thorn in my side from time to time.

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Hit a snag: "max recourse limit reached"

Post by aliasmask »

Venatius wrote:I hope this rather noobish question is forgivable, but does this change anything regarding the maximum level of nested if-statements? That's been a thorn in my side from time to time.
Unfortunately not. But Craig was asking about things to update and I'll bring this one up.

User avatar
Venatius
Dragon
Posts: 256
Joined: Mon Feb 16, 2009 7:12 pm

Re: Hit a snag: "max recourse limit reached"

Post by Venatius »

aliasmask wrote:
Venatius wrote:I hope this rather noobish question is forgivable, but does this change anything regarding the maximum level of nested if-statements? That's been a thorn in my side from time to time.
Unfortunately not. But Craig was asking about things to update and I'll bring this one up.
I'd really appreciate that, thank you! I sometimes hit that problem because I'm coding inelegantly, but there are times when it really does come down to needing just one more layer of IF than I can get, which leaves me groping for workarounds. I love scripting in MT but that has always been my chief complaint.

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Hit a snag: "max recourse limit reached"

Post by aliasmask »

One thing I do when I need that 3rd level and it's an if statement is just write it out with the same condition multiple times without using the code, ie

Code: Select all

code: {
   code: {
      if(condition): true; false
      if(condition): true; false
   }
}
If you're dealing with loops then using a UDF for the guts of the problem where it shares the scope is a good way to handle it as well.

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: Hit a snag: "max recourse limit reached"

Post by Jagged »

Or follow the link in Wolph42's signiture
Working_With_Two_CODE_Levels


User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Hit a snag: "max recourse limit reached"

Post by wolph42 »

Craig wrote:I have created the following changes that will go into the next build.

Increased max recursion depth by 50% (to 150).
Increased max loop iterations to 10,000
Added the following macro functions to query/set parser properties.
  • getMaxRecusionDepth()
  • getRecursionDepth()
  • getMaxLoopIterations()
  • setMaxRecusionDepth(<value>)
  • setMaxLoopIterations(<value>)
  • getMacroContext() -- Returns information about the source, name, index of the button of the macro being executed as a JSON object.
Some notes/things to keep in mind.
  • The recursion depth of the parser is not quite straight forward, there are actually two different recursion depths that track two different types of recursive call, you can have up to 150 of each, the getRecursionDepth() will return the greater of the two levels.
  • Small increases in max recursion depth can cause stack problems (that is why I didn't increase it more than 50).
  • If you change the Max Loop Iterations or the Max Recursion Depth it only lasts until you restart MapTool, its not saved to the campaign or MapTool settings.
  • You can not use either of the set functions to set the levels below the default values (because allowing you to do so could really screw things up if you have a bug and set it very low). You can use this fact to reset to default values with setMaxRecursionDepth(0), setMaxLoopIterations(0).
added to the wiki.

Post Reply

Return to “MapTool 1.4”