1+ from pathlib import Path
12import numpy as np
23import torch
34from agent import Agent
45from necto_obs import NectoObsBuilder
5- from rlgym_compat import GameState
6+ from rlgym_compat import V1GameState
7+ from rlgym_compat .sim_extra_info import SimExtraInfo
68
79from rlbot .flat import ControllerState , GameStateType , GameTickPacket , Vector3
810from rlbot .managers import Bot
3335 ]
3436)
3537
38+ COLLISION_MESH_PATH = Path (__file__ ).parent / "collision_meshes"
39+
3640
3741class Necto (Bot ):
3842 agent = Agent ()
@@ -51,6 +55,8 @@ class Necto(Bot):
5155 kickoff_index = - 1
5256 ticks = tick_skip # So we take an action the first tick
5357
58+ sim_extra_info : SimExtraInfo | None = None
59+
5460 def initialize_agent (self ):
5561 # Initialize the rlgym GameState object now that the game is active and the info is available
5662 self .obs_builder = NectoObsBuilder (self .field_info )
@@ -62,7 +68,14 @@ def initialize_agent(self):
6268 "\n " .join (map (str , self .field_info .boost_pads )),
6369 )
6470
65- self .game_state = GameState (self .field_info , self .tick_skip )
71+ self .game_state = V1GameState (
72+ self .field_info , self .match_settings , self .tick_skip
73+ )
74+
75+ if COLLISION_MESH_PATH .exists ():
76+ self .sim_extra_info = SimExtraInfo (
77+ self .field_info , self .match_settings , self .tick_skip
78+ )
6679
6780 self .logger .warning (
6881 "Remember to run Necto at 120fps with vsync off! "
@@ -124,7 +137,11 @@ def get_output(self, packet: GameTickPacket) -> ControllerState:
124137 if len (packet .balls ) == 0 :
125138 return self .controls
126139
127- self .game_state .decode (packet )
140+ extra_info = None
141+ if self .sim_extra_info is not None :
142+ extra_info = self .sim_extra_info .get_extra_info (packet )
143+
144+ self .game_state .update (packet , extra_info )
128145
129146 if self .update_action == 1 and len (self .game_state .players ) > self .index :
130147 self .update_action = 0
0 commit comments