Skip to content

Commit

Permalink
Fixed type annotations for game_state to be immutabledict
Browse files Browse the repository at this point in the history
  • Loading branch information
TimArnettThales committed Jul 4, 2024
1 parent 76b2c13 commit d91fbd1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/kesslergame/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class KesslerController:
game_state dictionary. This action method then sets the thrust, turn_rate, and fire commands on the ship object.
"""

def actions(self, ship_state: Dict[str, Any], game_state: type[immutabledict[str, Any]]) -> Tuple[float, float, bool, bool]:
def actions(self, ship_state: Dict[str, Any], game_state: immutabledict[Any, Any]) -> Tuple[float, float, bool, bool]:
"""
Method processed each time step by this controller.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/kesslergame/controller_gamepad.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import math
import threading
import time

from immutabledict import immutabledict

class GamepadController(KesslerController):

Expand All @@ -18,7 +18,7 @@ def __init__(self) -> None:
# can only toggle pausing every 0.5 seconds
self.pause_time_buffer = 0.5

def actions(self, ship_state: Dict[str, Any], game_state: Dict[str, Any]) -> Tuple[float, float, bool, bool]:
def actions(self, ship_state: Dict[str, Any], game_state: immutabledict[Any, Any]) -> Tuple[float, float, bool, bool]:
"""
Read in the current gamepad state, and create the appropriate actions
"""
Expand Down
2 changes: 1 addition & 1 deletion src/kesslergame/kessler_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def run(self, scenario: Scenario, controllers: List[KesslerController]) -> Tuple
liveships = [ship for ship in ships if ship.alive]

# Generate game_state info to send to controllers
game_state = immutabledict({
game_state: immutabledict = immutabledict({
'asteroids': [asteroid.state for asteroid in asteroids],
'ships': [ship.state for ship in liveships],
'bullets': [bullet.state for bullet in bullets],
Expand Down

0 comments on commit d91fbd1

Please sign in to comment.