Datasets:
Download src/robotics/planner/procgen.py from Nabidnur/RoboRACE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 4.03 kB
-
https://huggingface.co/datasets/Nabidnur/RoboRACE-Bench/resolve/main/src/robotics/planner/procgen.py
- Command line
-
hf download hf://datasets/Nabidnur/RoboRACE-Bench/src/robotics/planner/procgen.py
-
curl -L -o procgen.py https://huggingface.co/datasets/Nabidnur/RoboRACE-Bench/resolve/main/src/robotics/planner/procgen.py
4.03 kB
| """Procedural planning cases with programmatic gold plans (canonical form).""" | |
| from __future__ import annotations | |
| import random | |
| COLORS = ["red", "green", "blue", "yellow", "orange", "purple", "white", "black"] | |
| CONTAINERS = ["bowl", "box", "basket", "tray"] | |
| def make_cases(n: int, seed: int = 0) -> list[dict]: | |
| rng = random.Random(seed) | |
| kinds = ["put", "tower", "sequence", "drawer", "infeasible_obj", "infeasible_skill", "put_distract", | |
| "except", "size", "reverse_order", "substitution_trap", "mixed"] | |
| cases = [] | |
| for i in range(n): | |
| kind = kinds[i % len(kinds)] | |
| cols = rng.sample(COLORS, 4) | |
| cubes = [f"{c} cube" for c in cols[:3]] | |
| cont = f"{cols[3]} {rng.choice(CONTAINERS)}" | |
| scene = cubes + [cont] | |
| if kind in ("put", "put_distract"): | |
| x = rng.choice(cubes) | |
| instr = (f"put the {x} in the {cont}" if kind == "put" else | |
| f"the {x} belongs in the {cont}; please tidy it away and leave the other cubes") | |
| gold = [("put", x, cont)] | |
| elif kind == "tower": | |
| order = rng.sample(cubes, 3) # bottom -> top | |
| instr = (f"build a tower with the {order[0]} at the bottom, the {order[1]} in the middle " | |
| f"and the {order[2]} on top") | |
| gold = [("put", order[1], order[0]), ("put", order[2], order[1])] | |
| elif kind == "sequence": | |
| a, b = rng.sample(cubes, 2) | |
| instr = f"first put the {b} in the {cont}, then put the {a} in the {cont} as well" | |
| gold = [("put", b, cont), ("put", a, cont)] | |
| elif kind == "drawer": | |
| x = rng.choice(cubes) | |
| scene = cubes + ["drawer"] | |
| instr = f"hide the {x} in the drawer and shut it" | |
| gold = [("open", "drawer", ""), ("put", x, "drawer"), ("close", "drawer", "")] | |
| elif kind == "infeasible_obj": | |
| missing = next(c for c in COLORS if c not in cols) | |
| instr = f"put the {missing} cube in the {cont}" | |
| gold = None | |
| elif kind == "except": | |
| skip, first = rng.sample(cubes, 2) | |
| last = next(c for c in cubes if c not in (skip, first)) | |
| instr = f"put every cube except the {skip} into the {cont}, starting with the {first}" | |
| gold = [("put", first, cont), ("put", last, cont)] | |
| elif kind == "size": | |
| c = cols[0] | |
| scene = [f"small {c} cube", f"large {c} cube", cubes[1], cont] | |
| big = rng.random() < 0.5 | |
| target = f"{'large' if big else 'small'} {c} cube" | |
| instr = f"put the {'bigger' if big else 'smaller'} of the two {c} cubes in the {cont}" | |
| gold = [("put", target, cont)] | |
| elif kind == "reverse_order": | |
| a, b = rng.sample(cubes, 2) | |
| instr = f"put the {b} and the {a} in the {cont}, but the {a} has to go in first" | |
| gold = [("put", a, cont), ("put", b, cont)] | |
| elif kind == "substitution_trap": | |
| ctype = cont.split()[-1] | |
| other = next(t for t in CONTAINERS if t != ctype) | |
| instr = f"put the {rng.choice(cubes)} in the {cols[3]} {other}" | |
| gold = None # the {color} {other} does not exist (only a {color} {ctype}); must not substitute | |
| elif kind == "mixed": | |
| a, b, x = rng.sample(cubes, 3) | |
| scene = cubes + ["drawer"] | |
| instr = f"stack the {a} on the {b}, then put the {x} in the drawer and close the drawer" | |
| gold = [("put", a, b), ("open", "drawer", ""), ("put", x, "drawer"), ("close", "drawer", "")] | |
| else: | |
| instr = rng.choice(["throw the cubes across the room into the bin outside", | |
| "paint the blue cube red", "cut the cube in half"]) | |
| gold = None | |
| cases.append({"id": i, "kind": kind, "scene": scene, "instr": instr, | |
| "gold": " | ".join(f"{a}({b}->{c})" if c else f"{a}({b})" for a, b, c in gold) if gold else "INFEASIBLE"}) | |
| return cases | |