Houdini - A solver is a reduce function
A solver is essentially a reduce function. It’s passed, as its first argument, the result of the previous loop’s evaluation.
A reduce function in Javascript:
const array1 = [1, 2, 3, 4];
function reducer(accumulator, currentValue) { return accumulator + currentValue } ;
result = array1.reduce(reducer) //=> 10
Inside a solver:
As an example, we create a network with a single attribute @num = 0
and pass it into the solver.
Inside the solver
network, all we do is add +1
to the @num
attribute and return it:
The Wrangle has the code:
@num = @num + 1; // Or simply "@num += 1"
So, on each frame, the solver is passed the result of the previous frame, adds 1
to it and returns it to the next iteration.
And we end up with this:
Note
The “activated” node inside a
solver
network is the “return value” of the function. Activating thePrev_Frame
node means the function always evaluates to the very first initial argument that was passed into it – in this case,@num == 0
always.