Reversed the order of the creature compute dependency graph traversal

By doing this the traversal happens mostly in tree order, which is a 
better assumption of starting point in cases where there are dependency 
loops
This commit is contained in:
Stefan Zermatten
2022-02-26 14:58:38 +02:00
parent 7ee4a22d77
commit 653f05012a

View File

@@ -13,6 +13,12 @@ export default function computeCreatureComputation(computation){
node._visitedChildren = false;
stack.push(node)
});
// The graph nodes in the stack are ordered, by reversing the order we
// compute higher nodes in the tree first, which for dep loops is more likely
// to be a good guess of where to start thant the inverse
stack.reverse();
// Depth first traversal of nodes
while (stack.length){
let top = stack[stack.length - 1];