def test_pos_transform(): pos_pairs = [((0, 0), "A1", 0x00), ((7, 0), "H1", 0x70), ((0, 7), "A8", 0x07), ((7, 7), "H8", 0x77), ((3, 4), "D5", 0x34)] for tupl, sp, ip in pos_pairs: ok(to_tuple_pos(sp)) == tupl ok(to_tuple_pos(ip)) == tupl ok(to_str_pos(tupl)) == sp ok(to_str_pos(ip)) == sp ok(to_int_pos(sp)) == ip ok(to_int_pos(tupl)) == ip for x in range(8): for y in range(8): ok(to_tuple_pos(to_str_pos((x, y)))) == (x, y) ok(to_tuple_pos(to_int_pos((x, y)))) == (x, y)
def test_pos_transform(): pos_pairs = [ ((0, 0), "A1", 0x00), ((7, 0), "H1", 0x70), ((0, 7), "A8", 0x07), ((7, 7), "H8", 0x77), ((3, 4), "D5", 0x34), ] for tupl, sp, ip in pos_pairs: ok(to_tuple_pos(sp)) == tupl ok(to_tuple_pos(ip)) == tupl ok(to_str_pos(tupl)) == sp ok(to_str_pos(ip)) == sp ok(to_int_pos(sp)) == ip ok(to_int_pos(tupl)) == ip for x in range(8): for y in range(8): ok(to_tuple_pos(to_str_pos((x, y)))) == (x, y) ok(to_tuple_pos(to_int_pos((x, y)))) == (x, y)
def cell_to_coords(self, cell): return self.cell_index_to_coords(*to_tuple_pos(cell))
def pos(self): return to_tuple_pos(self.ipos)