I am in the process of trying to build a DC circuit simulator similar to the excellent one available at phet.colorado.edu. In order to make it work, I will need to do some matrix manipulations, specifically, computing the inverse of a matrix of size n x n and matrix multiplication.
Has anyone attempted to do this in Construct 2?
Methinks an extension to the Array plugin would be really cool...
So I've tried the following so far to recursively compute an array determinant:
1. I've created an object called "array" in the layout. On start of layout I set all of the values for each XY.
2. Each time I call the "computedeterminant" function, I create a new, smaller array of (n-1) x (n-1) for the next step in the recursion.
3. My plan was to pick a value from the smaller array, set it to a temporary variable, then plug that value into the bigger array.
It looks like my smaller arrays aren't getting filled properly because I can't pick the original by UID.
I smell a job for the hound
Picking problem is solved with the "System -> Pick All" condition. Thank you Yann for the excellent picking video!
On to other troubleshooting...
Develop games in your browser. Powerful, performant & highly capable.
The determinant is now computed correctly. The problem appears to be that loopindex("x") is in the global scope. In other words, if you recursively call a function with for() loops in it, it will always reference the first time you called a loop of that name. The solution was to uniquely identify the loop with a different name in each iteration.
In this case, instead of calling a for() loop with the tag "i", I called the for loop with the tag "i"&n, where n is the current size of the matrix I am working with. This is unique for each level of the recursion.
See the attached image for the solution.
Ashley, is recursion supposed to work this way? Or am I missing something?