plancraft 0.4.7__py3-none-any.whl → 0.4.9__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.
- plancraft/environment/actions.py +10 -0
- plancraft/environment/planner.py +40 -1
- {plancraft-0.4.7.dist-info → plancraft-0.4.9.dist-info}/METADATA +1 -1
- {plancraft-0.4.7.dist-info → plancraft-0.4.9.dist-info}/RECORD +6 -6
- {plancraft-0.4.7.dist-info → plancraft-0.4.9.dist-info}/WHEEL +0 -0
- {plancraft-0.4.7.dist-info → plancraft-0.4.9.dist-info}/licenses/LICENSE +0 -0
plancraft/environment/actions.py
CHANGED
@@ -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
|
|
plancraft/environment/planner.py
CHANGED
@@ -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,
|
@@ -500,7 +501,9 @@ def decompose_subgoal(
|
|
500
501
|
|
501
502
|
|
502
503
|
def get_subplans(
|
503
|
-
observation: dict,
|
504
|
+
observation: dict,
|
505
|
+
return_items=False,
|
506
|
+
clear_first=False,
|
504
507
|
) -> tuple[list[list[str]], list, list[str]] | tuple[list[list[str]], list]:
|
505
508
|
current_inventory = copy.deepcopy(observation["inventory"])
|
506
509
|
plan = get_plan(observation)
|
@@ -513,6 +516,31 @@ def get_subplans(
|
|
513
516
|
subplans = []
|
514
517
|
action_items_used = []
|
515
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
|
+
action_items = []
|
524
|
+
for slot in range(1, 10): # crafting grid slots 1-9
|
525
|
+
if slot in current_inventory and current_inventory[slot]["quantity"] > 0:
|
526
|
+
free_slot = find_free_inventory_slot(current_inventory, from_slot=slot)
|
527
|
+
action = MoveAction(
|
528
|
+
slot_from=slot,
|
529
|
+
slot_to=free_slot,
|
530
|
+
quantity=current_inventory[slot]["quantity"],
|
531
|
+
)
|
532
|
+
subplan.append(str(action))
|
533
|
+
action_items.append(current_inventory[slot]["type"])
|
534
|
+
current_inventory = update_inventory(
|
535
|
+
current_inventory,
|
536
|
+
slot,
|
537
|
+
free_slot,
|
538
|
+
current_inventory[slot]["quantity"],
|
539
|
+
)
|
540
|
+
if subplan: # only add clear subplan if there were items to clear
|
541
|
+
subplans.append(subplan)
|
542
|
+
action_items_used.append([action_items])
|
543
|
+
|
516
544
|
# Calculate the subplans for each step in the plan
|
517
545
|
for plan_recipe, new_inventory in plan:
|
518
546
|
subplan, current_inventory, action_items = decompose_subgoal(
|
@@ -520,6 +548,17 @@ def get_subplans(
|
|
520
548
|
)
|
521
549
|
subplans.append(subplan)
|
522
550
|
action_items_used.append(action_items)
|
551
|
+
|
552
|
+
# If we added a clear action, we need to modify the plan to include it
|
553
|
+
if clear_first and len(subplans) > len(plan):
|
554
|
+
# Insert a fake clear action at the beginning of the plan
|
555
|
+
clear_action = ClearAction()
|
556
|
+
plan_inventory_counter = copy.deepcopy(plan[0][1])
|
557
|
+
plan = [(clear_action, plan_inventory_counter)] + plan
|
558
|
+
|
559
|
+
# If we are returning items, we need to return the action items used
|
560
|
+
# this is a list of the item (from_slot) used in each action
|
523
561
|
if return_items:
|
524
562
|
return subplans, plan, action_items_used
|
563
|
+
|
525
564
|
return subplans, plan
|
@@ -15,10 +15,10 @@ plancraft/data/val.repeated.json,sha256=gLeCg94oB0B_e8QyH8-FBygcJctGA4bkXYldoOHt
|
|
15
15
|
plancraft/data/val.small.easy.json,sha256=9zEmqepjXG2NIp88xnFqOCkwsUsku3HEwHoQGxgTr6U,190252
|
16
16
|
plancraft/data/val.small.json,sha256=76E9EFaljDQyAokg97e-IblvcOe6KbrdKkXvRxhhkgo,237653
|
17
17
|
plancraft/environment/__init__.py,sha256=XFsFny4lH195AwAmL-WeCaF9ZCMgc7IgXIwhQ8FTdgE,505
|
18
|
-
plancraft/environment/actions.py,sha256=
|
18
|
+
plancraft/environment/actions.py,sha256=bMHR8bmgE_DD10K4Bii_QRgTs-GPkcgw9NKwHDoDmyQ,11813
|
19
19
|
plancraft/environment/env.py,sha256=B7VpIMcQKITyDmkHgBoR4KbmxmM1b4A6Y-1_b90EMXo,16428
|
20
20
|
plancraft/environment/items.py,sha256=Z9rhSyVDEoHF1pxRvhyiT94tyQJaWHi3wUHVcamz82o,221
|
21
|
-
plancraft/environment/planner.py,sha256=
|
21
|
+
plancraft/environment/planner.py,sha256=TKOMMqdBtk0dSc8X-ZgMnFeQnG_gzp99i3PHP-WI_hE,22415
|
22
22
|
plancraft/environment/prompts.py,sha256=NU9YHAz3id-IgaukQvEi5uLlpEstpE5_Hccvvq1At2Y,6950
|
23
23
|
plancraft/environment/recipes.py,sha256=0vwzOU86eZmGN2EpZVSIvzxpx0AOBWNPxTtAOFBN2A0,19570
|
24
24
|
plancraft/environment/sampler.py,sha256=BworSMWQ-TLbV9068tkNOdo4ZLP-UDox6Laeb4Weu9k,7723
|
@@ -1924,7 +1924,7 @@ plancraft/models/generators.py,sha256=7COMLjjx_HbTWJqINNLqqExQv7gLikfLTViacAdSt5
|
|
1924
1924
|
plancraft/models/oracle.py,sha256=f-0KWlBuHy6wcxmDsxM3MQ_QwfBstzfbA26mlk1MgLA,1657
|
1925
1925
|
plancraft/models/utils.py,sha256=xgkP5jqCeFfkKe3Xd4ZYfTqiEJ-dA-qgFAC-J35ub3E,4029
|
1926
1926
|
plancraft/train/dataset.py,sha256=oFqEd4LG9oEQ-71teh0Wf7-jJbtybT2ZibfM2bBdBkM,5474
|
1927
|
-
plancraft-0.4.
|
1928
|
-
plancraft-0.4.
|
1929
|
-
plancraft-0.4.
|
1930
|
-
plancraft-0.4.
|
1927
|
+
plancraft-0.4.9.dist-info/METADATA,sha256=jS7Fsd8WyiqI9w7joE9onIe8QJ339Lvo7vAxi3ihV6s,12391
|
1928
|
+
plancraft-0.4.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
1929
|
+
plancraft-0.4.9.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
|
1930
|
+
plancraft-0.4.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|