<commit_before>#include "SingleModePlay.h"
#include "AutoPlayHelpers.h"

enum {
	DRIVEMODE_DRIVE_TO_BALL_NAIVE = 5000,
	DRIVEMODE_DIRVE_TO_BALL_AVOID_TURN,
	DRIVEMODE_DRIVE_TO_BALL_ANGLED,
	DRIVEMODE_DRIVE_TO_BALL_AIM_GATE,
	DRIVEMODE_ROTATE_AROUND_BALL
};

/*BEGIN DriveToBall*/
void DriveToBall::onEnter()
{
	toggledDribbler = false;
	DriveInstruction::onEnter();	
	initialBall = getClosestBall();
	initialGate = m_pFieldState->GetTargetGate();
}

DriveMode DriveToBall::step(double dt){
	return DRIVEMODE_DRIVE_TO_BALL_AIM_GATE;
	/*
	//return stepNaive(dt);
	if (STUCK_IN_STATE(2000) && !toggledDribbler){ 
		m_pCom->ToggleTribbler(0);
		toggledDribbler = true;
	}
	return stepAimGate(dt);
	//return stepAngled(dt);
	//return stepPenatalizeRotation(dt);
	*/
}
class DriveToBallNaive : public DriveToBall
{
public:
	DriveToBallNaive(const std::string &name = "DRIVE_TO_BALL_NAIVE") : DriveToBall(name){};

	DriveMode step(double dt)
	{

		auto &target = getClosestBall();
		if (target.getDistance() > 10000) return DRIVEMODE_IDLE;
		if (m_pCom->BallInTribbler()) return DRIVEMODE_AIM_GATE;
		//std::cout << std::endl << "aimtarget0, " ;

		if (aimTarget(target, 10)){
			if (driveToTarget(target)){
				if (aimTarget(target, 1)){
					return DRIVEMODE_CATCH_BALL;
				}
			}
		}
		return DRIVEMODE_DRIVE_TO_BALL_NAIVE;
	}
};

class DriveToBallAngled : public DriveToBall
{
public:
	DriveToBallAngled(const std::string &name = "DRIVE_TO_BALL_ANGLED") : DriveToBall(name){};

	DriveMode step(double dt)
	{
		auto &target = getClosestBall();

		if (m_pCom->BallInTribbler()) return DRIVEMODE_AIM_GATE;
		if (driveToTargetWithAngle(target, 25, 5)){
			return DRIVEMODE_CATCH_BALL;
		}
		else {
			return DRIVEMODE_DRIVE_TO_BALL_ANGLED;
		}


	}
};

class DriveToBallAvoidTurn : public DriveToBall
{
public:
	DriveToBallAvoidTurn(const std::string &name = "DRIVE_TO_BALL_AVOID_TURN") : DriveToBall(name){};

	DriveMode step(double dt)
	{
		const ObjectPosition &target = getClosestBall(true);
		//if we are between closest ball and target gate and facing target gate then drive to home
		//to avoid rotating on any next ball
		if (fabs(m_pFieldState->GetTargetGate().getHeading()) < 20
			&& fabs(target.getHeading()) > 120) {
			return DRIVEMODE_DRIVE_HOME;
		}
		if (target.getDistance() > 10000) return DRIVEMODE_IDLE;
		if (m_pCom->BallInTribbler()) return DRIVEMODE_AIM_GATE;
		//std::cout << std::endl << "aimtarget0, ";
		if (aimTarget(target, 10)){
			if (driveToTarget(target)){
				if (aimTarget(target, 2)){
					return DRIVEMODE_CATCH_BALL;
				}
			}
		}
		return DRIVEMODE_DIRVE_TO_BALL_AVOID_TURN;

	}
};
class DriveToBallAimGate : public DriveInstruction
{
public:
	DriveToBallAimGate(const std::string &name = "DRIVE_TO_BALL_AIM_GATE") : DriveInstruction(name){};

