games/ares.py [57:145]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    step = 0
    game = 0
    wins = 0
    plays = 0
    reward = "START"
    last_move = "START"
    lock = threading.Lock()

    # Event listener for when a message is sent to a channel the client is in
    @client.event
    async def on_message(message):
        nonlocal step, game, reward, last_move, wins, plays

        # Don't let the client respond to its own messages
        if message.author == client.user:
            return

        # Check if the client was mentioned in the message
        if (
            client.user.mentioned_in(message)
            and message.mention_everyone is False
        ):
            if (move := extract_move(purge_mentions(message.content))) is None:
                return await message.channel.send(
                    f"{message.author.mention}, what move are you trying to make?"  # noqa: E501
                )

            move = move.upper()

            with lock:
                player.observations.append(move)

                # Let's keep observations at 10 for now.
                if len(player.observations) > 10:
                    player.observations.pop(0)

            with lock:
                if step == 0:
                    reward = "START"

            with lock:
                try:
                    response = player.crew.kickoff(
                        inputs={
                            "observations": player.observations,
                            "reward": reward,
                            "step": step,
                            "game": game,
                        }
                    )
                except Exception as e:
                    return await message.channel.send(
                        f"{message.author.mention}, {str(e)}"
                    )

                player_move = player.move()
                reward = 0
                plays = plays + 1

                if move == "ROCK":
                    if player_move == "SCISSORS":
                        reward = "LOSS"
                    elif player_move == "PAPER":
                        reward = "WIN"
                        wins = wins + 1
                elif move == "SCISSORS":
                    if player_move == "PAPER":
                        reward = "LOSS"
                    elif player_move == "ROCK":
                        reward = "WIN"
                        wins = wins + 1
                elif move == "PAPER":
                    if player_move == "ROCK":
                        reward = "LOSS"
                    elif player_move == "SCISSORS":
                        reward = "WIN"
                        wins = wins + 1

                last_move = player_move
                step = step + 1
                if step % 7 == 0:
                    step = 0
                    game = game + 1
                    reward = "START"
                    last_move = "START"

                return await message.channel.send(
                    f"{message.author.mention}, {response} ({wins} / {plays} wins)"  # noqa: E501
                )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



games/athena.py [57:145]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    step = 0
    game = 0
    wins = 0
    plays = 0
    reward = "START"
    last_move = "START"
    lock = threading.Lock()

    # Event listener for when a message is sent to a channel the client is in
    @client.event
    async def on_message(message):
        nonlocal step, game, reward, last_move, wins, plays

        # Don't let the client respond to its own messages
        if message.author == client.user:
            return

        # Check if the client was mentioned in the message
        if (
            client.user.mentioned_in(message)
            and message.mention_everyone is False
        ):
            if (move := extract_move(purge_mentions(message.content))) is None:
                return await message.channel.send(
                    f"{message.author.mention}, what move are you trying to make?"  # noqa: E501
                )

            move = move.upper()

            with lock:
                player.observations.append(move)

                # Let's keep observations at 10 for now.
                if len(player.observations) > 10:
                    player.observations.pop(0)

            with lock:
                if step == 0:
                    reward = "START"

            with lock:
                try:
                    response = player.crew.kickoff(
                        inputs={
                            "observations": player.observations,
                            "reward": reward,
                            "step": step,
                            "game": game,
                        }
                    )
                except Exception as e:
                    return await message.channel.send(
                        f"{message.author.mention}, {str(e)}"
                    )

                player_move = player.move()
                reward = 0
                plays = plays + 1

                if move == "ROCK":
                    if player_move == "SCISSORS":
                        reward = "LOSS"
                    elif player_move == "PAPER":
                        reward = "WIN"
                        wins = wins + 1
                elif move == "SCISSORS":
                    if player_move == "PAPER":
                        reward = "LOSS"
                    elif player_move == "ROCK":
                        reward = "WIN"
                        wins = wins + 1
                elif move == "PAPER":
                    if player_move == "ROCK":
                        reward = "LOSS"
                    elif player_move == "SCISSORS":
                        reward = "WIN"
                        wins = wins + 1

                last_move = player_move
                step = step + 1
                if step % 7 == 0:
                    step = 0
                    game = game + 1
                    reward = "START"
                    last_move = "START"

                return await message.channel.send(
                    f"{message.author.mention}, {response} ({wins} / {plays} wins)"  # noqa: E501
                )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



