@@ -99,11 +99,9 @@ def build_image(self):
9999 self .logger .error (f"❌ Failed to build Docker image: { result .stderr } \n { result .stdout } { result .stderr } " )
100100 raise RuntimeError (f"Failed to build Docker image: { result .stderr } " )
101101
102- def get_metadata (self ) -> dict :
103- """This is what we write to metadata.json.
104- You can subclass extend this to add more details for specific games.
105- """
106- return self ._metadata
102+ def copy_logs_from_env (self , round_num : int ) -> None :
103+ """Copy logs from the game's environment to the local machine."""
104+ (self .log_local / "rounds" / str (round_num )).mkdir (parents = True , exist_ok = True )
107105
108106 def end (self , cleanup : bool = False ):
109107 if cleanup :
@@ -112,6 +110,9 @@ def end(self, cleanup: bool = False):
112110 subprocess .run (f"rm -rf { artifact } " , shell = True )
113111 self .logger .info (f"🧼 Cleaned up { self .name } game" )
114112
113+ def log_round (self , round_num : int ) -> Path :
114+ return self .log_local / "rounds" / str (round_num )
115+
115116 def get_environment (self , branch_name : str | None = None ) -> DockerEnvironment :
116117 """Get docker container ID with the game code installed."""
117118 self .build_image ()
@@ -142,6 +143,12 @@ def get_environment(self, branch_name: str | None = None) -> DockerEnvironment:
142143 assert_zero_exit_code (environment .execute (cmd ), logger = self .logger )
143144 return environment
144145
146+ def get_metadata (self ) -> dict :
147+ """This is what we write to metadata.json.
148+ You can subclass extend this to add more details for specific games.
149+ """
150+ return self ._metadata
151+
145152 def _pre_round_setup (self , agents : list [Player ]):
146153 """Copy agent codebases into game's container"""
147154 for agent in agents :
@@ -158,12 +165,20 @@ def _pre_round_setup(self, agents: list[Player]):
158165 logger = self .logger ,
159166 )
160167
161- def copy_logs_from_env (self , round_num : int ) -> None :
162- """Copy logs from the game's environment to the local machine."""
163- (self .log_local / "rounds" / str (round_num )).mkdir (parents = True , exist_ok = True )
168+ def run_round (self , agents : list [Player ], round_num : int ) -> RoundStats :
169+ """
170+ Run a single round of the game with the given agents.
171+
172+ Returns the log output, result output, and winner name. All bookkeeping should be
173+ handled by the tournament class.
174+ """
175+ self ._pre_round_setup (agents )
176+ self .execute_round (agents )
177+ self .copy_logs_from_env (round_num )
178+ return self .get_stats (agents , round_num )
164179
165180 @abstractmethod
166- def get_stats (self , agents : list [Player ]) -> RoundStats :
181+ def get_stats (self , agents : list [Player ], round_num : int ) -> RoundStats :
167182 """Determine the winner of the game based on the result output.
168183
169184 Args:
@@ -181,16 +196,3 @@ def execute_round(self, agents: list[Player]):
181196 includes the pre-round setup, post-round setup, and winner determination.
182197 """
183198 pass
184-
185- def run_round (self , agents : list [Player ], round_num : int ) -> RoundStats :
186- """
187- Run a single round of the game with the given agents.
188-
189- Returns the log output, result output, and winner name. All bookkeeping should be
190- handled by the tournament class.
191- """
192- self ._pre_round_setup (agents )
193- self .execute_round (agents )
194- stats = self .get_stats (agents )
195- self .copy_logs_from_env (round_num )
196- return stats
0 commit comments