Esempio n. 1
0
void Brain::iAmOnAPK(Agent& agent) {
	string msg = agent.whatIHear();
	int second_space, third_space, fourth_space, point;
	second_space = msg.find(' ', msg.find(' ') + 1);
	third_space = msg.find(' ', second_space + 1);
	fourth_space = msg.find(' ', third_space + 1);
	point = msg.find('.', fourth_space);
	int y = atoi(msg.substr(second_space, (third_space - second_space)).c_str());
	int x = atoi(msg.substr(fourth_space, (point - fourth_space)).c_str());
	if (this->first_pk.first == -1) {
		this->first_pk = pair<int, int>(x, y);
		this->first_pk_agent = agent.getCoord();
	} else if (this->first_pk != pair<int, int>(x, y)) {
		this->second_pk = pair<int, int>(x, y);
		this->second_pk_agent = agent.getCoord();
		deduceMapOrientation();
	}
	map<pair<int, int>, Memory>::iterator it = this->objectives.find(agent.getCoord());
	if (it != this->objectives.end()) {
		this->objectives.clear();
	}
}