Teams

Team Protocols and ready-to-go implementations. The CommandLineTeam can be used for fast developer interaction.

CommandLineEncryptor

Bases: Encryptor

A teammate who decides clues using the command line.

Source code in /home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
class CommandLineEncryptor(Encryptor):
    """A teammate who decides clues using the command line. """

    def print_context(self, context: TeamContext):
        """Print information for the developer to know how to interact through the command line.

        Args:
            context (TeamContext): Relevant information to the developer. 
        """
        print("=" * 12)
        print(f"You are Encryptor on team {TeamName(context.team_name)}")
        print(f"Keywords: {context.keywords}")
        print(f"Notesheet: {context.game.notesheet}")
        print(f"Scoresheet: {context.game.data}")
        print(f"Number of Opponent Keywords: {context.num_opponent_keywords}")

    def decide_clues(self, code: Code, context: TeamContext) -> Clue:
        """Decide clues for the given code using the command line.

        Args:
            code (Code): The code assigned to the Encryptor to decide clues for.
            context (TeamContext): Relevant information the Encryptor's decision may be guided by.

        Returns:
            Clue: The clues decided by the Encryptor for each code number in the provided code.
        """
        self.print_context(context)
        print(f"Code : {code}")
        clues = tuple(input(f"Clue for number {code_num}: ") for code_num in code)
        return clues

decide_clues(code, context)

Decide clues for the given code using the command line.

Parameters:
  • code (Code) –

    The code assigned to the Encryptor to decide clues for.

  • context (TeamContext) –

    Relevant information the Encryptor's decision may be guided by.

Returns:
  • Clue( Clue ) –

    The clues decided by the Encryptor for each code number in the provided code.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
def decide_clues(self, code: Code, context: TeamContext) -> Clue:
    """Decide clues for the given code using the command line.

    Args:
        code (Code): The code assigned to the Encryptor to decide clues for.
        context (TeamContext): Relevant information the Encryptor's decision may be guided by.

    Returns:
        Clue: The clues decided by the Encryptor for each code number in the provided code.
    """
    self.print_context(context)
    print(f"Code : {code}")
    clues = tuple(input(f"Clue for number {code_num}: ") for code_num in code)
    return clues

print_context(context)

Print information for the developer to know how to interact through the command line.

Parameters:
  • context (TeamContext) –

    Relevant information to the developer.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
78
79
80
81
82
83
84
85
86
87
88
89
def print_context(self, context: TeamContext):
    """Print information for the developer to know how to interact through the command line.

    Args:
        context (TeamContext): Relevant information to the developer. 
    """
    print("=" * 12)
    print(f"You are Encryptor on team {TeamName(context.team_name)}")
    print(f"Keywords: {context.keywords}")
    print(f"Notesheet: {context.game.notesheet}")
    print(f"Scoresheet: {context.game.data}")
    print(f"Number of Opponent Keywords: {context.num_opponent_keywords}")

CommandLineGuesser

Bases: Guesser

A teammate who attempts to decipher their team's clues using the command line.

Source code in /home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
class CommandLineGuesser(Guesser):
    """A teammate who attempts to decipher their team's clues using the command line. """

    def print_context(self, context: TeamContext):
        """Print information for the developer to know how to interact through the command line.

        Args:
            context (TeamContext): Relevant information to the developer. 
        """
        print("=" * 12)
        print(f"You are Guesser on team {TeamName(context.team_name)}")
        print(f"Keywords: {context.keywords}")
        print(f"Notesheet: {context.game.notesheet}")
        print(f"Scoresheet: {context.game.data}")

    def get_code_num(self, clue: str, context: TeamContext) -> int:
        """Attempt to decipher a single clue using the command line.

        Args:
            clue (str): The clue provided by the opposing team.
            context (TeamContext): Relevant information the Guesser's decision may be guided by. 

        Returns:
            int: The guessed code number based on the team's clue.
        """
        code_num = None
        while code_num is None:
            try:
                code_num = int(input(f"Code number for clue {clue}: "))
            except ValueError:
                pass
            if code_num is None or code_num not in range(len(context.keywords)):
                print(f"Code num must lie in range [0 - {len(context.keywords)}).")
                code_num = None
        return code_num

    def decipher_clues(self, clues: Clue, context: TeamContext) -> Code:
        """Attempt to decipher the team's clues using the command line.

        Args:
            clues (Clue): The clues provided by the Guesser's team.
            context (TeamContext): Relevant information the Guesser's decision may be guided by. 

        Returns:
            Code: The guessed code numbers based on the team's clues.
        """
        self.print_context(context)
        print(f"Clues : {clues}")
        code = tuple(self.get_code_num(clue, context) for clue in clues)
        return code

