jkomoros / CASsim

Complex Adaptive Systems Simulator
Apache License 2.0
21 stars 0 forks source link

When sim is set, simOptions should be set to default #49

Closed jkomoros closed 2 years ago

jkomoros commented 2 years ago

Currently it's set to default, but within Simulator, so option-control doesn't render it, which makes it a pain to have to go in an add the optional/default properties and tweak those.

Instead, setSimPropertyInConfig should set it to DEFAULT_SENTINEL

jkomoros commented 2 years ago

... this is surprisingly nontrivial, because it has circular references between simulation.js and options.js.

Effectively right now we're late-binding that default value, but now we have to early-bind it earlier in the workflow.

jkomoros commented 2 years ago

OK, new plan. Factor out modfifiedConfigData to have the part where it does defaulting to be a function in the simulation.js package.

Simulation.cloneWithConfig grows simulation.cloneWithModification(path, value) which uses that sims config value, and can use the modifiedConfigData function

Remove setSimPropertyInConfig. Make sure that shadowedModificationsForSimIndex's behavior is at least tied in documentation to the new method in Simulation.js

jkomoros commented 2 years ago
jkomoros commented 2 years ago

I was just confused with how this works, if it has to load a new simulator. But then I remembered that we set the sim value, and then immedaitely try to set the deafult, but it fails, but that's OK, because the machinery notes that there's now another sim necessary and that isn't loaded. Then when it loads, the modification is run again and now the default is there.

So this does work, and should work even for simulators that aren't yet loaded.