def test_cell_export_to_dictionary(self): c1 = SquareCell(self.rule) c1.position = (23, 47) c2 = SquareCell(self.rule) c2.position = (2, 5) c3 = SquareCell(self.rule) c3.position = (90, 4) c4 = SquareCell(self.rule) c4.position = (3, 7) self.cell.neighs["north"] = set([c1, c2]) self.cell.neighs["east"] = set([c2]) self.cell.neighs["south"] = set([c3]) self.cell.neighs["west"] = set([c4]) resultDictionary = { 'state': 0, 'north': set([(23, 47), (2, 5)]), 'east': set([(2, 5)]), 'south': set([(90, 4)]), 'west': set([(3, 7)]), 'northeast': set([]), 'southeast': set([]), 'southwest': set([]), 'northwest': set([]) } self.assertDictEqual(self.cell.toDict(), resultDictionary)
def create_cells(self, rule): cells = {} for x in range(0, self.width, self.resolution): for y in range(0, self.height, self.resolution): cells[(x, y)] = SquareCell.create_initialized( rule, self.neighbourhood, self.cell_state_class) coordinates = (x + self.resolution / 2, y + self.resolution / 2) cells[(x, y)].position = coordinates cells[(x, y)].radius = self.resolution / 2 return cells
def setUp(self): self.rule = DummyRule() self.cell = SquareCell(self.rule)