decipher_clues(clues, context)

Attempt to decipher the team's clues using the command line.

Parameters:
  • clues (Clue) –

    The clues provided by the Guesser's team.

  • context (TeamContext) –

    Relevant information the Guesser's decision may be guided by.

Returns:
  • Code( Code ) –

    The guessed code numbers based on the team's clues.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
195
196
197
198
199
200
201
202
203
204
205
206
207
208
def decipher_clues(self, clues: Clue, context: TeamContext) -> Code:
    """Attempt to decipher the team's clues using the command line.

    Args:
        clues (Clue): The clues provided by the Guesser's team.
        context (TeamContext): Relevant information the Guesser's decision may be guided by. 

    Returns:
        Code: The guessed code numbers based on the team's clues.
    """
    self.print_context(context)
    print(f"Clues : {clues}")
    code = tuple(self.get_code_num(clue, context) for clue in clues)
    return code

get_code_num(clue, context)

Attempt to decipher a single clue using the command line.

Parameters:
  • clue (str) –

    The clue provided by the opposing team.

  • context (TeamContext) –

    Relevant information the Guesser's decision may be guided by.

Returns:
  • int( int ) –

    The guessed code number based on the team's clue.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
def get_code_num(self, clue: str, context: TeamContext) -> int:
    """Attempt to decipher a single clue using the command line.

    Args:
        clue (str): The clue provided by the opposing team.
        context (TeamContext): Relevant information the Guesser's decision may be guided by. 

    Returns:
        int: The guessed code number based on the team's clue.
    """
    code_num = None
    while code_num is None:
        try:
            code_num = int(input(f"Code number for clue {clue}: "))
        except ValueError:
            pass
        if code_num is None or code_num not in range(len(context.keywords)):
            print(f"Code num must lie in range [0 - {len(context.keywords)}).")
            code_num = None
    return code_num

print_context(context)

Print information for the developer to know how to interact through the command line.

Parameters:
  • context (TeamContext) –

    Relevant information to the developer.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
162
163
164
165
166
167
168
169
170
171
172
def print_context(self, context: TeamContext):
    """Print information for the developer to know how to interact through the command line.

    Args:
        context (TeamContext): Relevant information to the developer. 
    """
    print("=" * 12)
    print(f"You are Guesser on team {TeamName(context.team_name)}")
    print(f"Keywords: {context.keywords}")
    print(f"Notesheet: {context.game.notesheet}")
    print(f"Scoresheet: {context.game.data}")

CommandLineIntercepter

Bases: Intercepter

A teammate who attempts to decipher the opposing team's clues using the command line.

Source code in /home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
class CommandLineIntercepter(Intercepter):
    """A teammate who attempts to decipher the opposing team's clues using the command line. """

    def print_context(self, context: TeamContext):
        """Print information for the developer to know how to interact through the command line.

        Args:
            context (TeamContext): Relevant information to the developer. 
        """
        print("=" * 12)
        print(f"You are Intercepter on team {TeamName(context.team_name)}")
        print(f"Keywords: {context.keywords}")
        print(f"Notesheet: {context.game.notesheet}")
        print(f"Scoresheet: {context.game.data}")
        print(f"Number of Opponent Keywords: {context.num_opponent_keywords}")


    def get_code_num(self, clue: str, context: TeamContext) -> int:
        """Attempt to decipher a single opponent's clue using the command line.

        Args:
            clue (str): The clue provided by the opposing team.
            context (TeamContext): Relevant information the Intercepter's decision may be guided by. 

        Returns:
            int: The guessed code number based on the opposing team's clue.
        """
        code_num = None
        while code_num is None:
            try:
                code_num = int(input(f"Code number for clue {clue}: "))
            except ValueError:
                pass
            if code_num is None or code_num not in range(len(context.keywords)):
                print(f"Code num must lie in range [0 - {len(context.keywords)}).")
                code_num = None
        return code_num

    def intercept_clues(self, opponent_clues: Clue, context: TeamContext) -> Code:
        """Attempt to intercept the opposing team's clues using the command line.

        Args:
            opponent_clues (Clue): The clues provided by the opposing team.
            context (TeamContext): Relevant information the Interepter's decision may be guided by.

        Returns:
            Code: The intercepted code numbers based on the opposing team's clues.
        """
        self.print_context(context)
        print(f"Opponent Clues : {opponent_clues}")
        code = tuple(self.get_code_num(clue, context) for clue in opponent_clues)
        return code

