#include "ClosedZone.h"
#include "DebugAI.h"

ClosedZone::ClosedZone(void){
	name = CLOSED_ZONE;
	begin = 1;
	end = 10;
}

ClosedZone::~ClosedZone(void)
{
}

ClosedZone::ClosedZone(Distance* aFuzzyNumber){
	fuzzyNumber = aFuzzyNumber;
	fuzzyNumber->addFV(this);
	name = CLOSED_ZONE;
	begin = 1;
	end = 10;
}

void ClosedZone::update(){
	if (this->getFuzzyNumberValue()>= 0 && this->getFuzzyNumberValue()<=begin){
		setValue(1);
	}
	if (this->getFuzzyNumberValue()>= end){
		setValue(0);
	}
	if (this->getFuzzyNumberValue()<0){
		//If the execution go here they must have a problem.
		setValue(-1);
	}
	if (this->getFuzzyNumberValue()>= begin && this->getFuzzyNumberValue()<end){
		setValue((this->getFuzzyNumberValue() * (-1/(end-begin))) + (end/(end-begin)));
	}
	DebugAI::trace('v', toString());
}
void ClosedZone::setBegin(float aBegin){
	begin = aBegin;
}

void ClosedZone::setEnd(float aEnd){
	end = aEnd;
}