Validate agent code has required functions.
(self, agent: Player)
| 45 | self.run_cmd = "python3 /workspace/run_game.py" |
| 46 | |
| 47 | def validate_code(self, agent: Player) -> tuple[bool, str | None]: |
| 48 | """Validate agent code has required functions.""" |
| 49 | if self.submission not in agent.environment.execute("ls")["output"]: |
| 50 | return False, f"No {self.submission} file found in root directory" |
| 51 | |
| 52 | content = agent.environment.execute(f"cat {self.submission}")["output"] |
| 53 | |
| 54 | # Check for required function definitions |
| 55 | required_functions = ["def get_bid(", "def play_card("] |
| 56 | |
| 57 | missing = [] |
| 58 | for func in required_functions: |
| 59 | if func not in content: |
| 60 | missing.append(func) |
| 61 | |
| 62 | if missing: |
| 63 | return False, f"Missing required functions: {', '.join(missing)}" |
| 64 | |
| 65 | return True, None |
| 66 | |
| 67 | def _run_single_simulation(self, agents: list[Player], idx: int, cmd: str): |
| 68 | """Run a single Bridge game simulation.""" |