	DriveMode step(double dt){
		const ObjectPosition &ball = getClosestBall();
		const ObjectPosition &gate = m_pFieldState->GetTargetGate();
		double gateHeading = gate.getHeading();
		double ballHeading = ball.getHeading();
		double ballDistance = ball.getDistance();

		double rotation = 0;<commit_msg>tribblercheck<commit_after>#include "SingleModePlay.h"
#include "AutoPlayHelpers.h"

enum {
	DRIVEMODE_DRIVE_TO_BALL_NAIVE = 5000,
	DRIVEMODE_DIRVE_TO_BALL_AVOID_TURN,
	DRIVEMODE_DRIVE_TO_BALL_ANGLED,
	DRIVEMODE_DRIVE_TO_BALL_AIM_GATE,
	DRIVEMODE_ROTATE_AROUND_BALL
};

/*BEGIN DriveToBall*/
void DriveToBall::onEnter()
{
	toggledDribbler = false;
	DriveInstruction::onEnter();	
	initialBall = getClosestBall();
	initialGate = m_pFieldState->GetTargetGate();
}

DriveMode DriveToBall::step(double dt){
	return DRIVEMODE_DRIVE_TO_BALL_AIM_GATE;
	/*
	//return stepNaive(dt);
	if (STUCK_IN_STATE(2000) && !toggledDribbler){ 
		m_pCom->ToggleTribbler(0);
		toggledDribbler = true;
	}
	return stepAimGate(dt);
	//return stepAngled(dt);
	//return stepPenatalizeRotation(dt);
	*/
}
class DriveToBallNaive : public DriveToBall
{
public:
	DriveToBallNaive(const std::string &name = "DRIVE_TO_BALL_NAIVE") : DriveToBall(name){};

	DriveMode step(double dt)
	{

		auto &target = getClosestBall();
		if (target.getDistance() > 10000) return DRIVEMODE_IDLE;
		if (m_pCom->BallInTribbler()) return DRIVEMODE_AIM_GATE;
		//std::cout << std::endl << "aimtarget0, " ;

		if (aimTarget(target, 10)){
			if (driveToTarget(target)){
				if (aimTarget(target, 1)){
					return DRIVEMODE_CATCH_BALL;
				}
			}
		}
		return DRIVEMODE_DRIVE_TO_BALL_NAIVE;
	}
};

class DriveToBallAngled : public DriveToBall
{
public:
	DriveToBallAngled(const std::string &name = "DRIVE_TO_BALL_ANGLED") : DriveToBall(name){};

	DriveMode step(double dt)
	{
		auto &target = getClosestBall();

		if (m_pCom->BallInTribbler()) return DRIVEMODE_AIM_GATE;
		if (driveToTargetWithAngle(target, 25, 5)){
			return DRIVEMODE_CATCH_BALL;
		}
		else {
			return DRIVEMODE_DRIVE_TO_BALL_ANGLED;
		}


	}
};

class DriveToBallAvoidTurn : public DriveToBall
{
public:
	DriveToBallAvoidTurn(const std::string &name = "DRIVE_TO_BALL_AVOID_TURN") : DriveToBall(name){};

	DriveMode step(double dt)
	{
		const ObjectPosition &target = getClosestBall(true);
		//if we are between closest ball and target gate and facing target gate then drive to home
		//to avoid rotating on any next ball
		if (fabs(m_pFieldState->GetTargetGate().getHeading()) < 20
			&& fabs(target.getHeading()) > 120) {
			return DRIVEMODE_DRIVE_HOME;
		}
		if (target.getDistance() > 10000) return DRIVEMODE_IDLE;
		if (m_pCom->BallInTribbler()) return DRIVEMODE_AIM_GATE;
		//std::cout << std::endl << "aimtarget0, ";
		if (aimTarget(target, 10)){
			if (driveToTarget(target)){
				if (aimTarget(target, 2)){
					return DRIVEMODE_CATCH_BALL;
				}
			}
		}
		return DRIVEMODE_DIRVE_TO_BALL_AVOID_TURN;

	}
};
class DriveToBallAimGate : public DriveInstruction
{
public:
	DriveToBallAimGate(const std::string &name = "DRIVE_TO_BALL_AIM_GATE") : DriveInstruction(name){};

	DriveMode step(double dt){
		if (m_pCom->BallInTribbler())return DRIVEMODE_AIM_GATE;
		const ObjectPosition &ball = getClosestBall();
		const ObjectPosition &gate = m_pFieldState->GetTargetGate();
		double gateHeading = gate.getHeading();
		double ballHeading = ball.getHeading();
		double ballDistance = ball.getDistance();

		double rotation = 0;
{'fraction_non_alphanumeric': 0.12005785920925748, 'fraction_numerical': 0.011571841851494697, 'mean_word_length': 5.39568345323741, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 24, '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': '7085169', 'n_tokens_mistral': 2662, 'n_tokens_neox': 2436, 'n_words': 432}