plancraft 0.3.25__py3-none-any.whl → 0.3.27__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.
@@ -5,6 +5,14 @@ from typing import Optional
5
5
  from pydantic import BaseModel, field_validator, model_validator
6
6
 
7
7
 
8
+ # [A1], [A2], [A3], [B1], [B2], [B3], [C1], [C2], [C3], [I1]-[I36]
9
+ SLOT_REGEX_PATTERN = r"\[([ABC][0-9]|I[1-9]|I[12][0-9]|I3[0-6])\]"
10
+ # [0], [A1], [A2], [A3], [B1], [B2], [B3], [C1], [C2], [C3], [I1]-[I36]
11
+ SLOT_REGEX_PATTERN_WITH_CRAFTING_SLOT = r"\[(0|[ABC][0-9]|I[1-9]|I[12][0-9]|I3[0-6])\]"
12
+ # 1-64
13
+ QUANTITY_REGEX_PATTERN = r"([1-9]|[1-5][0-9]|6[0-4])"
14
+
15
+
8
16
  def convert_to_slot_index(slot: str) -> int:
9
17
  slot = slot.strip()
10
18
  grid_map = {
@@ -22,6 +30,10 @@ def convert_to_slot_index(slot: str) -> int:
22
30
  if slot in grid_map:
23
31
  return grid_map[slot]
24
32
  else:
33
+ # check if it is an inventory slot
34
+ if len(slot) < 4 or len(slot) > 5 or slot[1] != "I" or slot[2] == "0":
35
+ raise ValueError("Invalid slot index")
36
+ # convert I1 to 10, I2 to 11, I3 to 12, ..., I36 to 45
25
37
  return int(slot[2:-1]) + 9
26
38
 
27
39
 
@@ -40,8 +52,9 @@ def convert_from_slot_index(slot_index: int) -> str:
40
52
  }
41
53
  if slot_index < 10:
42
54
  return grid_map[slot_index]
43
- else:
55
+ elif slot_index < 46:
44
56
  return f"[I{slot_index-9}]"
57
+ raise ValueError("Invalid slot index")
45
58
 
46
59
 
47
60
  class ActionHandlerBase(abc.ABC):
@@ -218,9 +231,7 @@ class MoveActionHandler(ActionHandlerBase):
218
231
 
219
232
  @property
220
233
  def regex_pattern(self) -> str:
221
- return (
222
- r"move: from \[(0|[ABCI][0-9])\] to \[(0|[ABCI][0-9])\] with quantity \d+"
223
- )
234
+ return rf"move: from {SLOT_REGEX_PATTERN_WITH_CRAFTING_SLOT} to {SLOT_REGEX_PATTERN} with quantity {QUANTITY_REGEX_PATTERN}"
224
235
 
225
236
  @property
226
237
  def action_name(self) -> str:
@@ -258,9 +269,7 @@ class SmeltActionHandler(ActionHandlerBase):
258
269
 
259
270
  @property
260
271
  def regex_pattern(self) -> str:
261
- return (
262
- r"smelt: from \[(0|[ABCI][0-9])\] to \[(0|[ABCI][0-9])\] with quantity \d+"
263
- )
272
+ return rf"smelt: from {SLOT_REGEX_PATTERN} to {SLOT_REGEX_PATTERN} with quantity {QUANTITY_REGEX_PATTERN}"
264
273
 
265
274
  @property
266
275
  def action_name(self) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plancraft
3
- Version: 0.3.25
3
+ Version: 0.3.27
4
4
  Summary: Plancraft: an evaluation dataset for planning with LLM agents
5
5
  License: MIT License
6
6
 
@@ -11,7 +11,7 @@ plancraft/data/val.json,sha256=IToAiaqUNQi_xhX1bzmInuskLaT7C2ryQjP-CZkzL24,13044
11
11
  plancraft/data/val.small.easy.json,sha256=9zEmqepjXG2NIp88xnFqOCkwsUsku3HEwHoQGxgTr6U,190252
12
12
  plancraft/data/val.small.json,sha256=76E9EFaljDQyAokg97e-IblvcOe6KbrdKkXvRxhhkgo,237653
13
13
  plancraft/environment/__init__.py,sha256=XFsFny4lH195AwAmL-WeCaF9ZCMgc7IgXIwhQ8FTdgE,505
14
- plancraft/environment/actions.py,sha256=Y_uPg6xjMrtwvtADe7ziTFN9itw6IOOx3sJB5NQFNFE,10880
14
+ plancraft/environment/actions.py,sha256=fL_kzVUyOiud_74ST2YWhEgNFhL7y_ydwDPDmY1CTtU,11551
15
15
  plancraft/environment/env.py,sha256=A4532st7JFBYBF_Nh0CEEi3ZTLJAeaB3t9PAIVSemj0,16390
16
16
  plancraft/environment/items.py,sha256=Z9rhSyVDEoHF1pxRvhyiT94tyQJaWHi3wUHVcamz82o,221
17
17
  plancraft/environment/planner.py,sha256=uIOJjIoyT_4pxeWeTKb8BkLJyKZG0-AMoEOkZs6Ua9A,19340
@@ -1920,7 +1920,7 @@ plancraft/models/generators.py,sha256=F76_iPiqxUjDIrQwF58tzM0bLM91OkZJ0sBqBuki5w
1920
1920
  plancraft/models/oracle.py,sha256=f-0KWlBuHy6wcxmDsxM3MQ_QwfBstzfbA26mlk1MgLA,1657
1921
1921
  plancraft/models/utils.py,sha256=E-sZohvolWgGbpHQKgAgkgIfUJoVnT5pMt6JP8xLHKg,4034
1922
1922
  plancraft/train/dataset.py,sha256=oFqEd4LG9oEQ-71teh0Wf7-jJbtybT2ZibfM2bBdBkM,5474
1923
- plancraft-0.3.25.dist-info/METADATA,sha256=pSbT2EBhcwKnvRtOeq3lAPrpPrDgZ2DAsnosjLyQe78,11148
1924
- plancraft-0.3.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1925
- plancraft-0.3.25.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
1926
- plancraft-0.3.25.dist-info/RECORD,,
1923
+ plancraft-0.3.27.dist-info/METADATA,sha256=fii20vfc62_UjIquU8OXEWtxRXfaaaA2lRo7EbFaQok,11148
1924
+ plancraft-0.3.27.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1925
+ plancraft-0.3.27.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
1926
+ plancraft-0.3.27.dist-info/RECORD,,