## Creature Project ## CSC323 ## 4/17/10 ## Instruction.py: Initializes and packs instructions for Species. class Instruction(): def __init__(self, direction, species, coordinates=(0,0)): """The optional coordinates parameter is for the pack method.""" self.direction = direction self.species = species self.coords = coordinates def pack(self, coordinates): """Packs an instruction object with the coordinates given.""" self.coords = coordinates return Instruction(self.direction, self.species,\ (self.coords[0]+self.direction.x, self.coords[1]+self.direction.y)) def __str__(self): s = "Direction =" + str(self.direction) + "Species = " + str(self.species) + "Coords = (" + str(self.coords[0]) + ", " + str(self.coords[1]) + ")" return s def save_the_instruction(self): savedRule="\D" + str(self.direction) + "\S" +str(self.species) +"\C" + str(self.coords[0]) + "|" + str(self.coords[1]) return savedRule