mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-29 17:35:16 +00:00
support expanded notation anyway
This commit is contained in:
parent
285e2b20cc
commit
f0ca949aaf
1 changed files with 18 additions and 1 deletions
|
|
@ -116,7 +116,8 @@ class RubiksCubeDataset(ProceduralDataset):
|
||||||
|
|
||||||
# Test the solution
|
# Test the solution
|
||||||
try:
|
try:
|
||||||
eval_cube.rotate(answer)
|
expanded_answer = self.expand_moves(answer)
|
||||||
|
eval_cube.rotate(expanded_answer)
|
||||||
solved = eval_cube.is_done()
|
solved = eval_cube.is_done()
|
||||||
|
|
||||||
if solved:
|
if solved:
|
||||||
|
|
@ -135,6 +136,22 @@ class RubiksCubeDataset(ProceduralDataset):
|
||||||
ansi_escape = re.compile(r"(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]")
|
ansi_escape = re.compile(r"(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]")
|
||||||
return ansi_escape.sub("", line)
|
return ansi_escape.sub("", line)
|
||||||
|
|
||||||
|
def expand_moves(self, move_str):
|
||||||
|
moves = move_str.split()
|
||||||
|
expanded = []
|
||||||
|
for move in moves:
|
||||||
|
# Split the move into the base part and any trailing digits
|
||||||
|
match = re.fullmatch(r"^([^\d]*)(\d*)$", move)
|
||||||
|
if match:
|
||||||
|
base, num_part = match.groups()
|
||||||
|
if num_part:
|
||||||
|
# Append two copies of the base if there was a number. I don't think F3 is a valid signmaster notation etc
|
||||||
|
expanded.append(base)
|
||||||
|
expanded.append(base)
|
||||||
|
else:
|
||||||
|
expanded.append(base)
|
||||||
|
return " ".join(expanded).strip()
|
||||||
|
|
||||||
|
|
||||||
# Register the dataset
|
# Register the dataset
|
||||||
register_dataset("rubiks_cube", RubiksCubeDataset, RubiksCubeConfig)
|
register_dataset("rubiks_cube", RubiksCubeDataset, RubiksCubeConfig)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue