make this function float calculateTimeToSideWalls(const PlayerData& player) constexpr float SIDE_WALL_X = 4096.0f; calculate the players time too this surface info; // Modify InitializeCarState to return hasFlipX as a std::pair
std::pair<CarState, bool> InitializeCarState(RocketSim::Car* rocketSimPlayer, const rlbot::flat::PlayerInfo* playerInfo, const RLGSC::Action& controls) {
    CarState carState = {};
    bool hasFlipX = false;  // Initialize hasFlipX

    if (rocketSimPlayer != nullptr) {
        const auto& rocketSimState = rocketSimPlayer->GetState();

        carState.updateCounter = rocketSimState.updateCounter;
        carState.isOnGround = rocketSimState.isOnGround;
        memcpy(carState.wheelsWithContact, rocketSimState.wheelsWithContact, sizeof(carState.wheelsWithContact));
        carState.hasJumped = rocketSimState.hasJumped;
        carState.hasDoubleJumped = rocketSimState.hasDoubleJumped;
        carState.hasFlipped = rocketSimState.hasFlipped;
        carState.flipRelTorque = rocketSimState.flipRelTorque;
        carState.flipTime = rocketSimState.flipTime;
        carState.isFlipping = rocketSimState.isFlipping;
        carState.isJumping = rocketSimState.isJumping;
        carState.jumpTime = carState.isOnGround ? 0 : rocketSimState.jumpTime;
        carState.airTime = rocketSimState.airTime;
        carState.airTimeSinceJump = rocketSimState.airTimeSinceJump;
        carState.boost = playerInfo->boost();
        carState.timeSpentBoosting = rocketSimState.timeSpentBoosting;
        carState.isSupersonic = rocketSimState.isSupersonic;
        carState.supersonicTime = rocketSimState.supersonicTime;
        carState.handbrakeVal = rocketSimState.handbrakeVal;
        carState.isAutoFlipping = rocketSimState.isAutoFlipping;
        carState.autoFlipTimer = rocketSimState.autoFlipTimer;
        carState.autoFlipTorqueScale = rocketSimState.autoFlipTorqueScale;
        carState.worldContact = rocketSimState.worldContact;
        carState.carContact = rocketSimState.carContact;
        carState.isDemoed = playerInfo->isDemolished();
        carState.demoRespawnTimer = rocketSimState.demoRespawnTimer;
        carState.ballHitInfo = rocketSimState.ballHitInfo;
        carState.lastControls = rocketSimState.lastControls;

        hasFlipX =
            !carState.hasDoubleJumped && !carState.hasFlipped
            && carState.airTimeSinceJump < RLConst::DOUBLEJUMP_MAX_DELAY;
    }
    else {
        // Fallback to using playerInfo for some fields
        carState.hasJumped = playerInfo->jumped();
        carState.hasDoubleJumped = playerInfo->doubleJumped();
        carState.isDemoed = playerInfo->isDemolished();
        carState.boost = playerInfo->boost();
    }

    return { carState, hasFlipX };  // Return both carState and hasFlipX
}

// Update ToPlayer to accept hasFlipX
PlayerData ToPlayer(const rlbot::flat::PlayerInfo* playerInfo, RocketSim::Car* rocketSimPlayer, uint64_t ticks, int tickSkip, const rlbot::GameTickPacket& gameTickPacket, const RLGSC::Action& controls) {
    PlayerData pd = {};
    pd.carId = playerInfo->spawnId();
    pd.team = (Team)playerInfo->team();
    pd.phys = ToPhysObj(playerInfo->physics());
    pd.physInv = pd.phys.Invert();
    pd.boostFraction = playerInfo->boost() / 100.f;

    // Initialize new fields
    pd.matchGoals = playerInfo->scoreInfo()->goals();
    pd.matchSaves = playerInfo->scoreInfo()->saves();
    pd.matchAssists = playerInfo->scoreInfo()->assists();
    pd.matchShots = playerInfo->scoreInfo()->shots();
    pd.matchShotPasses = 0; // This information might not be available from rlbot
    pd.matchBumps = 0; // This information might not be available from rlbot
    pd.matchDemos = 0; // This information might not be available from rlbot
    pd.boostPickups = 0; // This information might not be available from rlbot

    // Initialize CarState and retrieve hasFlipX
    auto [carState, hasFlipX] = InitializeCarState(rocketSimPlayer, playerInfo, controls);
    pd.carState = carState;

    pd.hasFlip = hasFlipX;

    pd.hasJump = !carState.hasJumped;

    // Initialize ball_touched to false
    pd.ballTouchedStep = false;
    pd.ballTouchedTick = false;

    return pd;
}
 gravity is -650 the players mass is 180