X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=botsrc%2Fbot.cpp;h=411d933ee50d7bab0ab689b320a753d464cb3f06;hb=7ea4f9f073009ba9a6bbf2fec398b0742f798658;hp=10fb5447952d3e4bd58c21e80af169cb2fbf7e6e;hpb=f0bca5d0e69c0d1035c6b32b7d2c27e671f7060b;p=icfp05.git diff --git a/botsrc/bot.cpp b/botsrc/bot.cpp index 10fb544..411d933 100644 --- a/botsrc/bot.cpp +++ b/botsrc/bot.cpp @@ -47,10 +47,10 @@ void Bot::play(){ getline(cin, input); if (input == "game-over") return; - cerr << input << endl; - cerr << "Updating world" << endl; + //cerr << input << endl; + //cerr << "Updating world" << endl; updateWorld(); - cerr << "Done updating world" << endl; + //cerr << "Done updating world" << endl; _type = _players[_name].type; _location = _players[_name].location; //cerr << "New turn" << endl; @@ -155,22 +155,29 @@ void Bot::buildGraph(){ if (type == "foot"){ _intersections[from].connections[to] = both; Intersection& inter = _intersections[to]; - if (inter.connections.find(from) == inter.connections.end()) + hash_map::iterator conn = inter.connections.find(from); + if (conn == inter.connections.end()) inter.connections[from] = foot; - }else - _intersections[from].connections[to] = car; + else if (conn->second == car) + inter.connections[from] = both; + }else{ + Intersection& inter = _intersections[from]; + hash_map::iterator conn = inter.connections.find(to); + if (conn == inter.connections.end()) + inter.connections[from] = car; + else if (conn->second == foot) + inter.connections[from] = both; + } } //cerr << "Number of streets: " << streets << endl; getline(cin, input); } void Bot::updateWorld(){ - cerr << "Entered updateWorld function" << endl; string input; getline(cin,input); - cerr << input << endl; _world = value(input); - cerr << "World: " << _world << endl; + //cerr << "World: " << _world << endl; getline(cin,input); _robbed = value(input); @@ -264,7 +271,7 @@ T value(std::string input){ } std::string Bot::turn(){ - cerr << "Using stupid stand still Bot::turn" << endl; + //cerr << "Using stupid stand still Bot::turn" << endl; return _location; } @@ -362,10 +369,12 @@ std::list Bot::shortestPath(const std::string& from, PlayerType typ return list(); } -SimpleSPGoal::SimpleSPGoal(std::string to):_to(to){ +SimpleSPGoal::SimpleSPGoal(const std::string& to, int limit):_to(to), _limit(limit){ } int SimpleSPGoal::operator()(const SPInfo* node) const{ + if (_limit > 0 && node->cost >= _limit) + return -1; if (node->name == _to) return 1; return 0;