get_code_num(clue, context)

Attempt to decipher a single opponent's clue using the command line.

Parameters:
  • clue (str) –

    The clue provided by the opposing team.

  • context (TeamContext) –

    Relevant information the Intercepter's decision may be guided by.

Returns:
  • int( int ) –

    The guessed code number based on the opposing team's clue.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
def get_code_num(self, clue: str, context: TeamContext) -> int:
    """Attempt to decipher a single opponent's clue using the command line.

    Args:
        clue (str): The clue provided by the opposing team.
        context (TeamContext): Relevant information the Intercepter's decision may be guided by. 

    Returns:
        int: The guessed code number based on the opposing team's clue.
    """
    code_num = None
    while code_num is None:
        try:
            code_num = int(input(f"Code number for clue {clue}: "))
        except ValueError:
            pass
        if code_num is None or code_num not in range(len(context.keywords)):
            print(f"Code num must lie in range [0 - {len(context.keywords)}).")
            code_num = None
    return code_num

intercept_clues(opponent_clues, context)

Attempt to intercept the opposing team's clues using the command line.

Parameters:
  • opponent_clues (Clue) –

    The clues provided by the opposing team.

  • context (TeamContext) –

    Relevant information the Interepter's decision may be guided by.

Returns:
  • Code( Code ) –

    The intercepted code numbers based on the opposing team's clues.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
def intercept_clues(self, opponent_clues: Clue, context: TeamContext) -> Code:
    """Attempt to intercept the opposing team's clues using the command line.

    Args:
        opponent_clues (Clue): The clues provided by the opposing team.
        context (TeamContext): Relevant information the Interepter's decision may be guided by.

    Returns:
        Code: The intercepted code numbers based on the opposing team's clues.
    """
    self.print_context(context)
    print(f"Opponent Clues : {opponent_clues}")
    code = tuple(self.get_code_num(clue, context) for clue in opponent_clues)
    return code

print_context(context)

Print information for the developer to know how to interact through the command line.

Parameters:
  • context (TeamContext) –

    Relevant information to the developer.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
109
110
111
112
113
114
115
116
117
118
119
120
def print_context(self, context: TeamContext):
    """Print information for the developer to know how to interact through the command line.

    Args:
        context (TeamContext): Relevant information to the developer. 
    """
    print("=" * 12)
    print(f"You are Intercepter on team {TeamName(context.team_name)}")
    print(f"Keywords: {context.keywords}")
    print(f"Notesheet: {context.game.notesheet}")
    print(f"Scoresheet: {context.game.data}")
    print(f"Number of Opponent Keywords: {context.num_opponent_keywords}")

Encryptor

Bases: Protocol

Interface representing an Encryptor, a teammate who decides clues

Source code in /home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Encryptor(Protocol):
    """Interface representing an Encryptor, a teammate who decides clues"""

    def decide_clues(self, code: Code, context: TeamContext) -> Clue:
        """Decide clues for the given code as an Encryptor given the team context and current game state.

        Args:
            code (Code): The code assigned to the Encryptor to decide clues for.
            context (TeamContext): Relevant information the Encryptor's decision may be guided by.

        Returns:
            Clue: The clues decided by the Encryptor for each code number in the provided code.
        """
        ...

decide_clues(code, context)

Decide clues for the given code as an Encryptor given the team context and current game state.

Parameters:
  • code (Code) –

    The code assigned to the Encryptor to decide clues for.

  • context (TeamContext) –

    Relevant information the Encryptor's decision may be guided by.

Returns:
  • Clue( Clue ) –

    The clues decided by the Encryptor for each code number in the provided code.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
