plancraft 0.4.6__py3-none-any.whl → 0.4.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -216,6 +216,16 @@ class StopAction(BaseModel):
216
216
  return f"impossible: {self.reason}"
217
217
 
218
218
 
219
+ class ClearAction(BaseModel):
220
+ """
221
+ Fake action that represents clearing the crafting grid by moving all items to inventory slots
222
+ Used for a more semantically aware planner step
223
+ """
224
+
225
+ def __str__(self):
226
+ return "clearing crafting grid"
227
+
228
+
219
229
  # when symbolic action is true, can either move objects around or smelt
220
230
  SymbolicAction = MoveAction | SmeltAction
221
231
 
@@ -5,6 +5,7 @@ from collections import Counter
5
5
  import networkx as nx
6
6
 
7
7
  from plancraft.environment.actions import (
8
+ ClearAction,
8
9
  MoveAction,
9
10
  SmeltAction,
10
11
  StopAction,
@@ -392,7 +393,8 @@ def decompose_subgoal(
392
393
 
393
394
  # if item is already in the correct position, skip
394
395
  if (
395
- inventory_position in current_inventory
396
+ items_to_use_counter[item] > 0
397
+ and inventory_position in current_inventory
396
398
  and current_inventory[inventory_position]["type"] == item
397
399
  ) and current_inventory[inventory_position]["quantity"] > 0:
398
400
  min_quantity_needed.add(inventory_position)
@@ -441,6 +443,8 @@ def decompose_subgoal(
441
443
  )
442
444
  action_items_used.append(current_inventory[from_slot]["type"])
443
445
  items_to_use_counter[item] -= 1
446
+ if items_to_use_counter[item] == 0:
447
+ del items_to_use_counter[item]
444
448
  added_item = True
445
449
  # update state of inventory
446
450
  current_inventory = update_inventory(
@@ -497,7 +501,9 @@ def decompose_subgoal(
497
501
 
498
502
 
499
503
  def get_subplans(
500
- observation: dict, return_items=False
504
+ observation: dict,
505
+ return_items=False,
506
+ clear_first=False,
501
507
  ) -> tuple[list[list[str]], list, list[str]] | tuple[list[list[str]], list]:
502
508
  current_inventory = copy.deepcopy(observation["inventory"])
503
509
  plan = get_plan(observation)
@@ -510,6 +516,29 @@ def get_subplans(
510
516
  subplans = []
511
517
  action_items_used = []
512
518
 
519
+ if clear_first:
520
+ # move all the current stuff in the crafting grid to free inventory slots
521
+ # While this makes a worse planner, this makes a clearer distinction between crafting steps
522
+ subplan = []
523
+ for slot in range(1, 10): # crafting grid slots 1-9
524
+ if slot in current_inventory and current_inventory[slot]["quantity"] > 0:
525
+ free_slot = find_free_inventory_slot(current_inventory, from_slot=slot)
526
+ action = MoveAction(
527
+ slot_from=slot,
528
+ slot_to=free_slot,
529
+ quantity=current_inventory[slot]["quantity"],
530
+ )
531
+ subplan.append(str(action))
532
+ current_inventory = update_inventory(
533
+ current_inventory,
534
+ slot,
535
+ free_slot,
536
+ current_inventory[slot]["quantity"],
537
+ )
538
+ if subplan: # only add clear subplan if there were items to clear
539
+ subplans.append(subplan)
540
+ action_items_used.append([])
541
+
513
542
  # Calculate the subplans for each step in the plan
514
543
  for plan_recipe, new_inventory in plan:
515
544
  subplan, current_inventory, action_items = decompose_subgoal(
@@ -517,6 +546,14 @@ def get_subplans(
517
546
  )
518
547
  subplans.append(subplan)
519
548
  action_items_used.append(action_items)
549
+
550
+ # If we added a clear action, we need to modify the plan to include it
551
+ if clear_first and len(subplans) > len(plan):
552
+ # Insert a fake clear action at the beginning of the plan
553
+ clear_action = ClearAction()
554
+ plan_inventory_counter = copy.deepcopy(plan[0][1])
555
+ plan = [(clear_action, plan_inventory_counter)] + plan
556
+
520
557
  if return_items:
521
558
  return subplans, plan, action_items_used
522
559
  return subplans, plan
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plancraft
3
- Version: 0.4.6
3
+ Version: 0.4.8
4
4
  Summary: Plancraft: an evaluation dataset for planning with LLM agents
5
5
  License: MIT License
6
6
 
@@ -11,13 +11,14 @@ plancraft/data/test.small.easy.json,sha256=5NZEJ2PqIgmHQecJOIVQyM1D6GFKyJq7GVmgR
11
11
  plancraft/data/test.small.json,sha256=eULAG1rdolRMXPrecV-7YoDIheKGyIT5MVpWdISV0wg,270089
12
12
  plancraft/data/train.json,sha256=asZIFnkBdgupPKRXacM4J0Ngt21B2BrMT6oPgFA96HI,2697710
13
13
  plancraft/data/val.json,sha256=IToAiaqUNQi_xhX1bzmInuskLaT7C2ryQjP-CZkzL24,1304403
14
+ plancraft/data/val.repeated.json,sha256=gLeCg94oB0B_e8QyH8-FBygcJctGA4bkXYldoOHtSfQ,1726468
14
15
  plancraft/data/val.small.easy.json,sha256=9zEmqepjXG2NIp88xnFqOCkwsUsku3HEwHoQGxgTr6U,190252
15
16
  plancraft/data/val.small.json,sha256=76E9EFaljDQyAokg97e-IblvcOe6KbrdKkXvRxhhkgo,237653
16
17
  plancraft/environment/__init__.py,sha256=XFsFny4lH195AwAmL-WeCaF9ZCMgc7IgXIwhQ8FTdgE,505
17
- plancraft/environment/actions.py,sha256=Pub21caxM5iZ9IaX-ny1-xxr_peJIwwV_QAx3BVSry0,11551
18
+ plancraft/environment/actions.py,sha256=bMHR8bmgE_DD10K4Bii_QRgTs-GPkcgw9NKwHDoDmyQ,11813
18
19
  plancraft/environment/env.py,sha256=B7VpIMcQKITyDmkHgBoR4KbmxmM1b4A6Y-1_b90EMXo,16428
19
20
  plancraft/environment/items.py,sha256=Z9rhSyVDEoHF1pxRvhyiT94tyQJaWHi3wUHVcamz82o,221
20
- plancraft/environment/planner.py,sha256=ZrCFQKyW5eqN07f5v4XUhnUxwK85gluWc5u7pEHMhiI,20517
21
+ plancraft/environment/planner.py,sha256=Mw-fEfJPxqAf4mJedH4-6K4qng5xmTzSzzAGmhHf16U,22169
21
22
  plancraft/environment/prompts.py,sha256=NU9YHAz3id-IgaukQvEi5uLlpEstpE5_Hccvvq1At2Y,6950
22
23
  plancraft/environment/recipes.py,sha256=0vwzOU86eZmGN2EpZVSIvzxpx0AOBWNPxTtAOFBN2A0,19570
23
24
  plancraft/environment/sampler.py,sha256=BworSMWQ-TLbV9068tkNOdo4ZLP-UDox6Laeb4Weu9k,7723
@@ -1923,7 +1924,7 @@ plancraft/models/generators.py,sha256=7COMLjjx_HbTWJqINNLqqExQv7gLikfLTViacAdSt5
1923
1924
  plancraft/models/oracle.py,sha256=f-0KWlBuHy6wcxmDsxM3MQ_QwfBstzfbA26mlk1MgLA,1657
1924
1925
  plancraft/models/utils.py,sha256=xgkP5jqCeFfkKe3Xd4ZYfTqiEJ-dA-qgFAC-J35ub3E,4029
1925
1926
  plancraft/train/dataset.py,sha256=oFqEd4LG9oEQ-71teh0Wf7-jJbtybT2ZibfM2bBdBkM,5474
1926
- plancraft-0.4.6.dist-info/METADATA,sha256=GYJLfVMx2iKQeXNhHUbhZsNTDND2ZNZCR6s1jDl0gv4,12391
1927
- plancraft-0.4.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1928
- plancraft-0.4.6.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
1929
- plancraft-0.4.6.dist-info/RECORD,,
1927
+ plancraft-0.4.8.dist-info/METADATA,sha256=obqlXXK80FBjyK3x1a6_MEvipOeepxFpngP6j7Odf_s,12391
1928
+ plancraft-0.4.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1929
+ plancraft-0.4.8.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
1930
+ plancraft-0.4.8.dist-info/RECORD,,