<commit_before>#ifndef CPP_GAME_CAR_TRACKER_H_
#define CPP_GAME_CAR_TRACKER_H_

#include <algorithm>
#include <fstream>
#include <iostream>
#include <limits>
#include <map>
#include <string>
#include <cmath>

#include "game/physics_params.h"
#include "game/car_predictor.h"
#include "game/crash_model.h"
#include "game/drift_model.h"
#include "game/radius_model.h"
#include "game/error_tracker.h"
#include "game/lane_length_model.h"
#include "game/gauss.h"
#include "game/position.h"
#include "game/race.h"
#include "game/simplex.h"
#include "game/velocity_model.h"
#include "game/spawn_model.h"
#include "game/physics_params.h"

#define SQR(X) ((X)*(X))

using std::map;

namespace game {

// Usage:
//
// CarTracker car_tracker(race);
//
// OnStep() {
//   car_tracker.Record(position);
//
//   // perform computation to choose best command
//   Command command = ...
//
//   car_tracker.RecordCommand(command);
// }
class CarTracker : public CarPredictor {
 public:
  CarTracker(const Race* race, const PhysicsParams& params);

  virtual ~CarTracker();

  // We need to reset the CarTracker when the game is started.
  // The first Record() after Reset is assumed to be initial position of
  // the car.
  void Reset() {
    just_started_ = true;
    last_record_had_bump = false;
  }

  void Record(const Position& position, bool bump=false);

  void RecordCommand(const Command& command) {
    last_command_ = command;
  }

  void RecordCarCrash();

  void RecordTurboAvailable(const game::Turbo& turbo);

  CarState Predict(const CarState& state, const Command& command);

  double PredictDistance(const CarState& state, const vector<double>& throttles) const;
  double PredictDistance(const CarState& state, int how_many, double throttle) const;

  bool IsSafe(const CarState& state, const Command& command);

  bool IsSafe(const CarState& state, double safe_speed = 3);
  // TODO hardcoded safe_speed

  // TODO Add nice comments
  // Slower version of IsSafe() but more correct
  // - if velocity = 0 but angular_velocity > 0, we will report not safe
  // - it will try to first accellarate if Command(0) failed
  bool GenerateSafeStates(const CarState& state, vector<CarState>* states);

  bool IsReady() const;
<commit_msg>Set safe velocity to 2<commit_after>#ifndef CPP_GAME_CAR_TRACKER_H_
#define CPP_GAME_CAR_TRACKER_H_

#include <algorithm>
#include <fstream>
#include <iostream>
#include <limits>
#include <map>
#include <string>
#include <cmath>

#include "game/physics_params.h"
#include "game/car_predictor.h"
#include "game/crash_model.h"
#include "game/drift_model.h"
#include "game/radius_model.h"
#include "game/error_tracker.h"
#include "game/lane_length_model.h"
#include "game/gauss.h"
#include "game/position.h"
#include "game/race.h"
#include "game/simplex.h"
#include "game/velocity_model.h"
#include "game/spawn_model.h"
#include "game/physics_params.h"

#define SQR(X) ((X)*(X))

using std::map;

namespace game {

// Usage:
//
// CarTracker car_tracker(race);
//
// OnStep() {
//   car_tracker.Record(position);
//
//   // perform computation to choose best command
//   Command command = ...
//
//   car_tracker.RecordCommand(command);
// }
class CarTracker : public CarPredictor {
 public:
  CarTracker(const Race* race, const PhysicsParams& params);

  virtual ~CarTracker();

  // We need to reset the CarTracker when the game is started.
  // The first Record() after Reset is assumed to be initial position of
  // the car.
  void Reset() {
    just_started_ = true;
    last_record_had_bump = false;
  }

  void Record(const Position& position, bool bump=false);

  void RecordCommand(const Command& command) {
    last_command_ = command;
  }

  void RecordCarCrash();

  void RecordTurboAvailable(const game::Turbo& turbo);

  CarState Predict(const CarState& state, const Command& command);

  double PredictDistance(const CarState& state, const vector<double>& throttles) const;
  double PredictDistance(const CarState& state, int how_many, double throttle) const;

  bool IsSafe(const CarState& state, const Command& command);

  bool IsSafe(const CarState& state, double safe_speed = 2);
  // TODO hardcoded safe_speed

  // TODO Add nice comments
  // Slower version of IsSafe() but more correct
  // - if velocity = 0 but angular_velocity > 0, we will report not safe
  // - it will try to first accellarate if Command(0) failed
  bool GenerateSafeStates(const CarState& state, vector<CarState>* states);

  bool IsReady() const;

{'fraction_non_alphanumeric': 0.12106321197230288, 'fraction_numerical': 0.0020102747375474648, 'mean_word_length': 4.350059737156512, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7423425', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1448, 'n_words': 424}