From 54e2cf81a6cc187208a849091bda7cd94a10c894 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 27 Jun 2005 00:53:12 +0000 Subject: [PATCH] banks with guarding cops is BAD.. and public inheritance is more useful than private --- botsrc/bot.h | 8 ++++---- robbersrc/robber.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/botsrc/bot.h b/botsrc/bot.h index ee236ee..a5f469b 100644 --- a/botsrc/bot.h +++ b/botsrc/bot.h @@ -67,8 +67,8 @@ struct SPInfo{ class SPGoal{ public: - virtual ~SPGoal(){} - virtual int operator()(const SPInfo* node) const = 0; + virtual ~SPGoal(){} + virtual int operator()(const SPInfo* node) const = 0; }; class Bot { @@ -102,12 +102,12 @@ class Bot { class SimpleSPGoal : public SPGoal{ std::string _to; - SimpleSPGoal(std::string to); public: + SimpleSPGoal(std::string to); int operator()(const SPInfo* node) const; }; -class FindPlayer : SPGoal{ +class FindPlayer : public SPGoal{ int _limit; const __gnu_cxx::hash_map& _players; PlayerType _type; diff --git a/robbersrc/robber.cpp b/robbersrc/robber.cpp index dbb287a..8baf84e 100644 --- a/robbersrc/robber.cpp +++ b/robbersrc/robber.cpp @@ -41,6 +41,14 @@ string Robber::turn(){ bank != _banks.end(); ++bank){ //cerr << "Handling bank at: " << bank->first << endl; if (bank->second > 0){ + list cop = shortestPath(bank->first, cop_car, FindPlayer(_players, cop_car, 3), true); + if (cop.size() > 0) + continue; + else{ + cop = shortestPath(bank->first, cop_foot, FindPlayer(_players, cop_foot, 3), true); + if (cop.size() > 0) + continue; + } list l = shortestPath(street->first, _type, SimpleSPGoal(bank->first)); if (l.size() < 1) continue; -- 2.39.2