whats the differense between this python action parser and this cpp one class…
- User
whats the differense between this python action parser and this cpp one class SeerActionV4(ActionParser): def init(self): super().init() self._lookup_table = self.make_lookup_table()
@staticmethod def make_lookup_table(): actions = [] # Ground for throttle in (-1, 0, 1): for steer in (-1, 0, 1): for boost in (0, 1): for handbrake in (0, 1): if boost == 1 and throttle != 1: continue actions.append([throttle or boost, steer, 0, steer, 0, 0, boost, handbrake]) # Aerial for pitch in (-1, 0, 1): for yaw in (-1, 0, 1): for roll in (-1, 0, 1): for jump in (0, 1): for boost in (0, 1): if jump == 1 and yaw != 0: # Only need roll for sideflip continue if pitch == roll == jump == 0: # Duplicate with ground continue actions.append([boost, yaw, pitch, yaw, roll, jump, boost, 0]) actions = np.array(actions) return actions def get_action_space(self) -> gym.spaces.Space: return Discrete(len(self._lookup_table)) def parse_actions(self, actions: Any, state: GameState) -> np.ndarray: return self._lookup_table[actions] RLGSC::DiscreteAction::DiscreteAction() { Action a = {}; constexpr float // Boolean input R_B[] = { 0, 1 }, // Float input (hint: you can add partial inputs here) R_F[] = { -1, 0, 1 }; // TODO: Use std permutations here or whatever // Ground for (float throttle : R_F) { for (float steer : R_F) { for (float boost : R_B) { for (float handbrake : R_B) { // Prevent useless throttle when boosting if (boost == 1 && throttle != 1) continue; actions.push_back( { throttle, steer, 0, steer, 0, 0, boost, handbrake } ); } } } } // Aerial for (float pitch : R_F) { for (float yaw : R_F) { for (float roll : R_F) { for (float jump : R_B) { for (float boost : R_B) { // Only need roll for sideflip if (jump == 1 && yaw != 0) continue; // Duplicate with ground if (pitch == roll && roll == jump && jump == 0) continue; // Enable handbrake for potential wavedashes float handbrake = (jump == 1) && (pitch != 0 || yaw != 0 || roll != 0); actions.push_back( { boost, yaw, pitch, yaw, roll, jump, boost, handbrake } ); } } } } } static std::once_flag onceFlag; std::call_once(onceFlag, [=] { RG_LOG("DiscreteAction(): Lookup table built, action count: " << actions.size()); } );}
- Assistant