pyscreeps-arena 0.2.2__py3-none-any.whl → 0.3.0__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.
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyscreeps-arena
3
+ Version: 0.3.0
4
+ Summary: Python api|interface to play game: Screeps: Arena.
5
+ Author-email: 2229066748@qq.com
6
+ Maintainer: Eagle'sBaby
7
+ Maintainer-email: 2229066748@qq.com
8
+ License: Apache Licence 2.0
9
+ Keywords: python,screeps:arena,screeps
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: pyperclip
15
+ Requires-Dist: colorama
16
+ Requires-Dist: py7zr
17
+ Requires-Dist: Transcrypt==3.9.3
18
+ Requires-Dist: mkdocs
19
+ Requires-Dist: mkdocstrings[python]
20
+ Requires-Dist: mkdocs-material
21
+
22
+ # PyScreeps-Arena
23
+
24
+ use cmd `pyscreeps-arena <your new project path>` to new a project.
25
+
26
+ ## Tutorial
27
+
28
+ * [Tutorial 1: Loop and import](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial1-Loop%20and%20import.md)
29
+ * [Tutorial 2: Simple move](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial2-Simple%20move.md)
30
+ * [Tutorial 3: First attack](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial3-First%20attack.md)
31
+ * [Tutorial 4: Creeps bodies](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial4-Creeps%20Bodies.md)
32
+ * [Tutorial 5: Store and transfer](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial5-Store%20and%20transfer.md)
33
+ * [Tutorial 6: Terrain](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial6-Terrain.md)
34
+ * [Tutorial 7: Spawn creeps](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial7-Spawn%20creeps.md)
35
+ * [Tutorial 8: Harvest energy](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial8-Harvest%20energy.md)
36
+ * [Tutorial 9: Construction](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial9-Construction.md)
37
+ * [Tutorial 10: Final test](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial10-Final%20test.md)
@@ -0,0 +1,8 @@
1
+ pyscreeps_arena/__init__.py,sha256=S7k6_kTuhrf2XumCoQQ6rR7zm6HaA15pN4_RHjCSi1Y,754
2
+ pyscreeps_arena/build.py,sha256=ZTQfPG5M5sU2bFI9AbI_mp3V-HaG0-Prb73MQAu-sB0,25914
3
+ pyscreeps_arena/project.7z,sha256=utfgIbaNCq5FdWVH8wsiyxo9WLRx_i6KAswlVCR6cXw,49317
4
+ pyscreeps_arena-0.3.0.dist-info/METADATA,sha256=wE6hjrumbEMASSLhVWLf8MxFIWUSg3QVFr-T-i8FVZg,2054
5
+ pyscreeps_arena-0.3.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
6
+ pyscreeps_arena-0.3.0.dist-info/entry_points.txt,sha256=dqhZN327jfcNypYjEaEJ2t-ABUZ0sVhtDDrD7GiJBfo,67
7
+ pyscreeps_arena-0.3.0.dist-info/top_level.txt,sha256=l4uLyMR2NOy41ngBMh795jOHTFk3tgYKy64-9cgjVng,16
8
+ pyscreeps_arena-0.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,1001 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pyscreeps-arena
3
- Version: 0.2.2
4
- Summary: Python api|interface to play game: Screeps: Arena.
5
- Author-email: 2229066748@qq.com
6
- Maintainer: Eagle'sBaby
7
- Maintainer-email: 2229066748@qq.com
8
- License: Apache Licence 2.0
9
- Keywords: python,screeps:arena,screeps
10
- Classifier: Programming Language :: Python
11
- Classifier: Programming Language :: Python :: 3
12
- Requires-Python: >=3.10
13
- Description-Content-Type: text/markdown
14
- Requires-Dist: pyperclip
15
- Requires-Dist: colorama
16
- Requires-Dist: py7zr
17
- Requires-Dist: Transcrypt ==3.9.1
18
- Requires-Dist: mkdocs
19
- Requires-Dist: mkdocstrings[python]
20
- Requires-Dist: mkdocs-material
21
-
22
- # PyScreeps-Arena
23
-
24
- use cmd `pyscreeps-arena <your new project path>` to new a project.
25
-
26
- ## Tutorial
27
-
28
- * [Tutorial 1: Loop and import](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial1-Loop%20and%20import.md)
29
- * [Tutorial 2: Simple move](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial2-Simple%20move.md)
30
- * [Tutorial 3: First attack](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial3-First%20attack.md)
31
- * [Tutorial 4: Creeps bodies](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial4-Creeps%20Bodies.md)
32
- * [Tutorial 5: Store and transfer](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial5-Store%20and%20transfer.md)
33
- * [Tutorial 6: Terrain](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial6-Terrain.md)
34
- * [Tutorial 7: Spawn creeps](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial7-Spawn%20creeps.md)
35
- * [Tutorial 8: Harvest energy](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial8-Harvest%20energy.md)
36
- * [Tutorial 9: Construction](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial9-Construction.md)
37
- * [Tutorial 10: Final test](https://github.com/EagleBaby/python_screeps_arena/blob/main/tutorials/tutorial10-Final%20test.md)
38
-
39
- # std.py
40
-
41
- ## PyScreeps-Arena Standard Library
42
- Contains static classes and a utils module:</br>
43
-
44
- | class | static | description |
45
- |---------|--------|----------------------------------------------|
46
- | `std` | ✔ | std functions. like info, warn ... |
47
- | `st` | ✔ | Screeps Typing. set of `function(obj) -> bool` |
48
- | `put` | ✔ | standard output. contain set of commands. |
49
- | `get` | ✔ | standard input. get data of the current game. |
50
- | `ut` | X | Utils, contains some expansion classes. |
51
-
52
- ## \> std
53
-
54
- <details>
55
- <summary><b>std.param_assert(params, names, shoulds, errs)</b>
56
-
57
- 检查参数是否符合要求,不符合则抛出异常</summary>
58
-
59
- | param | type | description |
60
- |-------|------|-------------|
61
- | params | list[object] | 参数列表 |
62
- | names | list[str] | 参数名列表 |
63
- | shoulds | list[callable] | 期望的参数检查列表 |
64
- | errs | list[str] | 对应的错误信息列表 |
65
- | __raise | bool | 是否抛出异常(默认True) |
66
-
67
- | return | type | description |
68
- |--------|------|-------------|
69
- | None | None | 无返回值 |
70
- Example:
71
- ```python
72
- # > define ASSERT 1
73
- def func_add(a, b):
74
- # > if ASSERT
75
- std.param_assert(
76
- [a, b], # 参数列表
77
- ['a', 'b'], # 参数名列表
78
- [lambda x: isinstance(x, int), lambda x: isinstance(x, int)], # 期望的参数检查列表
79
- ['a is not int', 'b is not int'] # 对应的错误信息列表
80
- )
81
- # > endif
82
- return a + b
83
- ```
84
-
85
- </details><details>
86
- <summary><b>std.combo_filter(filter_composite)</b>
87
-
88
- 按照指定逻辑将 '组合容器函数表达式'转换为一个函数</summary>
89
-
90
- | param | type | description |
91
- |-------|----------------------------------|-------------|
92
- | filter_composite | tuple \| list \| set \| callable | 由tuple、list和set组成的过滤器结构(最小单元是callable) |
93
-
94
- | return | type | description |
95
- |--------|------|-------------|
96
- | callable | callable | 一个新的可以表达输入表达式的函数 |
97
-
98
- Example:
99
- ```python
100
- # 例如我们判断一个creep对象是否既能近战攻击又能远程攻击
101
- # 我们可以使用combo_filter来实现
102
- new_filter = std.combo_filter(
103
- # st.melee(obj) -> bool, st.ranged(obj) -> bool
104
- (st.melee, st.ranged) # tuple表示and关系,即melee & ranged
105
- )
106
-
107
- attack_and_ranged_attack = new_filter(creep)
108
-
109
- # st是一组形如function(obj)->bool函数组成的静态类,稍后会详细介绍
110
- ```
111
-
112
- </details><details>
113
- <summary><b>日志函数组</b>
114
-
115
- (log, info, warn, error)</summary>
116
-
117
- | param | type | description |
118
- |-------|------|-----------------------|
119
- | caller_name | str | 调用者名称, 主要是便于定位信息位置和来源 |
120
- | *args | str | 实际需要输出的信息 |
121
-
122
- | return | type | description |
123
- |--------|------|-------------|
124
- | None | None | 无返回值 |
125
-
126
- | function | description |
127
- |----------|-----------------------------------------------|
128
- | log | 输出日志信息,一般用于debug和一些不太重要的信息。输出中的'log'会用黄色来显示 |
129
- | info | 输出通用信息,一般用于输出一些标识性的信息。输出中的'info'会用绿底白字来显示 |
130
- | warn | 输出警告信息,一般用于输出一些可能会出现问题的信息。输出中的'warn'会用黄底白字来显示 |
131
- | error | 输出错误信息,该函数会抛出异常。 |
132
-
133
- </details><details>
134
- <summary><b>std.show_usage()</b>
135
-
136
- 显示当前硬件资源的使用情况,包括CPU使用情况和内存使用情况。建议在loop函数的最后调用。</summary>
137
- ```python
138
- def loop():
139
- # do something
140
- std.show_usage()
141
- ```
142
- </details>
143
-
144
- ## \> st
145
- 包含一组形如`function(obj) -> bool`的函数,用于判断对象的类型</br>
146
- 总的来说,可以分为4大类:
147
-
148
- ```python
149
- creeps = getObjectsByPrototype(Creep) -> js list
150
- creeps = get.creeps() -> py list
151
-
152
- # get提供了pyscreeps-arena获取绝大多数游戏内基础信息的方法, 稍后会详细介绍
153
- ```
154
- <details>
155
- <summary><b>Js基本类型判断:</b></summary>
156
-
157
- | function | description |
158
- |----------|-------------|
159
- | st.jnumber(obj) | 判断obj是否为js中的number类型 |
160
- | st.jstring(obj) | 判断obj是否为js中的string类型 |
161
- | st.jbool(obj) | 判断obj是否为js中的boolean类型 |
162
- | st.jlist(obj) | 判断obj是否为js中的array类型 |
163
- | st.jdict(obj) | 判断obj是否为js中的dict类型(等价于jlist) |
164
-
165
- </details>
166
- <br><details>
167
- <summary><b>Py基本类型判断:</b></summary>
168
-
169
- | function | description |
170
- |----------|-------------|
171
- | st.tuple(obj) | 判断obj是否为python中的tuple类型 |
172
- | st.list(obj) | 判断obj是否为python中的list类型 |
173
- | st.dict(obj) | 判断obj是否为python中的dict类型 |
174
- | st.set(obj) | 判断obj是否为python中的set类型 |
175
- | st.str(obj) | 判断obj是否为python中的str类型 |
176
- | st.int(obj) | 判断obj是否为python中的int类型 |
177
- | st.float(obj) | 判断obj是否为python中的float类型 |
178
- | st.bool(obj) | 判断obj是否为python中的bool类型 |
179
-
180
-
181
- </details>
182
- <br>
183
- <details>
184
- <summary><b>基本游戏类型判断:</b></summary>
185
-
186
- | function | description |
187
- |----------|------------------------------|
188
- | st.site(obj) | 判断obj是否为ConstructionSite类型 |
189
- | st.creep(obj) | 判断obj是否为Creep类型 |
190
- | st.gobject(obj) | 判断obj是否为GameObject类型 |
191
- | st.ostructure(obj) | 判断obj是否为OwnedStructure类型 |
192
- | st.resource(obj) | 判断obj是否为Resource类型 |
193
- | st.source(obj) | 判断obj是否为Source类型 |
194
- | st.store(obj) | 判断obj是否为Store类型 |
195
- | st.structure(obj) | 判断obj是否为Structure类型 |
196
- | st.box(obj) | 判断obj是否为StructureContainer类型 |
197
- | st.extension(obj) | 判断obj是否为StructureExtension类型 |
198
- | st.rampart(obj) | 判断obj是否为StructureRampart类型 |
199
- | st.road(obj) | 判断obj是否为StructureRoad类型 |
200
- | st.spawn(obj) | 判断obj是否为StructureSpawn类型 |
201
- | st.tower(obj) | 判断obj是否为StructureTower类型 |
202
- | st.wall(obj) | 判断obj是否为StructureWall类型 |
203
- | st.spawning(obj) | 判断obj是否为Spawning类型 |
204
- | st.flag(obj) | 判断obj是否为Flag类型 |
205
-
206
- </details>
207
- <br>
208
- <details>
209
- <summary><b>对象能力判断:</b></summary>
210
-
211
- | function | description |
212
- |----------|------------------------------|
213
- | st.movable(obj) | 判断obj是否具有移动的能力 |
214
- | st.atkable(obj) | 判断obj是否具有攻击的能力 |
215
- | st.melee(obj) | 判断obj是否具有近战攻击的能力 |
216
- | st.ranged(obj) | 判断obj是否具有远程攻击的能力 |
217
- | st.healable(obj) | 判断obj是否具有治疗别人的能力 |
218
- | st.hitable(obj) | 判断obj是否可以被攻击(不论敌我) |
219
- | st.workable(obj) | 判断obj是否具有建造和收获资源的能力 |
220
- | st.storable(obj) | 判断obj是否具有存储资源的能力 |
221
- | st.energetic(obj) | 判断obj是否含有能量(energy) |
222
- | st.damaged(obj) | 判断obj是否受到了伤害(hits < maxHits) |
223
- | st.my(obj) | 判断obj是否为我方单位 |
224
- | st.friend(obj) | 判断obj是否为友方单位(目前同st.my) |
225
- | st.enemy(obj) | 判断obj是否为敌方单位(目前同not st.my) |
226
-
227
- </details>
228
-
229
- ## \> put
230
- <details>
231
- <summary><b>Unit基础命令集</b></summary>
232
- <details>
233
- <summary><b>put.move(unit, to, options = None)</b>
234
-
235
- 命令Creep移动到目标点或向某个方向移动</summary>
236
-
237
- | param | type | description |
238
- |-------|----------------------------------|------------------------|
239
- | unit | list \| (st.friend & st.movable) | 一个或多个可移动的友方单位 |
240
- | to | st.point \| int | 一个目标点或是一个方向 |
241
- | options | UsrObject | 寻路选项(只在to为st.point时有效) |
242
- | __assert | bool | 是否进行参数检查 |
243
-
244
- | return | type | description |
245
- |--------|------------------|------------------------------------------------------|
246
- | 运行结果 | int \| list[int] | 成功返回OK(0),否则返回错误码(<0)。如果unit为list,那么返回每个unit的结果的list |
247
-
248
- ```python
249
- creep = get.creep(st.friend) # 获取一个友方creep
250
- spawn = get.spawn(st.friend) # 获取一个友方spawn
251
- put.move(creep, LEFT) # 让creep向左移动
252
- put.move(creep, spawn) # 让creep移动到spawn所在位置
253
-
254
- # 无视沼泽赶路(只是寻路逻辑无视沼泽,实际还是会受到沼泽的影响)
255
- op = UsrObject()
256
- op.swampCost = op.plainCost # 沼泽的消耗和平原一样,即无视沼泽
257
- put.move(creep, spawn, op) # 让creep移动到spawn所在位置
258
-
259
- # 如果你对你的代码很有信心,可以关闭参数检查。(一般不推荐使用者这么写)
260
- put.move(creep, spawn, None, False) # 注意,kwargs不工作,只能按顺序传参
261
- # 如果场上不存在友方creep,且您关闭了检查,那么可能会抛出一些奇奇怪怪的异常
262
- ```
263
- </details><details>
264
- <summary><b>put.attack(unit, target, move = True)</b>
265
-
266
- 命令Tower或Creep攻击敌方目标</summary>
267
-
268
- | param | type | description |
269
- |-------|----------------------------------|-------------------------|
270
- | unit | list \| (st.friend & st.atkable) | 一个或多个可攻击的友方单位 |
271
- | target | st.enemy & st.hitable | 一个敌方可受击的单位 |
272
- | move | bool \| UsrObject | 是否移动到目标位置(默认True)或是移动选项 |
273
- | __assert | bool | 是否进行参数检查 |
274
-
275
- | return | type | description |
276
- |--------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
277
- | 运行结果 | UsrObject \| list[UsrObject] | 返回UsrObject,每个UsrObject最多能包含melee, ranged, move这三个属性,分别表示是否进行近战攻击、远程攻击和移动,每个属性成功返回Ok(0), 失败返回错误码,未执行则为undefined。如果unit为list,那么返回每个unit的结果的list. |
278
-
279
- ```python
280
- creep = get.creep((st.friend, st.atkable)) # 获取一个友方可攻击的creep
281
- enemies = get.creeps(st.enemy) # 获取所有敌方creep
282
- closest_enemy = get.closest(creep, enemies) # 获取离creep最近的敌方creep
283
-
284
- put.attack(creep, closest_enemy) # 让creep攻击最近的敌方creep
285
- ```
286
-
287
- </details><details>
288
- <summary><b>put.heal(unit, target, move = True)</b>
289
-
290
- 命令Tower或Creep治疗目标单位</summary>
291
-
292
- | param | type | description |
293
- |-------|----------------------------------|-------------------------|
294
- | unit | list \| (st.friend & st.healable) | 一个或多个友方的具有治疗能力的单位 |
295
- | target | st.friend & st.creep | 一个友方的creep |
296
- | move | bool \| UsrObject | 是否可以自主移动(可以传入options, 视作True,用于调整移动时的路线) |
297
- | __assert | bool | 是否进行参数检查 |
298
-
299
- | return | type | description |
300
- |--------|------------------|------------------------------------------------------|
301
- | 运行结果 | UsrObject \| list[UsrObject] | 返回UsrObject,每个UsrObject最多能包含heal, ranged, move这三个属性,分别表示是否进行近距离治疗、远程治疗和移动,每个属性成功返回Ok(0), 失败返回错误码,未执行则为undefined。如果unit为list,那么返回每个unit的结果的list. |
302
- ```python
303
- creep = get.creep((st.friend, st.healable)) # 获取一个友方可治疗的creep
304
- damaged_creep = get.creep((st.friend, st.damaged)) # 获取一个友方受伤的creep
305
-
306
- put.heal(creep, damaged_creep) # 让creep治疗受伤的creep
307
- ```
308
-
309
- </details><details>
310
- <summary><b>put.fetch(unit, target, resource_type = RESOURCE_ENERGY, amount = None, move = True)</b>
311
-
312
- 命令单位从目标处取出资源</summary>
313
-
314
- | param | type | description |
315
- |-------|----------------------------------|-------------------------|
316
- | unit | list \| (st.friend & st.storable) | 一个或多个友方的可携带资源的单位 |
317
- | target | st.storable \| st.resource | 一个可存储的目标或掉落的资源 |
318
- | resource_type | int | 资源类型, 默认RESOURCE_ENERGY |
319
- | amount | int \| None | 资源数量,如果没有指定,则取出所有资源 |
320
- | move | bool \| UsrObject | 是否可以自主移动(可以传入options, 视作True,用于调整移动时的路线) |
321
- | __assert | bool | 是否进行参数检查 |
322
-
323
- | return | type | description |
324
- |--------|------------------|------------------------------------------------------|
325
- | 运行结果 | int \| list[int] | 成功返回OK(0),否则返回错误码(<0)。如果unit为list,那么返回每个unit的结果的list |
326
-
327
- ```python
328
- creep = get.creep((st.friend, st.storable)) # 获取一个友方可携带资源的creep
329
- dropped_energy = get.resource() # 获取掉落的能量
330
- energy_box = get.box(st.energetic) # 获取一个有能量的箱子, 也可以写成get.box({st.empty})
331
-
332
- put.fetch(creep, dropped_energy) # 让creep取出掉落的能量
333
- # put.fetch(creep, energy_box) # 让creep取出箱子里的能量
334
- ```
335
-
336
- ```python
337
- worker = get.creep(lambda c: c.my and c.name == 'worker') # 获取己方的'worker'
338
- carrier = get.creep(lambda c: c.my and c.name == 'carrier') # 获取己方的'carrier'
339
-
340
- if get.energy(worker) == 0:
341
- put.fetch(worker, carrier) # 让worker取出carrier携带的能量
342
-
343
- ```
344
-
345
- </details><details>
346
- <summary><b>put.deposit(unit, target, resource_type = RESOURCE_ENERGY, amount = None, move = True)</b>
347
-
348
- 命令单位将身上的资源放置于目标处</summary>
349
-
350
- | param | type | description |
351
- |-------|----------------------------------|-------------------------|
352
- | unit | list \| (st.friend & st.storable) | 一个或多个友方的可携带资源的单位 |
353
- | target | st.storable \| None | 一个可存储的目标,如果为None,单位会直接丢弃资源到原地 |
354
- | resource_type | int | 资源类型, 默认RESOURCE_ENERGY |
355
- | amount | int \| None | 资源数量,如果没有指定,则转移所有资源 |
356
- | move | bool \| UsrObject | 是否可以自主移动(可以传入options, 视作True,用于调整移动时的路线) |
357
- | __assert | bool | 是否进行参数检查 |
358
-
359
- | return | type | description |
360
- |--------|------------------|------------------------------------------------------|
361
- | 运行结果 | int \| list[int] | 成功返回OK(0),否则返回错误码(<0)。如果unit为list,那么返回每个unit的结果的list |
362
-
363
- ```python
364
- creep = get.creep((st.friend, st.storable)) # 获取一个友方可携带资源的creep
365
- spawn = get.spawn(st.friend) # 获取一个友方spawn
366
-
367
- put.deposit(creep, spawn) # 让creep把资源放到spawn
368
- ```
369
-
370
- ```python
371
- worker = get.creep(lambda c: c.my and c.name == 'worker') # 获取己方的'worker'
372
- carrier = get.creep(lambda c: c.my and c.name == 'carrier') # 获取己方的'carrier'
373
-
374
- if get.energy(worker) == 0:
375
- put.deposit(carrier, worker) # 让carrier把资源放到worker
376
- ```
377
-
378
- </details><details>
379
- <summary><b>put.build(unit, site, move = True)</b>
380
-
381
- 命令单位建造建筑</summary>
382
-
383
- | param | type | description |
384
- |-------|----------------------------------|-------------------------|
385
- | unit | list \| (st.friend & st.workable) | 一个或多个友方的可工作单位 |
386
- | site | st.site | 一个ConstructionSite实例对象 |
387
- | move | bool \| UsrObject | 是否可以自主移动(可以传入options, 视作True,用于调整移动时的路线) |
388
- | __assert | bool | 是否进行参数检查 |
389
-
390
- | return | type | description |
391
- |--------|------------------|------------------------------------------------------|
392
- | 运行结果 | int \| list[int] | 成功返回OK(0),否则返回错误码(<0)。如果unit为list,那么返回每个unit的结果的list |
393
-
394
- ```python
395
- creep = get.creep((st.friend, st.workable)) # 获取一个友方可工作的creep
396
- box = get.box({st.empty}) # 获取一个非空箱子
397
- site = get.site() # 获取一个ConstructionSite
398
-
399
- if get.energy(creep) == 0:
400
- put.fetch(creep, box) # 让creep取出箱子里的能量
401
- elif site:
402
- put.build(creep, site) # 让creep建造site
403
- ```
404
-
405
- </details><details>
406
- <summary><b>put.harvest(unit, target, move = True)</b>
407
-
408
- 命令单位采集资源</summary>
409
-
410
- | param | type | description |
411
- |-------|----------------------------------|-------------------------|
412
- | unit | list \| (st.friend & st.workable) | 一个友方的可工作单位 |
413
- | target | st.source | 一个资源点 |
414
- | move | bool \| UsrObject | 是否可以自主移动(可以传入options, 视作True,用于调整移动时的路线) |
415
- | __assert | bool | 是否进行参数检查 |
416
-
417
- | return | type | description |
418
- |--------|------------------|------------------------------------------------------|
419
- | 运行结果 | int \| list[int] | 成功返回OK(0),否则返回错误码(<0)。如果unit为list,那么返回每个unit的结果的list |
420
-
421
- ```python
422
- # 让worker采集资源(装满了就回家,否则就继续采集)
423
- worker = get.friend(lambda obj: obj.name == 'worker')
424
- spawn = get.spawn(st.friend)
425
- source = get.source()
426
- if get.energy(worker, True) == 100:
427
- put.deposit(worker, spawn, RESOURCE_ENERGY)
428
- else:
429
- put.harvest(worker, source)
430
- ```
431
- </details>
432
- </details>
433
- <br>
434
- <details>
435
- <summary><b>Unit扩展命令集</b></summary>
436
-
437
- <details>
438
- <summary><b>put.escape(unit, target, options = None)</b>
439
-
440
- 命令Creep远离目标</summary>
441
-
442
- | param | type | description |
443
- |-------|----------------------------------|-------------------------|
444
- | unit | list \| (st.friend & st.movable) | 一个或多个可移动的友方单位 |
445
- | target | st.point | 一个目标点 |
446
- | options | UsrObject | 寻路选项(只在to为st.point时有效) |
447
- | __assert | bool | 是否进行参数检查 |
448
-
449
- | return | type | description |
450
- |--------|------------------|------------------------------------------------------|
451
- | 运行结果 | int \| list[int] | 成功返回OK(0),否则返回错误码(<0)。如果unit为list,那么返回每个unit的结果的list |
452
-
453
- ```python
454
- # 让worker远离最近的敌人
455
- worker = get.friend(lambda obj: obj.name == 'worker')
456
- enemy = get.closest(worker, get.enemies())
457
- if enemy and get.distance(worker, enemy) <= 8:
458
- put.escape(worker, enemy)
459
- ```
460
-
461
- </details>
462
- <details>
463
- <summary><b>put.intermit(unit, target, resource_type = RESOURCE_ENERGY, options = None)</b>
464
-
465
- 断断续续地搬运资源到目标</summary>
466
-
467
- | param | type | description |
468
- |-------|----------------------------------|-------------------------|
469
- | unit | list \| (st.friend & st.storable & st.movable) | 一个友方的可移动的可存储资源的单位 |
470
- | target | st.storable | 一个可存储的目标 |
471
- | resource_type | int | 资源类型, 默认RESOURCE_ENERGY |
472
- | options | UsrObject | 寻路选项(只在to为st.point时有效) |
473
- | __assert | bool | 是否进行参数检查 |
474
-
475
- | return | type | description |
476
- |--------|------------------|------------------------------------------------------|
477
- | 运行结果 | int \| list[int] | 成功搬运完毕或是无资源可搬运,返回DONE(1); 搬运中返回OK(0)或是错误码(<0)。如果unit为list,那么返回每个unit的结果的list |
478
-
479
- ```python
480
- # 将身上或地上的资源搬运回家(确保身上或地上有资源)
481
- carrier = get.friend(lambda obj: obj.name == 'carrier')
482
- spawn = get.spawn(st.friend)
483
- put.intermit(carrier, spawn)
484
- ```
485
-
486
- </details>
487
- <details>
488
- <summary><b>put.follow(unit, target, distance, options = None, move = True)</b>
489
-
490
- 命令一个或多个单位跟随目标</summary>
491
-
492
- | param | type | description |
493
- |-------|----------------------------------|-------------------------|
494
- | unit | list \| (st.friend & st.movable) | 一个或多个可移动的友方单位 |
495
- | target | st.movable | 一个可移动的目标 |
496
- | distance | int \| tuple | 距离最大或最小值, tuple: 距离范围, 只在友方时有效 |
497
- | options | UsrObject | 寻路选项(只在to为st.point时有效) |
498
- | move | bool \| UsrObject | 是否可以自主移动(可以传入options, 视作True,用于调整移动时的路线) |
499
- | __assert | bool | 是否进行参数检查 |
500
-
501
- | return | type | description |
502
- |--------|------------------|------------------------------------------------------|
503
- | 运行结果 | int \| list[int] | 成功返回OK(0),否则返回错误码(<0)。如果unit为list,那么返回每个unit的结果的list |
504
-
505
- ```python
506
- # 让warriors跟随leader,距离不超过5。leader不考虑距离超过20的warrior。
507
- leader = get.friend(lambda obj: obj.name == 'leader')
508
- warriors = get.friends(lambda obj: obj.name == 'warrior')
509
- put.follow(warriors, leader, (5, 20))
510
- ```
511
- </details>
512
- <details>
513
- <summary><b>put.carry(unit, src, dst, resource_type = RESOURCE_ENERGY, options = None, intermit = False)</b>
514
-
515
- 命令单位从src处搬运资源到dst处</summary>
516
-
517
- | param | type | description |
518
- |-------|----------------------------------|-------------------------|
519
- | unit | list \| (st.friend & st.storable & st.movable) | 一个友方的可携带资源的可移动单位 |
520
- | src | st.storable | 从哪里取得资源 |
521
- | dst | st.storable | 被搬运资源的目标容器 |
522
- | resource_type | int | 资源类型, 默认RESOURCE_ENERGY |
523
- | options | UsrObject | 寻路选项(只在to为st.point时有效) |
524
- | intermit | bool | 是否断断续续地搬运资源 |
525
- | __assert | bool | 是否进行参数检查 |
526
-
527
- | return | type | description |
528
- |--------|------------------|------------------------------------------------------|
529
- | 运行结果 | int \| list[int] | 若intermit=False,成功返回OK(0),否则返回错误码(<0); 若intermit=True,则在搬运完毕或是无资源可搬运时,返回DONE(1),其余和前者相同。如果unit为list,那么返回每个unit的结果的list |
530
-
531
- ```python
532
- # 将身上的资源搬运回家(确保身上有资源)
533
- carrier = get.friend(lambda obj: obj.name == 'carrier')
534
- spawn = get.spawn(st.friend)
535
- box = get.closest(carrier, get.boxes(st.energetic))
536
- put.carry(carrier, box, spawn)
537
- ```
538
- </details></details>
539
- <br>
540
- <details>
541
- <summary><b>put.site(x, y_type, building_type = None)</b>
542
-
543
- 在指定位置创建新的 ConstructionSite</summary>
544
-
545
- | param | type | description |
546
- |-------|----------------------------------|-------------------------|
547
- | x | int \| float \| Position | x坐标或Position对象 |
548
- | y_type | int \| float \| type | y坐标或建筑类型 |
549
- | building_type | type \| None | 建筑类型(默认None) |
550
- | __assert | bool | 是否进行参数检查 |
551
-
552
- | return | type | description |
553
- |--------|------------------|------------------------------------------------------|
554
- | 运行结果 | int \| ConstructionSite | 如果成功(创建完成),返回创建的ConstructionSite对象; 否则返回错误码(<0) |
555
-
556
- ```python
557
- res = put.site(10, 10, StructureContainer)
558
- if st.site(res):
559
- site = res
560
- ```
561
-
562
- </details><details>
563
- <summary><b>put.create(spawn, recipe, name = None)</b>
564
-
565
- 命令spawn按照指定的配方生产一个creep</summary>
566
-
567
- | param | type | description |
568
- |-------|----------------------------------|-------------------------|
569
- | spawn | st.friend & st.spawn | 一个友方的Spawn |
570
- | recipe | list[str] | 一个creep的配方, 一般用const下的MOVE, CARRY, WORK等常量 |
571
- | name | str \| None | 一个creep的名字(默认为None), 这样创建的creep会带有.name属性 |
572
- | __assert | bool | 是否进行参数检查 |
573
-
574
- | return | type | description |
575
- |--------|------------------|------------------------------------------------------|
576
- | 运行结果 | int \| object | 如果成功(生产完成),返回创建的creep对象; 否则返回错误码(<0) |
577
-
578
- ```python
579
- # 生成一个名为'worker'的creep
580
- spawn = get.spawn(st.friend)
581
- worker = get.friend(lambda obj: obj.name == 'worker')
582
- if not worker:
583
- put.create(spawn, [CARRY, MOVE, WORK], 'worker')
584
- ```
585
-
586
- </details>
587
-
588
- ## \> get
589
- 提供一组获取游戏中的数据的函数。
590
- <details>
591
- <summary><b>无参数函数集</b></summary>
592
-
593
- | function | return | description |
594
- |-----------|--------|-------------|
595
- | get.cpu | int | 返回当前 tick 中经过的 CPU 壁钟时间(以纳秒为单位) |
596
- | get.heap | HeapInfo | 使用此方法获取虚拟机的堆统计信息。 |
597
- | get.ticks | int | 返回从当前游戏开始经过的 tick 数 |
598
- | get.arena | arenaInfo | 获取arenaInfo对象 |
599
- </details>
600
- <br>
601
- <details>
602
- <summary><b>游戏对象获取函数集</b></summary>
603
- 最主要的一组函数,只有一个参数`filter_fn`, 返回一个或一组游戏中的对象。包括creep、spawn、source等等。
604
-
605
- | param | type | description |
606
- |-------|------|--------------------|
607
- | filter_fn | list \| tuple \| set \| callable \| None | 条件容器函数表达式(默认值None) |
608
-
609
- 如果传入None(默认值),那么将不会进行筛选。也可以直接传入组合表达式,如`(st.friend, st.creep)`。
610
-
611
- | function | function(复数形式) | return | return(复数形式) | description |
612
- |----------|---------------------|--------------------|------------------|---------------------|
613
- | get.creep | get.creeps | Creep \| None | list[Creep] | 获取一个或多个特定条件的creep对象 |
614
- | get.friend | get.friends | GameObject \| None | list[GameObject] | 获取一个或多个特定条件的友方对象 |
615
- | get.enemy | get.enemies | GameObject \| None | list[GameObject] | 获取一个或多个特定条件的敌方对象 |
616
- | get.spawn | get.spawns | StructureSpawn \| None | list[StructureSpawn] | 获取一个或多个特定条件的spawn对象 |
617
- | get.structure | get.structures | Structure \| None | list[Structure] | 获取一个或多个特定条件的structure对象 |
618
- | get.source | get.sources | Source \| None | list[Source] | 获取一个或多个特定条件的source对象 |
619
- | get.site | get.sites | ConstructionSite \| None | list[ConstructionSite] | 获取一个或多个特定条件的site对象 |
620
- | get.resource | get.resources | Resource \| None | list[Resource] | 获取一个或多个特定条件的resource对象 |
621
- | get.tower | get.towers | StructureTower \| None | list[StructureTower] | 获取一个或多个特定条件的tower对象 |
622
- | get.wall | get.walls | StructureWall \| None | list[StructureWall] | 获取一个或多个特定条件的wall对象 |
623
- | get.rampart | get.ramparts | StructureRampart \| None | list[StructureRampart] | 获取一个或多个特定条件的rampart对象 |
624
- | get.extension | get.extensions | StructureExtension \| None | list[StructureExtension] | 获取一个或多个特定条件的extension对象 |
625
- | get.box | get.boxes | StructureContainer \| None | list[StructureContainer] | 获取一个或多个特定条件的box对象 |
626
- | get.road | get.roads | StructureRoad \| None | list[StructureRoad] | 获取一个或多个特定条件的road对象 |
627
- | get.storage | get.storages | GameObject \| None | list[GameObject] | 获取一个或多个特定条件的storage对象 |
628
- | get.flag | get.flags | Flag \| None | list[Flag] | 获取一个或多个特定条件的flag对象 |
629
- | get.score_controller | get.score_controllers | ScoreController \| None | list[ScoreController] | 获取一个或多个特定条件的score_controller对象 |
630
-
631
- </details>
632
- <br>
633
- <details>
634
- <summary><b>己方行动检测函数集</b></summary>
635
-
636
- 这一组函数用于判断单位是否在当前的tick是否被下达过某种行动命令。这些函数只能判断由put下达的行动命令,并且新的行动命令会覆盖旧的行动命令。
637
-
638
- | param | type | description |
639
- |-------|------|-------------------------------------------------------------|
640
- | unit | st.creep | 一个Creep对象 |
641
- | ticks_offset | int | 偏移的ticks数, 默认为0. 比如传入-1表示上一tick(如果当前tick下达过对应命令,那么会覆盖之前的记录) |
642
-
643
- | return | type | description |
644
- |--------|------|-------------------------------------|
645
- | bool | bool | 如果对应的tick下达过对应命令,返回True,否则返回False |
646
-
647
- | function | description |
648
- |----------|----------------------|
649
- | get.moved | 判断单位对应tick是否被下达过移动命令 |
650
- | get.attacked | 判断单位对应tick是否被下达过攻击命令 |
651
- | get.meleed | 判断单位对应tick是否被下达过近战攻击命令 |
652
- | get.ranged | 判断单位对应tick是否被下达过远程攻击命令 |
653
- | get.healed | 判断单位对应tick是否被下达过治疗命令 |
654
- | get.fetched | 判断单位对应tick是否被下达过拿取命令 |
655
- | get.deposited | 判断单位对应tick是否被下达过放置命令 |
656
- | get.built | 判断单位对应tick是否被下达过建造命令 |
657
- | get.intermited | 判断单位对应tick是否被下达过intermit命令 |
658
-
659
- </details>
660
- <br>
661
- <details>
662
- <summary><b>工具函数集</b></summary>
663
-
664
- <details>
665
- <summary><b>get.closest(obj, objs, filter_fn = None)</b>
666
-
667
- 返回距离最近的对象</summary>
668
-
669
- | param | type | description |
670
- |-------|----------------------------------|-------------------------|
671
- | obj | st.point | 一个坐标点 |
672
- | objs | list[st.point] | 一个坐标点列表 |
673
- | filter_fn | list \| tuple \| set \| callable \| None | 条件容器函数表达式(默认值None) |
674
-
675
- | return | type | description |
676
- |--------|------------------|------------------------------------------------------|
677
- | st.point | st.point \| None | 如果没有找到,返回None |
678
-
679
- ```python
680
- # 获取距离最近的敌方creep
681
- creep = get.creep(st.friend)
682
- enemies = get.creeps(st.enemy)
683
- closest_enemy = get.closest(creep, enemies)
684
- ```
685
-
686
- </details>
687
- <details>
688
- <summary><b>get.quickest(obj, objs, filter_fn = None)</b>
689
-
690
- 返回移动到目标所需时间最短的对象</summary>
691
-
692
- | param | type | description |
693
- |-------|----------------------------------|-------------------------|
694
- | obj | st.point | 一个坐标点 |
695
- | objs | list[st.point] | 一个坐标点列表 |
696
- | filter_fn | list \| tuple \| set \| callable \| None | 条件容器函数表达式(默认值None) |
697
-
698
- | return | type | description |
699
- |--------|------------------|------------------------------------------------------|
700
- | st.point | st.point \| None | 如果没有找到,返回None |
701
-
702
- ```python
703
- # 获取抵达时间最短的敌方creep
704
- creep = get.creep(st.friend)
705
- enemies = get.creeps(st.enemy)
706
- quickest_enemy = get.quickest(creep, enemies)
707
- ```
708
-
709
- </details>
710
- <details>
711
- <summary><b>get.inrange(obj, objs, range, filter_fn = None)</b>
712
-
713
- 返回在指定范围内的对象列表</summary>
714
-
715
- | param | type | description |
716
- |-------|----------------------------------|-------------------------|
717
- | obj | st.point | 一个坐标点 |
718
- | objs | list[st.point] | 一个坐标点列表 |
719
- | range | int | 查找的最大范围距离 |
720
- | filter_fn | list \| tuple \| set \| callable \| None | 条件容器函数表达式(默认值None) |
721
-
722
- | return | type | description |
723
- |--------|------------------|------------------------------------------------------|
724
- | list | list[st.point] | 如果没有找到,返回空列表 |
725
-
726
- ```python
727
- # 获取距离小于5的敌方creep
728
- creep = get.creep(st.friend)
729
- enemies = get.creeps(st.enemy)
730
- inrange_enemies = get.inrange(creep, enemies, 5)
731
- ```
732
-
733
- </details>
734
- <details>
735
- <summary><b>get.energy(target, percent = False, cmp = None)</b>
736
-
737
- 获取目标的能量值</summary>
738
-
739
- | param | type | description |
740
- |-------|----------------------------------|----------------------------------------|
741
- | target | st.storable | 一个可存储资源的游戏对象 |
742
- | percent | bool | 是否返回百分比(默认False) |
743
- | cmp | str | 便捷比较表达式,如'>100', '<50', '=0' (没有<= >=) |
744
-
745
- | return | type | description |
746
- |--------|------------------|------------------------------------------------------|
747
- | int \| bool | int \| bool | 如果percent为True,返回百分比[0, 100],否则返回具体能量值int; 有cmp字符串时,返回比较结果bool |
748
-
749
- ```python
750
- # 获取spawn的能量值
751
- spawn = get.spawn(st.friend)
752
- energy = get.energy(spawn)
753
- ```
754
-
755
- </details>
756
- <details>
757
- <summary><b>get.health(target, percent = False, cmp = None)</b>
758
-
759
- 获取目标的生命值</summary>
760
-
761
- | param | type | description |
762
- |-------|----------------------------------|----------------------------------------|
763
- | target | st.hitable | 一个可被攻击的游戏对象 |
764
- | percent | bool | 是否返回百分比(默认False) |
765
- | cmp | str | 便捷比较表达式,如'>100', '<50', '=0' (没有<= >=) |
766
-
767
- | return | type | description |
768
- |--------|------------------|------------------------------------------------------|
769
- | int \| bool | int \| bool | 如果percent为True,返回百分比[0, 100],否则返回具体生命值int; 有cmp字符串时,返回比较结果bool |
770
-
771
- ```python
772
- # 获取creep的生命值
773
- creep = get.creep(st.friend)
774
- health = get.health(creep)
775
- ```
776
-
777
- </details>
778
- <details>
779
- <summary><b>get.parts(creep)</b>
780
-
781
- 获取creep的parts信息</summary>
782
-
783
- | param | type | description |
784
- |-------|----------------------------------|----------------------------------------|
785
- | creep | st.creep | 一个Creep对象 |
786
-
787
- | return | type | description |
788
- |--------|------------------|------------------------------------------------------|
789
- | list[str] | list[str] | 返回一个列表,包含了目标creep的所有部件(字符串形式). 如果获取失败,返回空列表 |
790
-
791
- ```python
792
- # 获取creep的部件信息
793
- creep = get.creep(st.friend)
794
- parts = get.parts(creep)
795
- ```
796
-
797
- </details>
798
- <details>
799
- <summary><b>get.pcount(creep, part_type, broken = True)</b>
800
-
801
- 获取creep的body中指定类型的部件数量</summary>
802
-
803
- | param | type | description |
804
- |-------|----------------------------------|----------------------------------------|
805
- | creep | st.creep | 一个Creep对象 |
806
- | part_type | str | 部件类型, 如MOVE, CARRY, ATTACK, WORK, RANGED_ATTACK 等 |
807
- | broken | bool | 是否包含完全损坏的部件(默认True) |
808
-
809
- | return | type | description |
810
- |--------|------------------|------------------------------------------------------|
811
- | int | int | 返回指定类型的部件数量. 如果获取失败,返回-1 |
812
-
813
- ```python
814
- # 获取creep的MOVE部件数量
815
- creep = get.creep(st.friend)
816
- move_count = get.pcount(creep, MOVE)
817
- ```
818
-
819
- </details>
820
- <details>
821
- <summary><b>get.wait(creep)</b>
822
-
823
- 获取目标creep需要等待多少tick后才能进行移动</summary>
824
-
825
- | param | type | description |
826
- |-------|----------------------------------|----------------------------------------|
827
- | creep | st.creep | 一个Creep对象 |
828
-
829
- | return | type | description |
830
- |--------|------------------|------------------------------------------------------|
831
- | int | int | 返回等待的tick数. 如果获取失败,返回-1. 如果目标无法移动,返回0xffff |
832
-
833
- ```python
834
- # 获取creep需要等待多少tick后才能进行移动
835
- creep = get.creep(st.friend)
836
- wait = get.wait(creep)
837
- ```
838
-
839
- </details>
840
- <details>
841
- <summary><b>get.score(creep)</b>
842
-
843
- 为Creep评分</summary>
844
-
845
- | param | type | description |
846
- |-------|----------------------------------|----------------------------------------|
847
- | creep | st.creep | 一个Creep对象 |
848
-
849
- | return | type | description |
850
- |--------|------------------|------------------------------------------------------|
851
- | int | int | 返回评分值 |
852
-
853
- ```python
854
- # 为creep评分
855
- creep = get.creep(st.friend)
856
- score = get.score(creep)
857
- ```
858
-
859
- </details>
860
- <details>
861
- <summary><b>get.distance(obj, target)</b>
862
-
863
- 返回obj到目标的距离(单位: 方块数)</summary>
864
-
865
- | param | type | description |
866
- |-------|----------------------------------|----------------------------------------|
867
- | obj | st.point | 一个坐标点 |
868
- | target | st.point | 一个坐标点 |
869
-
870
- | return | type | description |
871
- |--------|------------------|------------------------------------------------------|
872
- | int | int | 返回距离值 |
873
-
874
- ```python
875
- # 获取creep到spawn的距离
876
- creep = get.creep(st.friend)
877
- spawn = get.spawn(st.friend)
878
- distance = get.distance(creep, spawn)
879
- ```
880
-
881
- </details>
882
- <details>
883
- <summary><b>get.sign(x)</b>
884
-
885
- 返回x的符号</summary>
886
-
887
- | param | type | description |
888
- |-------|----------------------------------|----------------------------------------|
889
- | x | int | 一个整数 |
890
-
891
- | return | type | description |
892
- |--------|------------------|------------------------------------------------------|
893
- | int | int | 返回符号值(0, 1, -1) |
894
-
895
- </details>
896
- <details>
897
- <summary><b>get.find(objs, filter_fn)</b>
898
-
899
- Find the first object that satisfies the condition</summary>
900
-
901
- | param | type | description |
902
- |-------|----------------------------------|----------------------------------------|
903
- | objs | list \| tuple | 待查找的对象列表 |
904
- | filter_fn | list \| tuple \| set \| callable | 容器函数表达式 |
905
-
906
- | return | type | description |
907
- |--------|----------------|-------------|
908
- | object | object \| None | 返回找到的对象 |
909
-
910
- ```python
911
- # 查找一个满足条件的creep
912
- enemies = get.creeps(st.enemy)
913
- enemy = get.find(enemies, st.atkable)
914
- ```
915
-
916
- </details>
917
- <details>
918
- <summary><b>get.filter(objs, filter_fn)</b>
919
-
920
- Returns a list of objects that satisfy the condition</summary>
921
-
922
- | param | type | description |
923
- |-------|----------------------------------|----------------------------------------|
924
- | objs | list \| tuple | 待查找的对象列表 |
925
- | filter_fn | list \| tuple \| set \| callable | 容器函数表达式 |
926
-
927
- | return | type | description |
928
- |--------|----------------|-------------|
929
- | list | list | 返回满足条件的对象列表 |
930
-
931
- ```python
932
- # 获取所有满足条件的creep
933
- enemies = get.creeps(st.enemy)
934
- atkable_enemies = get.filter(enemies, st.atkable)
935
- ```
936
-
937
- </details>
938
- <details>
939
- <summary><b>get.classname(game_object)</b>
940
-
941
- 获取游戏相关的js对象的类名</summary>
942
-
943
- | param | type | description |
944
- |-------|----------------------------------|----------------------------------------|
945
- | game_object | GameObject | 游戏对象 |
946
-
947
- | return | type | description |
948
- |--------|----------------|-------------|
949
- | str | str | 返回类名 |
950
-
951
- ```python
952
- # 获取creep的类名
953
- creep = get.creep(st.friend)
954
- cls_name = get.classname(creep)
955
- ```
956
-
957
- </details>
958
- <details>
959
- <summary><b>get.terrain(x_or_point, y = None)</b>
960
-
961
- 获取指定位置的地形</summary>
962
-
963
- | param | type | description |
964
- |-------|----------------------------------|----------------------------------------|
965
- | x_or_point | int \| st.point | x坐标或者坐标点 |
966
- | y | None \| int | y坐标。 如果传入了y坐标,那么期望的第一个参数x为int类型 |
967
-
968
- | return | type | description |
969
- |--------|----------------|-------------|
970
- | int | int | 地形常量 |
971
-
972
- ```python
973
- # 获取指定位置的地形
974
- terrain = get.terrain(10, 10)
975
- ```
976
-
977
- </details>
978
- </details>
979
-
980
- ## \> ut
981
- ut本身并不提供任何函数,内部包含多个扩展工具类,用于提供更多的功能。这些工具类可能随着版本的更新而增加或减少,具体的使用方法请参考对应的工具类文档。
982
- (下面是应该会常驻的工具类):
983
-
984
- | class | description |
985
- |-------|-------------|
986
- | ut.Stage | 有限状态机 |
987
- | ut.View | 在屏幕上绘制图像 |
988
- | ut.Efr | 事件消息框架 |
989
- | ut.Mp | 地图工具 |
990
- | ut.CInfo | Creep信息 |
991
- | ut.StV | 战略视图 |
992
- | ... | ... |
993
-
994
-
995
-
996
-
997
-
998
-
999
-
1000
-
1001
-
@@ -1,8 +0,0 @@
1
- pyscreeps_arena/__init__.py,sha256=S7k6_kTuhrf2XumCoQQ6rR7zm6HaA15pN4_RHjCSi1Y,754
2
- pyscreeps_arena/build.py,sha256=ZTQfPG5M5sU2bFI9AbI_mp3V-HaG0-Prb73MQAu-sB0,25914
3
- pyscreeps_arena/project.7z,sha256=utfgIbaNCq5FdWVH8wsiyxo9WLRx_i6KAswlVCR6cXw,49317
4
- pyscreeps_arena-0.2.2.dist-info/METADATA,sha256=fetkc9VpWMdWJkqe93tHQeWXhObVRWdUm57La7ZMzBA,46967
5
- pyscreeps_arena-0.2.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- pyscreeps_arena-0.2.2.dist-info/entry_points.txt,sha256=dqhZN327jfcNypYjEaEJ2t-ABUZ0sVhtDDrD7GiJBfo,67
7
- pyscreeps_arena-0.2.2.dist-info/top_level.txt,sha256=l4uLyMR2NOy41ngBMh795jOHTFk3tgYKy64-9cgjVng,16
8
- pyscreeps_arena-0.2.2.dist-info/RECORD,,