Spaces:
Sleeping
Sleeping
File size: 22,994 Bytes
d88694d 560752c d88694d 560752c d88694d 560752c d88694d eaa79f0 d88694d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | """
Task definitions for the warehouse fulfillment environment.
"""
from __future__ import annotations
from typing import Dict, List
from .models import BinState, OrderLine, TaskDefinition
GRID_SIZE = (7, 7)
def _base_bins() -> List[BinState]:
return [
BinState(bin_id="A1", position=(2, 1), sku="thermometer", quantity=2),
BinState(bin_id="A2", position=(2, 3), sku="cough_syrup", quantity=2),
BinState(bin_id="B1", position=(4, 1), sku="bandage_kit", quantity=2),
BinState(bin_id="B2", position=(4, 3), sku="pain_relief", quantity=2),
BinState(bin_id="C1", position=(2, 5), sku="gloves", quantity=2),
]
TASKS: Dict[str, TaskDefinition] = {
"easy_single_pick": TaskDefinition(
task_id="easy_single_pick",
difficulty="easy",
title="Single urgent order",
description=(
"Fulfill a same-hour pharmacy order by retrieving one thermometer "
"from the correct bin and packing it at the station."
),
max_steps=40,
battery_capacity=36,
low_battery_threshold=8,
agent_start=(1, 1),
agent_heading="E",
dock_position=(1, 1),
pack_station_position=(5, 5),
charger_position=(1, 5),
bins=_base_bins(),
order=[OrderLine(sku="thermometer", quantity=1)],
required_scans=["A1"],
rubric_criteria=[
{
"name": "completion",
"description": "Order fully packed.",
"check": "param_at_least:state.completion_ratio=1.0",
},
{
"name": "pick_item",
"description": "Picked at least one item.",
"check": "tool_used:pick_item",
},
{
"name": "pack_item",
"description": "Packed the order at the station.",
"check": "tool_used:pack_item",
},
{
"name": "no_wrong_picks",
"description": "No incorrect picks.",
"check": "param_at_most:state.wrong_picks=0",
},
{
"name": "no_invalid_actions",
"description": "No invalid actions.",
"check": "param_at_most:state.invalid_actions=0",
},
],
),
"medium_multi_item": TaskDefinition(
task_id="medium_multi_item",
difficulty="medium",
title="Two-line prescription basket",
description=(
"Fulfill a two-line order by scanning the relevant bins before each "
"pick, then pack one cough syrup and one pain relief unit."
),
max_steps=60,
battery_capacity=34,
low_battery_threshold=8,
agent_start=(1, 1),
agent_heading="E",
dock_position=(1, 1),
pack_station_position=(5, 5),
charger_position=(1, 5),
bins=_base_bins(),
order=[
OrderLine(sku="cough_syrup", quantity=1),
OrderLine(sku="pain_relief", quantity=1),
],
required_scans=["A2", "B2"],
rubric_criteria=[
{
"name": "completion",
"description": "All items packed.",
"check": "param_at_least:state.completion_ratio=1.0",
},
{
"name": "scans",
"description": "Scanned required bins.",
"check": "param_at_least:state.correct_scans=2",
},
{
"name": "pack_item",
"description": "Packed items at the station.",
"check": "tool_used:pack_item",
},
{
"name": "no_wrong_picks",
"description": "No incorrect picks.",
"check": "param_at_most:state.wrong_picks=0",
},
{
"name": "no_wrong_scans",
"description": "No incorrect scans.",
"check": "param_at_most:state.wrong_scans=0",
},
{
"name": "few_invalid_actions",
"description": "At most one invalid action.",
"check": "param_at_most:state.invalid_actions=1",
},
],
),
"hard_restock_priority": TaskDefinition(
task_id="hard_restock_priority",
difficulty="hard",
title="Priority basket with battery management",
description=(
"Fulfill a three-line urgent order while managing battery reserve. "
"The agent must scan each target bin, recharge when needed, and "
"pack a thermometer, gloves, and bandage kit."
),
max_steps=85,
battery_capacity=24,
low_battery_threshold=6,
agent_start=(1, 1),
agent_heading="E",
dock_position=(1, 1),
pack_station_position=(5, 5),
charger_position=(1, 5),
bins=_base_bins(),
order=[
OrderLine(sku="thermometer", quantity=1),
OrderLine(sku="gloves", quantity=1),
OrderLine(sku="bandage_kit", quantity=1),
],
required_scans=["A1", "C1", "B1"],
rubric_criteria=[
{
"name": "completion",
"description": "All items packed.",
"check": "param_at_least:state.completion_ratio=1.0",
},
{
"name": "scans",
"description": "Scanned all required bins.",
"check": "param_at_least:state.correct_scans=3",
},
{
"name": "recharge",
"description": "Recharged at least once.",
"check": "tool_used:recharge",
},
{
"name": "no_battery_depletion",
"description": "Avoided battery depletion.",
"check": "param_at_most:state.battery_depletion_events=0",
},
{
"name": "no_wrong_picks",
"description": "No incorrect picks.",
"check": "param_at_most:state.wrong_picks=0",
},
{
"name": "few_invalid_actions",
"description": "At most one invalid action.",
"check": "param_at_most:state.invalid_actions=1",
},
],
),
# -----------------------------------------------------------------------
# Task 4: obstacle_course (medium) — obstacles block direct paths
# -----------------------------------------------------------------------
"obstacle_course": TaskDefinition(
task_id="obstacle_course",
difficulty="medium",
title="Obstacle-filled aisle navigation",
description=(
"Fulfill a two-item order in a warehouse cluttered with fallen crates. "
"Navigate around obstacles to reach bins, scan them, pick one thermometer "
"and one bandage kit, then pack both at the station."
),
max_steps=70,
battery_capacity=40,
low_battery_threshold=10,
agent_start=(0, 0),
agent_heading="E",
dock_position=(0, 0),
pack_station_position=(6, 6),
charger_position=(0, 6),
bins=[
BinState(bin_id="A1", position=(2, 1), sku="thermometer", quantity=2),
BinState(bin_id="B1", position=(4, 1), sku="bandage_kit", quantity=2),
BinState(bin_id="A2", position=(2, 3), sku="cough_syrup", quantity=2),
BinState(bin_id="B2", position=(4, 3), sku="pain_relief", quantity=2),
BinState(bin_id="C1", position=(2, 5), sku="gloves", quantity=2),
],
order=[
OrderLine(sku="thermometer", quantity=1),
OrderLine(sku="bandage_kit", quantity=1),
],
required_scans=["A1", "B1"],
obstacles=[(1, 2), (2, 2), (3, 2), (3, 4), (4, 4), (5, 4)],
rubric_criteria=[
{
"name": "completion",
"description": "All items packed.",
"check": "param_at_least:state.completion_ratio=1.0",
},
{
"name": "scans",
"description": "Scanned both required bins.",
"check": "param_at_least:state.correct_scans=2",
},
{
"name": "pack_item",
"description": "Packed items at the station.",
"check": "tool_used:pack_item",
},
{
"name": "no_obstacle_collisions",
"description": "Avoided all obstacle collisions.",
"check": "param_at_most:state.obstacle_collisions=0",
},
{
"name": "no_wrong_picks",
"description": "No incorrect picks.",
"check": "param_at_most:state.wrong_picks=0",
},
{
"name": "few_invalid_actions",
"description": "At most two invalid actions.",
"check": "param_at_most:state.invalid_actions=2",
},
],
),
# -----------------------------------------------------------------------
# Task 5: heavy_lifting (hard) — items have weight, limited carry capacity
# -----------------------------------------------------------------------
"heavy_lifting": TaskDefinition(
task_id="heavy_lifting",
difficulty="hard",
title="Heavy-item logistics with weight limits",
description=(
"Fulfill a three-item order where items vary in weight (1-4 units). "
"The agent has a carry capacity of 3 and must choose pickup order wisely. "
"Heavier items drain more battery while moving. Scan each bin, pick items "
"that fit within your carry limit, and pack at the station. "
"The heavy pain_relief (weight 4) cannot be carried — skip it!"
),
max_steps=90,
battery_capacity=32,
low_battery_threshold=8,
agent_start=(1, 1),
agent_heading="E",
dock_position=(1, 1),
pack_station_position=(5, 5),
charger_position=(1, 5),
bins=[
BinState(bin_id="A1", position=(2, 1), sku="thermometer", quantity=3, weight=1),
BinState(bin_id="A2", position=(2, 3), sku="cough_syrup", quantity=2, weight=2),
BinState(bin_id="B1", position=(4, 1), sku="bandage_kit", quantity=2, weight=3),
BinState(bin_id="B2", position=(4, 3), sku="pain_relief", quantity=2, weight=4),
BinState(bin_id="C1", position=(2, 5), sku="gloves", quantity=3, weight=1),
],
order=[
OrderLine(sku="thermometer", quantity=1),
OrderLine(sku="cough_syrup", quantity=1),
OrderLine(sku="bandage_kit", quantity=1),
],
required_scans=["A1", "A2", "B1"],
carry_capacity=3,
rubric_criteria=[
{
"name": "completion",
"description": "All items packed.",
"check": "param_at_least:state.completion_ratio=1.0",
},
{
"name": "scans",
"description": "Scanned all three required bins.",
"check": "param_at_least:state.correct_scans=3",
},
{
"name": "recharge",
"description": "Recharged at least once.",
"check": "tool_used:recharge",
},
{
"name": "no_overweight",
"description": "Never tried to pick an overweight item.",
"check": "param_at_most:state.overweight_attempts=0",
},
{
"name": "no_battery_depletion",
"description": "Avoided battery depletion.",
"check": "param_at_most:state.battery_depletion_events=0",
},
{
"name": "no_wrong_picks",
"description": "No incorrect picks.",
"check": "param_at_most:state.wrong_picks=0",
},
{
"name": "few_invalid_actions",
"description": "At most two invalid actions.",
"check": "param_at_most:state.invalid_actions=2",
},
],
),
# -----------------------------------------------------------------------
# Task 6: stamina_run (hard) — stamina drains on movement
# -----------------------------------------------------------------------
"stamina_run": TaskDefinition(
task_id="stamina_run",
difficulty="hard",
title="Endurance run with stamina management",
description=(
"Fulfill a two-item order while managing stamina. Every move drains stamina; "
"when stamina hits zero, movement costs double battery. Rest at the rest area "
"to restore stamina. Pick one cough syrup and one gloves unit, scan bins, and "
"pack at the station without running out of energy."
),
max_steps=80,
battery_capacity=36,
low_battery_threshold=8,
agent_start=(0, 0),
agent_heading="E",
dock_position=(0, 0),
pack_station_position=(6, 6),
charger_position=(0, 6),
rest_position=(3, 3),
stamina_capacity=12,
stamina_move_cost=1,
bins=[
BinState(bin_id="A1", position=(2, 1), sku="thermometer", quantity=2),
BinState(bin_id="A2", position=(2, 3), sku="cough_syrup", quantity=2),
BinState(bin_id="B1", position=(4, 1), sku="bandage_kit", quantity=2),
BinState(bin_id="B2", position=(4, 3), sku="pain_relief", quantity=2),
BinState(bin_id="C1", position=(2, 5), sku="gloves", quantity=2),
],
order=[
OrderLine(sku="cough_syrup", quantity=1),
OrderLine(sku="gloves", quantity=1),
],
required_scans=["A2", "C1"],
rubric_criteria=[
{
"name": "completion",
"description": "All items packed.",
"check": "param_at_least:state.completion_ratio=1.0",
},
{
"name": "scans",
"description": "Scanned both required bins.",
"check": "param_at_least:state.correct_scans=2",
},
{
"name": "rest_used",
"description": "Used the rest area at least once.",
"check": "tool_used:rest",
},
{
"name": "no_stamina_depletion",
"description": "Avoided complete stamina depletion.",
"check": "param_at_most:state.stamina_depletion_events=0",
},
{
"name": "no_battery_depletion",
"description": "Avoided battery depletion.",
"check": "param_at_most:state.battery_depletion_events=0",
},
{
"name": "no_wrong_picks",
"description": "No incorrect picks.",
"check": "param_at_most:state.wrong_picks=0",
},
],
),
# -----------------------------------------------------------------------
# Task 7: budget_run (expert) — money rewards and profit target
# -----------------------------------------------------------------------
"budget_run": TaskDefinition(
task_id="budget_run",
difficulty="expert",
title="Profitable fulfillment under budget pressure",
description=(
"Fulfill orders for profit. Each item has a dollar value earned when correctly "
"packed. Wrong packs lose half the item value. You must reach a profit target "
"of $15.00 while completing the order. Pick high-value items efficiently: "
"2 thermometers ($5 each) and 1 bandage kit ($8). Budget-aware decisions matter."
),
max_steps=70,
battery_capacity=30,
low_battery_threshold=6,
agent_start=(1, 1),
agent_heading="E",
dock_position=(1, 1),
pack_station_position=(5, 5),
charger_position=(1, 5),
bins=[
BinState(bin_id="A1", position=(2, 1), sku="thermometer", quantity=3, value=5.0),
BinState(bin_id="A2", position=(2, 3), sku="cough_syrup", quantity=2, value=3.0),
BinState(bin_id="B1", position=(4, 1), sku="bandage_kit", quantity=2, value=8.0),
BinState(bin_id="B2", position=(4, 3), sku="pain_relief", quantity=2, value=4.0),
BinState(bin_id="C1", position=(2, 5), sku="gloves", quantity=2, value=2.0),
],
order=[
OrderLine(sku="thermometer", quantity=2),
OrderLine(sku="bandage_kit", quantity=1),
],
required_scans=["A1", "B1"],
profit_target=15.0,
rubric_criteria=[
{
"name": "completion",
"description": "All items packed.",
"check": "param_at_least:state.completion_ratio=1.0",
},
{
"name": "profit_target",
"description": "Reached the profit target of $15.",
"check": "param_at_least:state.money_earned=15.0",
},
{
"name": "scans",
"description": "Scanned required bins.",
"check": "param_at_least:state.correct_scans=2",
},
{
"name": "recharge",
"description": "Recharged at least once.",
"check": "tool_used:recharge",
},
{
"name": "no_money_lost",
"description": "No money lost from wrong packs.",
"check": "param_at_most:state.money_lost=0.0",
},
{
"name": "no_wrong_picks",
"description": "No incorrect picks.",
"check": "param_at_most:state.wrong_picks=0",
},
{
"name": "few_invalid_actions",
"description": "At most one invalid action.",
"check": "param_at_most:state.invalid_actions=1",
},
],
),
# -----------------------------------------------------------------------
# Task 8: gauntlet (expert) — all mechanics combined
# -----------------------------------------------------------------------
"gauntlet": TaskDefinition(
task_id="gauntlet",
difficulty="expert",
title="The gauntlet: obstacles, weight, stamina, and profit",
description=(
"The ultimate warehouse challenge. Navigate a cluttered warehouse with obstacles, "
"manage item weights (carry capacity 3), conserve stamina (rest when needed), "
"earn money for packed items, and hit a $20 profit target. Fulfill a four-item "
"order: 1 thermometer ($5, wt 1), 1 cough syrup ($6, wt 2), 1 bandage kit ($8, wt 3), "
"and 1 gloves ($4, wt 1). Recharge battery, rest for stamina, avoid obstacles, "
"and finish profitable."
),
max_steps=120,
battery_capacity=28,
low_battery_threshold=7,
agent_start=(0, 0),
agent_heading="S",
dock_position=(0, 0),
pack_station_position=(6, 6),
charger_position=(6, 0),
rest_position=(0, 6),
stamina_capacity=10,
stamina_move_cost=1,
carry_capacity=3,
profit_target=20.0,
obstacles=[(1, 1), (3, 1), (5, 3), (3, 3), (1, 5), (5, 5)],
bins=[
BinState(bin_id="A1", position=(2, 0), sku="thermometer", quantity=3, weight=1, value=5.0),
BinState(bin_id="A2", position=(2, 4), sku="cough_syrup", quantity=2, weight=2, value=6.0),
BinState(bin_id="B1", position=(4, 0), sku="bandage_kit", quantity=2, weight=3, value=8.0),
BinState(bin_id="B2", position=(4, 4), sku="pain_relief", quantity=2, weight=4, value=4.0),
BinState(bin_id="C1", position=(4, 2), sku="gloves", quantity=3, weight=1, value=4.0),
],
order=[
OrderLine(sku="thermometer", quantity=1),
OrderLine(sku="cough_syrup", quantity=1),
OrderLine(sku="bandage_kit", quantity=1),
OrderLine(sku="gloves", quantity=1),
],
required_scans=["A1", "A2", "B1", "C1"],
rubric_criteria=[
{
"name": "completion",
"description": "All four items packed.",
"check": "param_at_least:state.completion_ratio=1.0",
},
{
"name": "profit_target",
"description": "Reached $20 profit target.",
"check": "param_at_least:state.money_earned=20.0",
},
{
"name": "scans",
"description": "Scanned all four required bins.",
"check": "param_at_least:state.correct_scans=4",
},
{
"name": "recharge",
"description": "Recharged at least once.",
"check": "tool_used:recharge",
},
{
"name": "rest_used",
"description": "Used the rest area at least once.",
"check": "tool_used:rest",
},
{
"name": "no_obstacle_collisions",
"description": "Avoided all obstacle collisions.",
"check": "param_at_most:state.obstacle_collisions=0",
},
{
"name": "no_overweight",
"description": "Never tried to pick an overweight item.",
"check": "param_at_most:state.overweight_attempts=0",
},
{
"name": "no_battery_depletion",
"description": "Avoided battery depletion.",
"check": "param_at_most:state.battery_depletion_events=0",
},
{
"name": "no_stamina_depletion",
"description": "Avoided stamina depletion.",
"check": "param_at_most:state.stamina_depletion_events=0",
},
{
"name": "no_wrong_picks",
"description": "No incorrect picks.",
"check": "param_at_most:state.wrong_picks=0",
},
{
"name": "few_invalid_actions",
"description": "At most two invalid actions.",
"check": "param_at_most:state.invalid_actions=2",
},
],
),
}
def get_task(task_id: str) -> TaskDefinition:
if task_id not in TASKS:
raise KeyError(f"Unknown task_id: {task_id}")
return TASKS[task_id]
|