Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneT2000 committed Feb 3, 2023
2 parents 1d5b095 + e5717b6 commit 3770959
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog

### v2.1.2

Cast all numbers to ints, ensure all observations only contain ints, no floats.

### v2.1.1

Remove max episode timesteps from gym registration of the Lux AI env. Expect user to specify themselves
Expand Down
1 change: 1 addition & 0 deletions luxai_s2/luxai_s2/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def format_factory_action(a: int):

def format_action_vec(a: np.ndarray):
# (0 = move, 1 = transfer X amount of R, 2 = pickup X amount of R, 3 = dig, 4 = self destruct, 5 = recharge X)
a = a.astype(int)
a_type = a[0]
if a_type == 0:
act = MoveAction(a[1], dist=1, repeat=a[4], n=a[5])
Expand Down
6 changes: 4 additions & 2 deletions luxai_s2/luxai_s2/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def _handle_bid(self, actions):
].factories_to_place = self.state.board.factories_per_team
# verify bid is valid
valid_action = True
bid = abs(a["bid"])
bid = math.floor(abs(a["bid"]))
self.state.teams[k].bid = a["bid"]
if bid > self.state.teams[k].init_water:
valid_action = False
Expand Down Expand Up @@ -340,6 +340,8 @@ def _handle_factory_placement_step(self, actions):
factory = self.add_factory(self.state.teams[k], a["spawn"])
if factory is None:
continue
a["water"] = math.floor(a["water"])
a["metal"] = math.floor(a["metal"])
factory.cargo.water = a["water"]
factory.cargo.metal = a["metal"]
factory.power = self.env_cfg.INIT_POWER_PER_FACTORY
Expand Down Expand Up @@ -1015,7 +1017,7 @@ def add_factory(self, team: Team, pos: np.ndarray):
unit_id=f"factory_{self.state.global_id}",
num_id=self.state.global_id,
)
factory.pos.pos = list(pos)
factory.pos.pos = np.array([pos[0], pos[1]]).astype(int)
factory.cargo.water = self.env_cfg.INIT_WATER_METAL_PER_FACTORY
factory.cargo.metal = self.env_cfg.INIT_WATER_METAL_PER_FACTORY
factory.power = self.env_cfg.INIT_POWER_PER_FACTORY
Expand Down

0 comments on commit 3770959

Please sign in to comment.