int Agent::nextAction(State s, FANN::neural_net*& net, Position self_pos, Home home, double eps) { //stateTrajectory.push_back(s); //TODO if adding threading, change to drand48_r() and rand_r() if (drand48() < eps) { return rand() % 6; } if (this->isCarrying()) { Position home_pos = home.getPosition(); if (home_pos == self_pos) return SET_DOWN; if (abs(self_pos.getX() - home_pos.getX()) > abs(self_pos.getY() - home_pos.getY())) { if (self_pos.getX() > home_pos.getX()) { return MOVE_LEFT; } else { return MOVE_RIGHT; } } else{ if (self_pos.getY() > home_pos.getY()) { return MOVE_UP; } else { return MOVE_DOWN; } } } /* Picks the output from the neural net */ fann_type* output = net->run( (fann_type*) s.array); int max_i = 0; for (int i = 0; i < 6; ++i) { if (output[i] > output[max_i]) { max_i = i; } } return max_i; }