##This file is used to create the necessary components for Conway's Game of Life. ##Species, rules, and worlds are created from LocalWorld import LocalWorld from Predicate import * import Direction from Species import Species from Instruction import Instruction from ConflictResolutionPolicy import ConflictResolutionPolicy from Rule import Rule #make species ConwaySpec = Species("Conway", "lime green") DeadSpec = Species("Dead","grey") #make world testWorld = LocalWorld(6,6,DeadSpec) #make predicates comeAlive1 = QuantityPredicate(ConwaySpec, 2) comeAlive2 = QuantityPredicate(ConwaySpec, 3) comeAlive = OrPredicate([comeAlive1,comeAlive2]) becomeDead = NotPredicate(comeAlive) #make instructions live = Instruction(Direction.C,ConwaySpec) die = Instruction(Direction.C,DeadSpec) #make rules rule1 = Rule(comeAlive,[live]) rule2 = Rule(becomeDead,[die]) ConwaySpec.addRule(rule1,0) DeadSpec.addRule(rule1,0) ConwaySpec.addRule(rule2,1) DeadSpec.addRule(rule2,1) #make strength dictionary testWorld.conflictResolver.addPolicy(ConwaySpec,DeadSpec,1) #add testing species testWorld.setSpecies(2,2,ConwaySpec) testWorld.setSpecies(3,3,ConwaySpec) print(testWorld) testWorld.step() print(testWorld) testWorld.step() print(testWorld)