expand more

This commit is contained in:
Rich Jones 2025-02-27 10:41:30 +01:00
parent f0ca949aaf
commit 633a1aa1ba
2 changed files with 17 additions and 14 deletions

View file

@ -137,20 +137,21 @@ class RubiksCubeDataset(ProceduralDataset):
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()
try:
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:
expanded.extend([base] * int(num_part))
else:
expanded.append(base)
return " ".join(expanded).strip()
except Exception as e:
return move_str
# Register the dataset