okennedy / worldtree

A simple procedural hierarchical world generator
0 stars 0 forks source link

Recursive properties recur too far #5

Open okennedy opened 10 years ago

okennedy commented 10 years ago

saruman:WorldTree xthemage$ ./bin/wt -c sample/test/reachability.properties sample/test/reachability6.definitions Time taken to create skeleton :6.476ms Time taken to fill entire map :2.115ms Exception in thread "main" java.lang.StackOverflowError at java.util.HashMap$Entry.(HashMap.java:814) at java.util.HashMap.createEntry(HashMap.java:901) at java.util.HashMap.addEntry(HashMap.java:888) at java.util.HashMap.put(HashMap.java:509) at java.util.HashSet.add(HashSet.java:217) at internal.parser.resolve.constraint.ConstraintSolver.validateDefinition(ConstraintSolver.java:125) at internal.parser.resolve.constraint.ConstraintSolver.validateDefinition(ConstraintSolver.java:139) at internal.parser.resolve.constraint.ConstraintSolver.validateDefinition(ConstraintSolver.java:139) at internal.parser.resolve.constraint.ConstraintSolver.validateDefinition(ConstraintSolver.java:139) at internal.parser.resolve.constraint.ConstraintSolver.validateDefinition(ConstraintSolver.java:139) at internal.parser.resolve.constraint.ConstraintSolver.validateDefinition(ConstraintSolver.java:139) at internal.parser.resolve.constraint.ConstraintSolver.validateDefinition(ConstraintSolver.java:139) ... repeats several dozen times ...

gurupras commented 10 years ago

I can tell why this is happening..but I'm not entirely sure about how to solve it. The definition is a recursive definition that has no end condition. Currently, the solver considers ‘DEFINE’ {LEVEL} {REF}.’ {PROPERTY} ‘AS’ ‘RANDOM’ {RANDOMSPEC} ‘WHERE’ {COND}` as the simplest definition which I believe is used to terminate definitions with dependencies. In this case, there is no such termination condition and therefore the stack overflow.

This is a very intriguing definition..I'm not sure what the correct output should be.

okennedy commented 10 years ago

My intuition is that the answer will involve NULLs in some form or another. Something like IF TE.NULL THEN ELSE TE.reachable