File size: 1,066 Bytes
dfdde45
c6c2b98
a92f249
dfdde45
a92f249
7877562
 
c6c2b98
abc228d
 
758a706
5de0b8a
7877562
 
758a706
7877562
758a706
7877562
758a706
7877562
 
 
f596e58
 
 
dfdde45
 
f596e58
5de0b8a
c2392fe
dfdde45
f596e58
7877562
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from typing import Literal
import logging

from agent_interfaces import AgentInterface

Role = Literal["chameleon", "herd"]

logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger("chameleon")


class Player:

    role: Role | None = None
    """The role of the player in the game. Can be "chameleon" or "herd". This changes every round."""
    rounds_played_as_chameleon: int = 0
    """The number of times the player has been the Chameleon."""
    rounds_played_as_herd: int = 0
    """The number of times the player has been in the Herd."""
    points: int = 0
    """The number of points the player has."""

    def __init__(
            self,
            name: str,
            player_id: str,
            interface: AgentInterface
    ):
        self.name = name
        self.id = player_id
        self.interface = interface

    def assign_role(self, role: Role):
        self.role = role
        if role == "chameleon":
            self.rounds_played_as_chameleon += 1
        elif role == "herd":
            self.rounds_played_as_herd += 1