Skip to content

Commit c45fdb1

Browse files
committed
Enh: Save initial commit hash that player starts with
Closes #41
1 parent de92f04 commit c45fdb1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

codeclash/agents/abstract.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(
4040
"incremental_diff": {0: ""}, # mapping round -> diff
4141
"created_timestamp": int(time.time()),
4242
"config": self.config,
43+
"initial_commit_hash": self._get_commit_hash(),
4344
}
4445

4546
# --- Main methods ---
@@ -126,6 +127,14 @@ def _get_round_tag_name(self, round: int) -> str:
126127
"""Get git tag name for the version of the codebase at the given round."""
127128
return f"{self._player_unique_id}-round-{round}"
128129

130+
def _get_commit_hash(self) -> str:
131+
"""Get the current commit hash."""
132+
out = assert_zero_exit_code(
133+
self.environment.execute("git rev-parse HEAD"),
134+
logger=self.logger,
135+
)
136+
return out["output"].strip()
137+
129138
def _commit(self) -> None:
130139
"""Commit changes to the agent's codebase."""
131140
r = self.game_context.round

0 commit comments

Comments
 (0)