+ }
+ if (positions.size() > 0){
+ _robberLocation = positions.top().second;
+ //cerr << "Sending myself to: " << _robberLocation << ", probability of robber: " << positions.top().first << endl;
+ }
+ for (int i = 0; i < 2 && positions.size() > 1; ++i ){
+ positions.pop();
+ locations.push_back(positions.top().second);
+ //cerr << "Sending another cop to: " << locations.back() << ", probability of robber: " << positions.top().first << endl;
+ }
+ }else{
+ locations.push_back(_robberLocation);
+ locations.push_back(_robberLocation);
+ }
+ if (!_robberLocation.empty()){
+ //cerr << "Robber found at " << _robberLocation << endl;
+ _copTargets[_name].first = _robberLocation;
+
+ vector<string> busyCops;
+ busyCops.push_back(_name);
+ while (locations.size() > 0){
+ string cop;
+ int dist = 1000000;
+ for (hash_map<string,Player>::const_iterator player = _players.begin();
+ player != _players.end();++player){
+ if (player->second.type == robber || find(busyCops.begin(), busyCops.end(), player->first) != busyCops.end())
+ continue;
+ list<string> l = shortestPath(player->second.location, player->second.type,SimpleSPGoal(locations.front(), dist-1));
+ if (l.size() > 0 && l.size() < dist){
+ dist = l.size();
+ cop = player->first;
+ if (dist == 1)
+ break;
+ }
+ }
+ if (!cop.empty()){
+ //cerr << "Sending " << cop << " to " << locations.front() << endl;
+ _copTargets[cop].first = locations.front();
+ busyCops.push_back(cop);
+ }
+ locations.pop_front();
+ }
+ }
+ //cerr << "Sending plan." << endl;
+ cout << "plan\\" << endl;
+ for(hash_map<string, pair<string, PlayerType> >::iterator player = _copTargets.begin();
+ player != _copTargets.end(); ++player){
+ Player& pl = _players[player->first];
+ if (pl.type != player->second.second
+ && pl.location != _copHq)
+ player->second.second = pl.type;
+ list<string> playerRoute = shortestPath(pl.location, player->second.second, SimpleSPGoal(player->second.first));
+ if (playerRoute.size() > 1){
+ list<string>::iterator i = playerRoute.begin();
+ ++i;
+ if (*i == _robberLocation || !(playerRoute.size() == 2 && _intersections[*i].type == bank)){
+ if (player->first == _name)
+ _location = *i;
+ //cerr << "Sending " << player->first << " to " << *i << " by " << player->second.second << endl;
+ cout << "plan: " << player->first << " " << *i << " " << _playerTypeNames[player->second.second] << " " << _world+1 << endl;
+ }
+ }
+ }