Play a single round of Decrypto. The game object will be updated with the round results.
| Parameters: |
-
teams
(
Sequence[Team])
–
The pair of teams participating in the game.
-
game
(
Game)
–
The Decrypto game object which encodes the current state.
-
codes
(
Sequence[Code])
–
The codes for the current round.
|
/home/docs/checkouts/readthedocs.org/user_builds/decryptogame/envs/latest/lib/python3.10/site-packages/decryptogame/play.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 | def play_round(teams:Sequence[Team], game: Game, codes: Sequence[Code]):
"""Play a single round of Decrypto. The game object will be updated with the round results.
Args:
teams (Sequence[Team]): The pair of teams participating in the game.
game (Game): The Decrypto game object which encodes the current state.
codes (Sequence[Code]): The codes for the current round.
"""
# each member may need information about its team and the game to make proper decisions
context = [TeamContext(
team_name=team_name,
keywords=team.keywords,
num_opponent_keywords=len(teams[not team_name].keywords),
game=game
)
for team_name, team in enumerate(teams)]
# each team's encryptor decides the clues
clues = {}
for team_name, code in enumerate(codes):
team = teams[team_name]
# give the encryptor the context of its team and the current game state
clues[team_name] = team.encryptor.decide_clues(code, context[team_name])
# each team attempts to intercept the opposing team's code
attempted_interception = {}
for team_name, code in enumerate(codes):
team = teams[team_name]
# give the intercepter the context of its team and the current game state
opponent = not team_name
attempted_interception[team_name] = team.intercepter.intercept_clues(clues[opponent], context[team_name])
# each team attempts to decipher the clues to their code
attempted_decipher = {}
for team_name, code in enumerate(codes):
team = teams[team_name]
# give the guesser the context of its team and the current game state
attempted_decipher[team_name] = team.guesser.decipher_clues(clues[team_name], context[team_name])
# each team reveals their codes and the notes are processed and added to the notesheet
notes = [Note(clues=clues[team_name],
attempted_interception=attempted_interception[team_name],
attempted_decipher=attempted_decipher[team_name],
correct_code=code
)
for team_name, code in enumerate(codes)]
game.process_round_notes(notes)
|