mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-25 17:10:51 +00:00
catch exception in RubiksCube score_answer
This commit is contained in:
parent
a04db556e6
commit
a6bf23e655
1 changed files with 10 additions and 7 deletions
|
|
@ -102,21 +102,24 @@ class RubiksCubeDataset(ProceduralDataset):
|
||||||
|
|
||||||
def score_answer(self, answer: Optional[str], entry: Dict[str, any]) -> float:
|
def score_answer(self, answer: Optional[str], entry: Dict[str, any]) -> float:
|
||||||
"""Determine if the solution provided solves the cube"""
|
"""Determine if the solution provided solves the cube"""
|
||||||
|
answer = answer.strip()
|
||||||
|
|
||||||
reward = 0.0
|
reward = 0.0
|
||||||
if answer is not None:
|
if answer is not None and len(answer) > 0:
|
||||||
|
|
||||||
# Reconstruct the test cube
|
# Reconstruct the test cube
|
||||||
eval_cube = Cube(entry["metadata"]["cube_size"])
|
eval_cube = Cube(entry["metadata"]["cube_size"])
|
||||||
eval_cube.rotate(entry["metadata"]["scramble_moves"])
|
eval_cube.rotate(entry["metadata"]["scramble_moves"])
|
||||||
|
|
||||||
# Test the solution
|
# Test the solution
|
||||||
|
try:
|
||||||
eval_cube.rotate(answer)
|
eval_cube.rotate(answer)
|
||||||
solved = eval_cube.is_done()
|
solved = eval_cube.is_done()
|
||||||
|
|
||||||
if solved:
|
if solved:
|
||||||
reward = 1.0
|
reward = 1.0
|
||||||
else:
|
else:
|
||||||
|
reward = 0.1 # Incorrect, but rotate could parse the answer
|
||||||
|
except:
|
||||||
reward = 0.01 # At least you tried
|
reward = 0.01 # At least you tried
|
||||||
|
|
||||||
return reward
|
return reward
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue