[r109] Recursion bug

Bugs will be moved here once resolved.

Post » Fri Nov 09, 2012 7:40 pm

Hi,
I've been playing around with recursion to test the new function feature.
Building a simple factorial function works fine
Code: Select all
+Function: On "factorial"
    + Function: parameter 0 > 1
        -> return Function.Param(0)*Function.Call("factorial",Function.Param(0)-1)
    + Else
        -> return 1


But then I wanted to test a recursive backtrack for generating a 2D maze.
And there's a js bug.

So here's the capx (it's the dig() function)
maze.capx

Also, when you change global/local variable names, the parameters in the function call don't get updated, I ended up with a crash and an invalid capx at some point.

Also, parameter 0 > 1 feels weird somehow, maybe parameter[0] or parameter(0) would be betterYann2012-11-09 19:41:38
Last edited by Yann on Sun Sep 14, 2014 8:52 pm, edited 2 times in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Nov 10, 2012 3:16 pm

I think this is fixed in the next build (same issue as other thread). I also fixed the fact local non-static variables would share their values across all levels of recursion, like global variables - from the next build now their values also work independently in each call.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sat Nov 10, 2012 3:24 pm

cool thanks (:
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to Closed bugs

Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests