Skip to content

Commit

Permalink
handle the case where users pass in a decimal amount of ships (#202)
Browse files Browse the repository at this point in the history
Users were passing in "28.0" as a number of ships. Remove any decimals from the input string to handle this case.
  • Loading branch information
bovard authored Jul 11, 2022
1 parent 47b1309 commit f1eaf1e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kaggle_environments/envs/kore_fleets/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,18 @@ def from_str(raw: str):
if not raw:
return None
if raw.startswith(ShipyardActionType.SPAWN.name):
return ShipyardAction.spawn_ships(int(raw.split("_")[1]))
_, ship_str = raw.split("_")
try:
num_ships = int(ship_str.split(".")[0])
except _:
num_ships = 0
return ShipyardAction.spawn_ships(num_ships)
if raw.startswith(ShipyardActionType.LAUNCH.name):
_, ship_str, plan_str = raw.split("_")
num_ships = int(ship_str)
try:
num_ships = int(ship_str.split(".")[0])
except _:
num_ships = 0
return ShipyardAction.launch_fleet_with_flight_plan(num_ships, plan_str)

@staticmethod
Expand Down

0 comments on commit f1eaf1e

Please sign in to comment.