## Creature Project ## CSC323: Group 1: Nora, Terian, Josh, and Jordan ## 4/7/10 ## DirectionalTestPredicate.py: Contains test for neighbors in a certain direction. ###Borrowed code from Group 0 from Predicate import * from enum import Direction class DirectionalTestPredicate(TestPredicate): """compares the state of the creature at direction desiredNum to desiredSpecies""" def holds(self, world, location): x = location[0] + self.desiredNum[0] y = location[1] + self.desiredNum[1] creat = world.getCreature(x, y).getSpecies() if creat == None: return False elif self.desiredSpecies == None: return True return creat == self.desiredSpecies def __str__(self): return ''.join("(DIRECTION",' '.join((k.__str__():v.__str__() for \ k, vin self.desiredState)), ")")