plancraft 0.4.7__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.
- plancraft/environment/actions.py +10 -0
- plancraft/environment/planner.py +35 -1
- {plancraft-0.4.7.dist-info → plancraft-0.4.8.dist-info}/METADATA +1 -1
- {plancraft-0.4.7.dist-info → plancraft-0.4.8.dist-info}/RECORD +6 -6
- {plancraft-0.4.7.dist-info → plancraft-0.4.8.dist-info}/WHEEL +0 -0
- {plancraft-0.4.7.dist-info → plancraft-0.4.8.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,29 @@ 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
|
+
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
|
+
|
516
542
|
# Calculate the subplans for each step in the plan
|
517
543
|
for plan_recipe, new_inventory in plan:
|
518
544
|
subplan, current_inventory, action_items = decompose_subgoal(
|
@@ -520,6 +546,14 @@ def get_subplans(
|
|
520
546
|
)
|
521
547
|
subplans.append(subplan)
|
522
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
|
+
|
523
557
|
if return_items:
|
524
558
|
return subplans, plan, action_items_used
|
525
559
|
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=Mw-fEfJPxqAf4mJedH4-6K4qng5xmTzSzzAGmhHf16U,22169
|
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.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,,
|
File without changes
|
File without changes
|