import Menu import BoardSetup import BoardScreen import sys sys.path.append('../model') from Predicate import * from SpeciesDatabase import * def menuTest(): Menu.run() def screenTest(): BoardScreen.run(10, 10, None, "White", None, None) def setupTest(): BoardSetup.run() def test(): from LocalWorld import LocalWorld import Direction from Species import Species from Instruction import Instruction from ConflictResolutionPolicy import ConflictResolutionPolicy from Rule import Rule #make species dead = Species("dead","grey") squirrel = Species("squirrel","red") bear = Species("bear","blue") sam = Species("sam","purple") ravi = Species("ravi","yellow") tree = Species("tree", "green") #make world testWorld = LocalWorld(6,6,dead) #make predicate testPred = DirectionalTestPredicate(dead,Direction.W) #make instruction testInstruc1 = Instruction(Direction.E,squirrel) testInstruc2 = Instruction(Direction.C,dead) testInstrucList = [testInstruc1, testInstruc2] #make and add rule ##if dead to left, then move left testRule = Rule(testPred,testInstrucList) squirrel.addRule(testRule,0) #make strength dictionary testWorld.conflictResolver.addPolicy(squirrel,dead,1) #add species testWorld.setSpecies(4,2,squirrel) sd = SpeciesDatabase.getInstance() sd.addSpecies(squirrel.kind, squirrel) sd.addSpecies(dead.kind, dead) sd.addSpecies(bear.kind, bear) sd.addSpecies(sam.kind, sam) sd.addSpecies(ravi.kind, ravi) sd.addSpecies(tree.kind, tree) BoardSetup.run(sd=sd) def test2(): from LocalWorld import LocalWorld import Direction from Species import Species from Instruction import Instruction from ConflictResolutionPolicy import ConflictResolutionPolicy from Rule import Rule #make species ConwaySpec = Species("Conway", "green") DeadSpec = Species("Dead","grey") SamSpec = Species("Sam", "blue") #make world testWorld = LocalWorld(6,6,DeadSpec) #make predicates two = QuantityPredicate(ConwaySpec, 2) three = QuantityPredicate(ConwaySpec, 3) 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) comeToLife = Rule(three,[live]) liveRule = Rule(OrPredicate([two,three]), [live]) dieRule = Rule(NotPredicate(OrPredicate([two, three])), [die]) #make rules ConwaySpec.addRule(liveRule, 1) ConwaySpec.addRule(dieRule, 0) DeadSpec.addRule(comeToLife, 1) sd = SpeciesDatabase.getInstance() sd.addSpecies(DeadSpec.kind, DeadSpec) sd.addSpecies(ConwaySpec.kind, ConwaySpec) BoardSetup.run(sd=sd) testWorld.conflictResolver.addPolicy(ConwaySpec, DeadSpec, 1)