diff options
author | 2021-10-17 13:09:54 +0100 | |
---|---|---|
committer | 2021-10-17 13:09:54 +0100 | |
commit | 860c137f868ff9c91df0669a33dd9d551cbcc4a5 (patch) | |
tree | a1f20377b54d612ebd96aed588b825b6601237c0 | |
parent | Add missing `Game.channel` attribute (diff) |
Address review & make `AI.get_move` a staticmethod
-rw-r--r-- | bot/exts/fun/tic_tac_toe.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/bot/exts/fun/tic_tac_toe.py b/bot/exts/fun/tic_tac_toe.py index 1ebf8d11..946b6f7b 100644 --- a/bot/exts/fun/tic_tac_toe.py +++ b/bot/exts/fun/tic_tac_toe.py @@ -72,11 +72,12 @@ class Player: class AI: """Tic Tac Toe AI class for against computer gaming.""" - def __init__(self, ctx: Context, symbol: str): - self.user = ctx.me + def __init__(self, bot_user: discord.Member, symbol: str): + self.user = bot_user self.symbol = symbol - async def get_move(self, board: dict[int, str], _: discord.Message) -> tuple[bool, int]: + @staticmethod + async def get_move(board: dict[int, str], _: discord.Message) -> tuple[bool, int]: """Get move from AI. AI use Minimax strategy.""" possible_moves = [i for i, emoji in board.items() if emoji in list(Emojis.number_emojis.values())] @@ -175,7 +176,8 @@ class Game: self.canceled = True return False, "User declined" - async def add_reactions(self, msg: discord.Message) -> None: + @staticmethod + async def add_reactions(msg: discord.Message) -> None: """Add number emojis to message.""" for nr in Emojis.number_emojis.values(): await msg.add_reaction(nr) @@ -267,7 +269,7 @@ class TicTacToe(Cog): return if opponent is None: game = Game( - [Player(ctx.author, ctx, Emojis.x_square), AI(ctx, Emojis.o_square)], + [Player(ctx.author, ctx, Emojis.x_square), AI(ctx.me, Emojis.o_square)], ctx ) else: |