Skip to content

Commit 3770959

Browse files
committed
2 parents 1d5b095 + e5717b6 commit 3770959

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ChangeLog
22

3+
### v2.1.2
4+
5+
Cast all numbers to ints, ensure all observations only contain ints, no floats.
6+
37
### v2.1.1
48

59
Remove max episode timesteps from gym registration of the Lux AI env. Expect user to specify themselves

luxai_s2/luxai_s2/actions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def format_factory_action(a: int):
189189

190190
def format_action_vec(a: np.ndarray):
191191
# (0 = move, 1 = transfer X amount of R, 2 = pickup X amount of R, 3 = dig, 4 = self destruct, 5 = recharge X)
192+
a = a.astype(int)
192193
a_type = a[0]
193194
if a_type == 0:
194195
act = MoveAction(a[1], dist=1, repeat=a[4], n=a[5])

luxai_s2/luxai_s2/env.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def _handle_bid(self, actions):
250250
].factories_to_place = self.state.board.factories_per_team
251251
# verify bid is valid
252252
valid_action = True
253-
bid = abs(a["bid"])
253+
bid = math.floor(abs(a["bid"]))
254254
self.state.teams[k].bid = a["bid"]
255255
if bid > self.state.teams[k].init_water:
256256
valid_action = False
@@ -340,6 +340,8 @@ def _handle_factory_placement_step(self, actions):
340340
factory = self.add_factory(self.state.teams[k], a["spawn"])
341341
if factory is None:
342342
continue
343+
a["water"] = math.floor(a["water"])
344+
a["metal"] = math.floor(a["metal"])
343345
factory.cargo.water = a["water"]
344346
factory.cargo.metal = a["metal"]
345347
factory.power = self.env_cfg.INIT_POWER_PER_FACTORY
@@ -1015,7 +1017,7 @@ def add_factory(self, team: Team, pos: np.ndarray):
10151017
unit_id=f"factory_{self.state.global_id}",
10161018
num_id=self.state.global_id,
10171019
)
1018-
factory.pos.pos = list(pos)
1020+
factory.pos.pos = np.array([pos[0], pos[1]]).astype(int)
10191021
factory.cargo.water = self.env_cfg.INIT_WATER_METAL_PER_FACTORY
10201022
factory.cargo.metal = self.env_cfg.INIT_WATER_METAL_PER_FACTORY
10211023
factory.power = self.env_cfg.INIT_POWER_PER_FACTORY

0 commit comments

Comments
 (0)