From c3ab1be08e60ed370a2b49e2ed0c9347be710602 Mon Sep 17 00:00:00 2001 From: AlberLC Date: Mon, 21 Nov 2022 22:16:31 +0100 Subject: [PATCH] Fix Connect4Bot ai patterns --- flanabot/bots/connect_4_bot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flanabot/bots/connect_4_bot.py b/flanabot/bots/connect_4_bot.py index 2763451..0e045e8 100644 --- a/flanabot/bots/connect_4_bot.py +++ b/flanabot/bots/connect_4_bot.py @@ -94,7 +94,10 @@ class Connect4Bot(MultiBot, ABC): good_positions = [pos for pos in available_positions_ if pos not in human_winning_positions_above and pos not in ai_winning_positions_above] if good_positions: - j = random.choice(self._best_plays(good_positions, player_2.number, board))[1] + if random.random() < 0.5: + j = random.choice(self._best_plays(good_positions, player_2.number, board))[1] + else: + j = random.choice(good_positions)[1] elif ai_winning_positions_above: j = random.choice(self._best_plays(ai_winning_positions_above, player_2.number, board))[1] else: