from LocalWorld import LocalWorld import Direction from Species import Species from Instruction import Instruction from ConflictResolutionPolicy import ConflictResolutionPolicy from Rule import Rule from Predicate import * ###NOTE: New tests should probably go in UnitTests.py### ###These tests are old (although they still work)### #make species dead = Species("dead","black") squirrel = Species("squirrel","red") cow = Species("cow", "white") #make world testWorld = LocalWorld(6,6,dead) #make predicate testPred = DirectionalTestPredicate(dead,Direction.NW) testPred2 = DirectionalTestPredicate(squirrel, Direction.N) testPred3 = DirectionalTestPredicate(squirrel, Direction.S) testPred3 = NotPredicate(testPred3) #make instruction testInstruc1 = Instruction(Direction.W,squirrel) testInstruc2 = Instruction(Direction.C,dead) testInstrucList = [testInstruc1, testInstruc2] cowInstruct1 = Instruction(Direction.NW, cow) cowInstruct2 = Instruction(Direction.C, dead) cowInstructList = [cowInstruct2, cowInstruct1] testInstruc3 = Instruction(Direction.SW, squirrel) r2instructList = [testInstruc3] #make and add rule ##if dead to left, then move left testRule = Rule(testPred,testInstrucList) squirrel.addRule(testRule,1) testRule2 = Rule(testPred3, r2instructList) squirrel.addRule(testRule2,0) cowRule = Rule(testPred2, cowInstructList) cow.addRule(cowRule,0) #make strength dictionary testWorld.conflictResolver.addPolicy(cow,squirrel,1) testWorld.conflictResolver.addPolicy(cow, dead, 1) testWorld.conflictResolver.addPolicy(squirrel,dead,1) #add species testWorld.setSpecies(4,2,squirrel) testWorld.setSpecies(4,3,cow) testWorld.setSpecies(3,2,cow) #step world print(testWorld) #4,3 cow should move into 3,2 cow and disappear #4,3 should now be dead #4,2 squirrel should make a new squirrel in 3,3 testWorld.step() print(testWorld) #new squirrel should be made in 2,4 testWorld.step() print(testWorld)