/**
 * \file Variables.cpp
 * \date 30.03.2002
 *
 * Interface for the coach adjustable variables class
 */

#include "Player/World/Variables.h"
#include "Player/World/World.h"
#include <string.h>

/// Initialize parameters adjusted by coach
Variables::Variables(World* w) : WorldObject(w)
{
}

Variables::Variables(const Variables& variables) : WorldObject(variables.world)
{
}

Variables& Variables::operator=(const Variables& variables)
{
	if(&variables == this) return *this;
	WorldObject::operator=(variables);
	return *this;
}

void Variables::Initialize()
{
	// Set default values of decision making tree parameters
	// We need server parameters to set up some of these
	distanceToGoal = 17.f;
	kickToGoalDirection = 0;
	
	dribleSurroundingsMaxWidth = 5;
	dribleSurroundingsMinWidth = 
		world->params->server->player_size + 
		world->params->server->ball_size + 
		world->params->server->kickable_margin; 
		
	passSurroundingsMinWidth = 3;
	passSurroundingsMaxWidth = 30;
	minXPosition = -20;
	maxXPosition = 20;

	friendDashAdjust = 6.f / 5.f;
	enemyDashAdjust = 1.f;

	friendBallCtrlBonus = 1.1f;
	enemyBallCtrlBonus = 1.1f;

#ifdef GOALIE
	tooMuchFriendCnt = 0.25f;
	tooMuchEnemyCnt = 0.25f;
#else // GOALIE
	tooMuchFriendCnt = 0.25f;
	tooMuchEnemyCnt = 2.1f;
#endif // GOALIE

	useNeuralNetwork = false;
	nStepForPredictBall = 30;
	maximumPassableFriendAge = 5;
}

bool Variables::ParseVariable(const char *name, const char *value)
{
	if(strcmp(name, "UseNeuralNetwork") == 0)
	{
		if(strcmp(value, "on") == 0) useNeuralNetwork = true;
		else if(strcmp(value, "off") == 0) useNeuralNetwork = false;
		else return false;

		return true;
	}
	// add other parameters

	return false;
}

Variables::~Variables()
{
}
