I'm trying to write a program that can simulate different scenarios.
The model of the world is represented by various python objects, typically functions and classes. I want to retain both the original and new versions of the world.
Conceptually, I think I would like to define the world as it currently stands, then change bits about it, and simulate both.
For example, I'm expecting something like this:
import world
from simulator import simulate
from world_changer import change, copy_world
world0 = world
world1 = change(copy_world(world))
results0 = simulate(world0)
results1 = simulate(world1)
print results0, results1
The world typically will be a package as there's a lot going on in it, and classes within modules seems a natural way to represent a stateful process.
I really don't know if this is possible, or if I'm thinking about this in the right way.
Your question is very abstract, but dependency injection seems like a plausible alternative:
import world
from simulator import simulate
from sub_worlds import sub_world_0, sub_world_1
world0 = world.World(sub_world_0)
world1 = world.World(sub_world_1)
...
I'm trying to write a program that can simulate different scenarios.
The model of the world is represented by various python objects, typically functions and classes. I want to retain both the original and new versions of the world.
Conceptually, I think I would like to define the world as it currently stands, then change bits about it, and simulate both.
For example, I'm expecting something like this:
import world
from simulator import simulate
from world_changer import change, copy_world
world0 = world
world1 = change(copy_world(world))
results0 = simulate(world0)
results1 = simulate(world1)
print results0, results1
The world typically will be a package as there's a lot going on in it, and classes within modules seems a natural way to represent a stateful process.
I really don't know if this is possible, or if I'm thinking about this in the right way.
Your question is very abstract, but dependency injection seems like a plausible alternative:
import world
from simulator import simulate
from sub_worlds import sub_world_0, sub_world_1
world0 = world.World(sub_world_0)
world1 = world.World(sub_world_1)
...
0 commentaires:
Enregistrer un commentaire