}
}
-Bot::~Bot(){
-}
-
/**
nod\ eol
( nod: loc node-tag coordinate coordinate eol )*
node >> input;
node >> input;
Intersection& inter = _intersections[input];
- node >> inter.type;
+ node >> input;
+ if (input == "bank")
+ inter.type = bank;
+ else if (input == "hq")
+ inter.type = hq;
+ else if (input == "robber-start")
+ inter.type = robber_start;
+ else
+ inter.type = ordinary;
node >> inter.x;
node >> inter.y;
}
return _location;
}
-struct SPInfo{
- string name;
- bool settled;
- SPInfo* parent;
- int cost;
-};
-
struct SPInfoComp{
bool operator()(const SPInfo* v1, const SPInfo* v2){
return v1->cost > v2->cost;
}
};
-std::list<std::string> Bot::shortestPath(const std::string& from, const std::string& to, PlayerType type){
+std::list<std::string> Bot::shortestPath(const std::string& from, PlayerType type, const SPGoal& goal){
+
+ //cerr << "New shortest path from: " << from << endl;
priority_queue<SPInfo*, vector<SPInfo* >, SPInfoComp > pq;
hash_map<string,SPInfo> nodes;
node->cost = 0;
pq.push(node);
+ int g = 0;
while(!pq.empty()){
node = pq.top();
pq.pop();
//cerr << "Vector with size: " << w.size() << endl;
- //cerr << "Looking at: " << w.back() << endl;
+ //cerr << "Looking at: " << node->name << endl;
//copy(w.begin(), w.end(), ostream_iterator<string>(cerr, " : "));
- if (node->name == to){
+
+ g = goal(node);
+ if (g < 0)
+ break;
+ else if (g){
list<string> l;
front_insert_iterator<list<string> > ii(l);
do{
bool hascar = type == cop_car;
if ( (hascar && (street->second == car || street->second == both)) ||
(!hascar && (street->second == foot || street->second == both))){
+ //cerr << "Adding street: " << street->first << endl;
SPInfo* n = 0;
if (newNode == nodes.end()){
n = &nodes[street->first];