@@ -69,30 +69,6 @@ def inspect_strategy(inspector, opponent):
6969 return opponent .strategy (inspector )
7070
7171
72- def _limited_simulate_play (player_1 , player_2 , h1 ):
73- """Simulates a player's move.
74-
75- After inspecting player_2's next move (allowing player_2's strategy
76- method to set any internal variables as needed), update histories
77- for both players. Note that player_1's move is an argument.
78-
79- If you need a more complete simulation, see `simulate_play` in
80- player.py.
81-
82- Parameters
83- ----------
84- player_1: Player
85- The player whose move is already known.
86- player_2: Player
87- The player the we want to inspect.
88- h1: Action
89- The next action for first player.
90- """
91- h2 = inspect_strategy (player_1 , player_2 )
92- player_1 .update_history (h1 , h2 )
93- player_2 .update_history (h2 , h1 )
94-
95-
9672def _calculate_scores (p1 , p2 , game ):
9773 """Calculates the scores for two players based their history.
9874
@@ -118,42 +94,6 @@ def _calculate_scores(p1, p2, game):
11894 return s1 , s2
11995
12096
121- def look_ahead (player1 , player2 , game , rounds = 10 ):
122- """Returns a constant action that maximizes score by looking ahead.
123-
124- Parameters
125- ----------
126- player_1: Player
127- The player that will look ahead.
128- player_2: Player
129- The opponent that will be inspected.
130- game: Game
131- The Game object used to score rounds.
132- rounds: int
133- The number of rounds to look ahead.
134-
135- Returns
136- -------
137- Action
138- The action that maximized score if it is played constantly.
139- """
140- results = {}
141- possible_strategies = {C : Cooperator (), D : Defector ()}
142- for action , player in possible_strategies .items ():
143- # Instead of a deepcopy, create a new opponent and replay the history to it.
144- opponent_ = player2 .clone ()
145- if opponent_ .classifier ["stochastic" ]:
146- opponent_ .set_seed (player2 ._seed )
147- for h in player1 .history :
148- _limited_simulate_play (player , opponent_ , h )
149-
150- # Now play forward with the constant strategy.
151- simulate_match (player , opponent_ , action , rounds )
152- results [action ] = _calculate_scores (player , opponent_ , game )
153-
154- return C if results [C ] > results [D ] else D
155-
156-
15797@lru_cache ()
15898def recursive_thue_morse (n ):
15999 """The recursive definition of the Thue-Morse sequence.
0 commit comments