18
19
20
21
22
23
24
25
26
27
28
def decide_clues(self, code: Code, context: TeamContext) -> Clue:
    """Decide clues for the given code as an Encryptor given the team context and current game state.

    Args:
        code (Code): The code assigned to the Encryptor to decide clues for.
        context (TeamContext): Relevant information the Encryptor's decision may be guided by.

    Returns:
        Clue: The clues decided by the Encryptor for each code number in the provided code.
    """
    ...

Guesser

Bases: Protocol

Interface representing an Guesser, a teammate who attempts to decipher their team's clues

Source code in /home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class Guesser(Protocol):
    """Interface representing an Guesser, a teammate who attempts to decipher their team's clues"""

    def decipher_clues(self, clues: Clue, context: TeamContext) -> Code:
        """Attempt to decipher the clues provided by the team as a Guesser given the team context and current game state.

        Args:
            clues (Clue): The clues provided by the Guesser's team.
            context (TeamContext): Relevant information the Guesser's decision may be guided by.

        Returns:
            Code: The guessed code numbers based on the team's clues.
        """
        ...

decipher_clues(clues, context)

Attempt to decipher the clues provided by the team as a Guesser given the team context and current game state.

Parameters:
  • clues (Clue) –

    The clues provided by the Guesser's team.

  • context (TeamContext) –

    Relevant information the Guesser's decision may be guided by.

Returns:
  • Code( Code ) –

    The guessed code numbers based on the team's clues.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
48
49
50
51
52
53
54
55
56
57
58
def decipher_clues(self, clues: Clue, context: TeamContext) -> Code:
    """Attempt to decipher the clues provided by the team as a Guesser given the team context and current game state.

    Args:
        clues (Clue): The clues provided by the Guesser's team.
        context (TeamContext): Relevant information the Guesser's decision may be guided by.

    Returns:
        Code: The guessed code numbers based on the team's clues.
    """
    ...

Intercepter

Bases: Protocol

Interface representing an Intercepter, a teammate who attempts to decipher the opposing team's clues

Source code in /home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Intercepter(Protocol):
    """Interface representing an Intercepter, a teammate who attempts to decipher the opposing team's clues"""

    def intercept_clues(self, opponent_clues: Clue, context: TeamContext) -> Code:
        """Attempt to decipher the opposing team's clues as an Intercepter given the team context and current game state.

        Args:
            opponent_clues (Clue): The clues provided by the opposing team.
            context (TeamContext): Relevant information the Intercepter's decision may be guided by.

        Returns:
            Code: The intercepter's code numbers guess based on the opposing team's clues.
        """
        ...

intercept_clues(opponent_clues, context)

Attempt to decipher the opposing team's clues as an Intercepter given the team context and current game state.

Parameters:
  • opponent_clues (Clue) –

    The clues provided by the opposing team.

  • context (TeamContext) –

    Relevant information the Intercepter's decision may be guided by.

Returns:
  • Code( Code ) –

    The intercepter's code numbers guess based on the opposing team's clues.

/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
33
34
35
36
37
38
39
40
41
42
43
def intercept_clues(self, opponent_clues: Clue, context: TeamContext) -> Code:
    """Attempt to decipher the opposing team's clues as an Intercepter given the team context and current game state.

    Args:
        opponent_clues (Clue): The clues provided by the opposing team.
        context (TeamContext): Relevant information the Intercepter's decision may be guided by.

    Returns:
        Code: The intercepter's code numbers guess based on the opposing team's clues.
    """
    ...

Team dataclass

Dataclass representing a team for a Decrypto game.

Source code in /home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
60
61
62
63
64
65
66
@dataclasses.dataclass(kw_only=True)
class Team:
    """Dataclass representing a team for a Decrypto game."""
    keywords: Keywords
    encryptor: Encryptor
    intercepter: Intercepter
    guesser: Guesser

TeamContext dataclass

Dataclass representing the relevant information a team might consider

Source code in /home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/teams.py
 6
 7
 8
 9
10
11
12
@dataclasses.dataclass(kw_only=True)
class TeamContext:
    """Dataclass representing the relevant information a team might consider"""
    team_name: TeamName
    keywords: Keywords
    num_opponent_keywords: int
    game: Game