plancraft 0.4.3__py3-none-any.whl → 0.4.4__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/planner.py +24 -5
- {plancraft-0.4.3.dist-info → plancraft-0.4.4.dist-info}/METADATA +1 -1
- {plancraft-0.4.3.dist-info → plancraft-0.4.4.dist-info}/RECORD +5 -5
- {plancraft-0.4.3.dist-info → plancraft-0.4.4.dist-info}/WHEEL +0 -0
- {plancraft-0.4.3.dist-info → plancraft-0.4.4.dist-info}/licenses/LICENSE +0 -0
plancraft/environment/planner.py
CHANGED
@@ -234,11 +234,13 @@ def get_plan(observation: dict):
|
|
234
234
|
|
235
235
|
def decompose_subgoal(
|
236
236
|
current_inventory: dict, plan_recipe, new_inventory: dict[str, int]
|
237
|
-
) -> list[str]:
|
237
|
+
) -> tuple[list[str], dict[str, int], list[str]]:
|
238
238
|
"""
|
239
239
|
For a given plan_recipe and inventory, output the list of action to craft recipe
|
240
240
|
"""
|
241
241
|
subplan = []
|
242
|
+
# track the item type used in each action's from_slot
|
243
|
+
action_items_used = []
|
242
244
|
new_inventory_counter = Counter(new_inventory)
|
243
245
|
current_inventory_counter = get_inventory_counter(current_inventory)
|
244
246
|
items_to_use_counter = current_inventory_counter - new_inventory_counter
|
@@ -264,6 +266,7 @@ def decompose_subgoal(
|
|
264
266
|
action = SmeltAction(
|
265
267
|
slot_from=from_slot, slot_to=free_slot, quantity=quantity
|
266
268
|
)
|
269
|
+
action_items_used.append(current_inventory[from_slot]["type"])
|
267
270
|
subplan.append(str(action))
|
268
271
|
|
269
272
|
# update inventory to decrement quantity of item in from_slot and increment quantity of item in free_slot
|
@@ -280,7 +283,7 @@ def decompose_subgoal(
|
|
280
283
|
if current_inventory[from_slot]["quantity"] <= 0:
|
281
284
|
del current_inventory[from_slot]
|
282
285
|
|
283
|
-
return subplan, current_inventory
|
286
|
+
return subplan, current_inventory, action_items_used
|
284
287
|
|
285
288
|
elif isinstance(plan_recipe, ShapelessRecipe):
|
286
289
|
crafting_slot = 1
|
@@ -314,6 +317,7 @@ def decompose_subgoal(
|
|
314
317
|
slot_to=free_slot,
|
315
318
|
quantity=current_inventory[crafting_slot]["quantity"],
|
316
319
|
)
|
320
|
+
action_items_used.append(current_inventory[crafting_slot]["type"])
|
317
321
|
subplan.append(str(action))
|
318
322
|
current_inventory = update_inventory(
|
319
323
|
current_inventory,
|
@@ -331,6 +335,7 @@ def decompose_subgoal(
|
|
331
335
|
action = MoveAction(
|
332
336
|
slot_from=from_slot, slot_to=crafting_slot, quantity=1
|
333
337
|
)
|
338
|
+
action_items_used.append(current_inventory[from_slot]["type"])
|
334
339
|
subplan.append(str(action))
|
335
340
|
current_inventory = update_inventory(
|
336
341
|
current_inventory, from_slot, crafting_slot, 1
|
@@ -366,6 +371,9 @@ def decompose_subgoal(
|
|
366
371
|
slot_to=free_slot,
|
367
372
|
quantity=current_inventory[inventory_position]["quantity"],
|
368
373
|
)
|
374
|
+
action_items_used.append(
|
375
|
+
current_inventory[inventory_position]["type"]
|
376
|
+
)
|
369
377
|
current_inventory = update_inventory(
|
370
378
|
current_inventory,
|
371
379
|
inventory_position,
|
@@ -411,6 +419,9 @@ def decompose_subgoal(
|
|
411
419
|
"quantity"
|
412
420
|
],
|
413
421
|
)
|
422
|
+
action_items_used.append(
|
423
|
+
current_inventory[inventory_position]["type"]
|
424
|
+
)
|
414
425
|
current_inventory = update_inventory(
|
415
426
|
current_inventory,
|
416
427
|
inventory_position,
|
@@ -428,6 +439,7 @@ def decompose_subgoal(
|
|
428
439
|
slot_to=inventory_position,
|
429
440
|
quantity=1,
|
430
441
|
)
|
442
|
+
action_items_used.append(current_inventory[from_slot]["type"])
|
431
443
|
items_to_use_counter[item] -= 1
|
432
444
|
added_item = True
|
433
445
|
# update state of inventory
|
@@ -446,6 +458,7 @@ def decompose_subgoal(
|
|
446
458
|
slot_to=free_slot,
|
447
459
|
quantity=current_inventory[slot]["quantity"],
|
448
460
|
)
|
461
|
+
action_items_used.append(current_inventory[slot]["type"])
|
449
462
|
current_inventory = update_inventory(
|
450
463
|
current_inventory,
|
451
464
|
slot,
|
@@ -469,6 +482,7 @@ def decompose_subgoal(
|
|
469
482
|
)
|
470
483
|
)
|
471
484
|
)
|
485
|
+
action_items_used.append(current_inventory[0]["type"])
|
472
486
|
current_inventory = update_inventory(
|
473
487
|
current_inventory, 0, free_slot, plan_recipe.result.count
|
474
488
|
)
|
@@ -479,10 +493,10 @@ def decompose_subgoal(
|
|
479
493
|
if current_inventory[i]["quantity"] <= 0:
|
480
494
|
del current_inventory[i]
|
481
495
|
|
482
|
-
return subplan, current_inventory
|
496
|
+
return subplan, current_inventory, action_items_used
|
483
497
|
|
484
498
|
|
485
|
-
def get_subplans(observation: dict) -> tuple[list[list[str]], list]:
|
499
|
+
def get_subplans(observation: dict, return_items=False) -> tuple[list[list[str]], list]:
|
486
500
|
current_inventory = copy.deepcopy(observation["inventory"])
|
487
501
|
plan = get_plan(observation)
|
488
502
|
# get action
|
@@ -490,10 +504,15 @@ def get_subplans(observation: dict) -> tuple[list[list[str]], list]:
|
|
490
504
|
return [[str(StopAction())]], []
|
491
505
|
# plan_recipe, new_inventory = plan[0]
|
492
506
|
subplans = []
|
507
|
+
action_items_used = []
|
508
|
+
|
493
509
|
# Calculate the subplans for each step in the plan
|
494
510
|
for plan_recipe, new_inventory in plan:
|
495
|
-
subplan, current_inventory = decompose_subgoal(
|
511
|
+
subplan, current_inventory, action_items = decompose_subgoal(
|
496
512
|
current_inventory, plan_recipe, new_inventory
|
497
513
|
)
|
498
514
|
subplans.append(subplan)
|
515
|
+
action_items_used.append(action_items)
|
516
|
+
if return_items:
|
517
|
+
return subplans, plan, action_items_used
|
499
518
|
return subplans, plan
|
@@ -17,7 +17,7 @@ plancraft/environment/__init__.py,sha256=XFsFny4lH195AwAmL-WeCaF9ZCMgc7IgXIwhQ8F
|
|
17
17
|
plancraft/environment/actions.py,sha256=Pub21caxM5iZ9IaX-ny1-xxr_peJIwwV_QAx3BVSry0,11551
|
18
18
|
plancraft/environment/env.py,sha256=B7VpIMcQKITyDmkHgBoR4KbmxmM1b4A6Y-1_b90EMXo,16428
|
19
19
|
plancraft/environment/items.py,sha256=Z9rhSyVDEoHF1pxRvhyiT94tyQJaWHi3wUHVcamz82o,221
|
20
|
-
plancraft/environment/planner.py,sha256
|
20
|
+
plancraft/environment/planner.py,sha256=-ZN6MSQxMTNfexa6ixzzFKK-qBSB4jbxOJLtknnHju8,20437
|
21
21
|
plancraft/environment/prompts.py,sha256=NU9YHAz3id-IgaukQvEi5uLlpEstpE5_Hccvvq1At2Y,6950
|
22
22
|
plancraft/environment/recipes.py,sha256=0vwzOU86eZmGN2EpZVSIvzxpx0AOBWNPxTtAOFBN2A0,19570
|
23
23
|
plancraft/environment/sampler.py,sha256=BworSMWQ-TLbV9068tkNOdo4ZLP-UDox6Laeb4Weu9k,7723
|
@@ -1923,7 +1923,7 @@ plancraft/models/generators.py,sha256=7COMLjjx_HbTWJqINNLqqExQv7gLikfLTViacAdSt5
|
|
1923
1923
|
plancraft/models/oracle.py,sha256=f-0KWlBuHy6wcxmDsxM3MQ_QwfBstzfbA26mlk1MgLA,1657
|
1924
1924
|
plancraft/models/utils.py,sha256=xgkP5jqCeFfkKe3Xd4ZYfTqiEJ-dA-qgFAC-J35ub3E,4029
|
1925
1925
|
plancraft/train/dataset.py,sha256=oFqEd4LG9oEQ-71teh0Wf7-jJbtybT2ZibfM2bBdBkM,5474
|
1926
|
-
plancraft-0.4.
|
1927
|
-
plancraft-0.4.
|
1928
|
-
plancraft-0.4.
|
1929
|
-
plancraft-0.4.
|
1926
|
+
plancraft-0.4.4.dist-info/METADATA,sha256=Yjro1BL1G5QoDlC8v_RStAtPZykvO5pDOwdaHV_8U-c,12391
|
1927
|
+
plancraft-0.4.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
1928
|
+
plancraft-0.4.4.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
|
1929
|
+
plancraft-0.4.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|