def test_can_not_hop_hopper_space(self): t = [ board.Tile(1, 0, 0, piece.create_ladybug('W')), board.Tile(2, 0, 0, piece.create_ladybug('W')), board.Tile(2, 1, 0, piece.create_ladybug('W')), board.Tile(3, 1, 0, piece.create_ladybug('W')), board.Tile(4, 0, 0, piece.create_ladybug('W')), ] p = board.Tile(0, 0, 0, piece.create_hopper('B')) self.assertFalse(hiveutil.space_hopable(p, hexutil.Point(5, 0), t, hiveutil.generate_hive_movement_cloud(t, p))) self.assertTrue(hiveutil.space_hopable(p, hexutil.Point(3, 0), t, hiveutil.generate_hive_movement_cloud(t, p)))
def test_can_crawl_to_spider(self): t = [ board.Tile(1, 0, 0, piece.create_ladybug('W')), ] p = board.Tile(0, 0, 0, piece.create_spider('W')) self.assertTrue(hiveutil.space_crawable(p, hexutil.Point(2, 0), t, hiveutil.generate_hive_movement_cloud(t, p)))
def test_can_not_crawl_to_spider_back_and_forth(self): t = [ board.Tile(1, 0, 0, piece.create_ladybug('W')), ] p = board.Tile(0, 0, 0, piece.create_spider('W')) self.assertFalse(hiveutil.space_crawable(p, hexutil.Point(0, 1), t, hiveutil.generate_hive_movement_cloud(t, p)))
def test_movement_cloud_six_piece_ring(self): t = [ board.Tile(2, 0, 0, piece.create_ladybug('W')), board.Tile(2, 1, 0, piece.create_ladybug('W')), board.Tile(2, 2, 0, piece.create_ladybug('W')), board.Tile(1, 2, 0, piece.create_ladybug('W')), board.Tile(0, 1, 0, piece.create_ladybug('W')), board.Tile(1, 0, 0, piece.create_ladybug('W')), ] cloud = [ hexutil.Point(1, 1), hexutil.Point(3, 1), hexutil.Point(3, 2), hexutil.Point(2, 3), hexutil.Point(1, 3), hexutil.Point(0, 3), hexutil.Point(0, 2), hexutil.Point(-1, 1), hexutil.Point(0, 0), hexutil.Point(0, -1), hexutil.Point(1, -1), hexutil.Point(2, -1), hexutil.Point(3, 0), ] self.assertCountEqual(hiveutil.generate_hive_movement_cloud(t, t[0]), cloud)
def test_can_not_crawl_to_beetle_out_of_range(self): t = [ board.Tile(1, 0, 0, piece.create_ladybug('W')), ] p = board.Tile(0, 0, 0, piece.create_beetle('W')) self.assertFalse(hiveutil.space_crawable(p, hexutil.Point(1, 1), t, hiveutil.generate_hive_movement_cloud(t, p)))
def test_can_crawl_to_beetle_on_top(self): t = [ board.Tile(1, 0, 0, piece.create_ladybug('W')), board.Tile(1, 1, 0, piece.create_ladybug('W')), ] p = board.Tile(1, 0, 1, piece.create_beetle('W')) self.assertTrue(hiveutil.space_crawable(p, hexutil.Point(1, 1), t, hiveutil.generate_hive_movement_cloud(t, p)))
def test_can_not_crawl_to_ant_gates(self): t = [ board.Tile(1, 0, 0, piece.create_ladybug('W')), board.Tile(2, 0, 0, piece.create_ladybug('W')), board.Tile(2, 1, 0, piece.create_ladybug('W')), board.Tile(2, 2, 0, piece.create_ladybug('W')), board.Tile(1, 2, 0, piece.create_ladybug('W')), ] p = board.Tile(0, 0, 0, piece.create_ant('W')) self.assertFalse(hiveutil.space_crawable(p, hexutil.Point(1, 1), t, hiveutil.generate_hive_movement_cloud(t, p)))
def test_movement_cloud_one_piece(self): t = [ board.Tile(1, 1, 0, piece.create_ladybug('W')) ] cloud = [ hexutil.Point(2, 0), hexutil.Point(2, 1), hexutil.Point(2, 2), hexutil.Point(1, 2), hexutil.Point(0, 1), hexutil.Point(1, 0), ] self.assertCountEqual(hiveutil.generate_hive_movement_cloud(t, t[0]), cloud)
def test_can_crawl_to_ant_gates_in_big_ring(self): t = [ board.Tile(2, 0, 0, piece.create_ladybug('W')), board.Tile(3, 0, 0, piece.create_ladybug('W')), board.Tile(4, 0, 0, piece.create_ladybug('W')), board.Tile(4, 1, 0, piece.create_ladybug('W')), board.Tile(4, 2, 0, piece.create_ladybug('W')), board.Tile(3, 3, 0, piece.create_ladybug('W')), board.Tile(2, 3, 0, piece.create_ladybug('W')), board.Tile(1, 3, 0, piece.create_ladybug('W')), board.Tile(1, 2, 0, piece.create_ladybug('W')) ] p = board.Tile(1, 0, 0, piece.create_ant('W')) self.assertTrue(hiveutil.space_crawable(p , hexutil.Point(3, 1), t, hiveutil.generate_hive_movement_cloud(t, p)))
def test_can_crawl_to_spider_strange_case(self): t = [ board.Tile(1, 0, 0, piece.create_ladybug('W')), board.Tile(2, 0, 0, piece.create_ladybug('W')), board.Tile(2, 1, 0, piece.create_ladybug('W')), board.Tile(2, 2, 0, piece.create_ladybug('W')), board.Tile(1, 3, 0, piece.create_ladybug('W')), board.Tile(0, 3, 0, piece.create_ladybug('W')), board.Tile(0, 2, 0, piece.create_ladybug('W')), ] p = board.Tile(0, 0, 0, piece.create_spider('W')) cloud = hiveutil.generate_hive_movement_cloud(t, p) self.assertTrue(hiveutil.space_crawable(p , hexutil.Point(1, 2), t, cloud)) self.assertTrue(hiveutil.space_crawable(p, hexutil.Point(1, 1), t, cloud)) self.assertTrue(hiveutil.space_crawable(p, hexutil.Point(2, -1), t, cloud)) self.assertTrue(hiveutil.space_crawable(p, hexutil.Point(-1, 2), t, cloud))
def test_can_not_hop_hopper_simple_off_direction(self): t = [ board.Tile(1, 0, 0, piece.create_ladybug('W')), ] p = board.Tile(0, 0, 0, piece.create_hopper('B')) self.assertFalse(hiveutil.space_hopable(p, hexutil.Point(1, 1), t, hiveutil.generate_hive_movement_cloud(t, p)))