def test_black_chips(self): """Тестируем постановку черных фишек, и определения черных групп""" game = Game() self.move((555, 310), (9, 8), game, self.color_black) self.move((520, 310), (8, 8), game, self.color_black) self.move((485, 310), (7, 8), game, self.color_black) self.move((450, 310), (6, 8), game, self.color_black) self.move((275, 555), (1, 1), game, self.color_black) self.move((310, 555), (2, 1), game, self.color_black) self.move((345, 555), (3, 1), game, self.color_black) expected_black_groups = [[(9, 8), (8, 8), (7, 8), (6, 8)], [(1, 1), (2, 1), (3, 1)]] actual_black_groups = game.get_black_groups() self.assertEqual(actual_black_groups, expected_black_groups)
def test_attack(self): """Тест атаки бота. Заполняем доску четырмя фишками, отдаленных друг от друга. Такие фишки легко закрыть с помощью 16 ходов: 4 дыхания на каждую фишку""" game = Game() self.move((275, 275), (9, 9), game, self.color) self.move((555, 555), (9, 1), game, self.color) self.move((555, 380), (9, 6), game, self.color) self.move((380, 450), (4, 4), game, self.color) bot = SmartBot(game) for i in range(16): response = bot.action() game.set_new_move() expected_black_groups = [] actual_black_groups = game.get_black_groups() self.assertEqual(actual_black_groups, expected_black_groups)
def test_white_black_chips(self): """Тестируем постановку фишек обоих цветов, и определения обоих групп""" game = Game() self.move((345, 380), (3, 6), game, self.color_white) self.move((310, 380), (2, 6), game, self.color_white) self.move((275, 380), (1, 6), game, self.color_white) self.move((380, 555), (4, 1), game, self.color_white) self.move((415, 555), (5, 1), game, self.color_white) self.move((380, 310), (4, 8), game, self.color_black) self.move((380, 310), (4, 8), game, self.color_black) self.move((310, 310), (2, 8), game, self.color_black) self.move((275, 310), (1, 8), game, self.color_black) expected_black_groups = [[(4, 8)], [(2, 8), (1, 8)]] actual_white_groups = game.get_white_groups() actual_black_groups = game.get_black_groups() expected_white_groups = [[(3, 6), (2, 6), (1, 6)], [(4, 1), (5, 1)]] self.assertEqual(actual_black_groups, expected_black_groups) self.assertEqual(actual_white_groups, expected_white_groups)