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 ###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") #make world testWorld = LocalWorld(6,6,dead) #make predicate testPred = QuantityPredicate(squirrel, 2) testPred2 = QuantityPredicate(squirrel, 3) #make instruction testInstruc1 = Instruction(Direction.W,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) testRule2 = Rule(testPred2, testInstrucList) squirrel.addRule(testRule2, 1) #make strength dictionary testWorld.conflictResolver.addPolicy(squirrel,dead,1) #add species testWorld.setSpecies(3,2,squirrel) testWorld.setSpecies(4,3,squirrel) testWorld.setSpecies(3,4,squirrel) #step world print(testWorld) #4,3 squirrel should move to left (4,3 is now dead) testWorld.step() print(testWorld) #3,3 squirrel should move to left (3,3 is now dead) testWorld.step() print(testWorld) #2,3 squirrel should move left (2,3 is now dead) testWorld.step() print(testWorld) #Nothing should happen testWorld.step() print(testWorld)