I have resolved to proceed with Option B from yesterday. This has many implications for the way the code is written. It requires a new Class, “Model”, that will run the simulation, and will include one method for each page. These methods can directly address the special needs of particular pages, such as the interdependent pages. However, it raises new problems regarding the method of calculating results. Some diagrams will clarify the issues. First, here’s a simple structure for the causality model for the simulation:
This structure may look complicated but it is simple to calculate because we simply start at the top and work our way down the tree, layer by layer. But it gets messier when we have to consider causality that doesn’t flow downward, such as in this case:
Again, we can still solve this problem by working from left to right on each layer. But here’s the killer problem:
This is the problem I have with the energy price feedback loop, where I have to use an iterative algorithm. It may crop up in other places as well. Again, I can apply the iteration to either the entire simulation (which runs the risk of hyperbolic behavior) or I can apply it to subsets such as the energy price system. At the moment I am inclined towards the first solution, as I think I can identify and control the likely sources of hyperbolic behavior — I’ve got a lot of experience dealing with hyperbolic systems.
Another issue, though, is the determination of this structure. After all, nowhere in the data structures do I directly declare this structure. The only relationships I declare are direct causal relationships. In other words, for every page, I specify the pages that are causal to it. From that, I can infer the effects of each page as well. But building the directed graph shown above from those is a more complex problem. Nevertheless, it can be solved, and so I shall work on that problem today.
I’m having the devil of a time figuring out the causal sequencing algorithm. All the pages start off in random order, and I need to come up with an ordering reflecting the causal sequence. In other words, pages with no causes (because their values are set by the player) should come first in the causal sequence, followed by pages whose causal factors consist solely of the first set of pages, and so on. Basically, every page should be below all the pages that constitute causal factors for that page. The final page, obviously, will then be the “Final Score” page. But this is messy because there are multiple causal factors for most pages. I have gone through a number of single-pass algorithms but I think I’ll need to use a multiple-pass algorithm. Yuck!