#include "cop.h" #include "graph.h" using namespace std; #undef DEBUG CopData::CopData( int worldSize, int robberNode ) : N(worldSize), robberPosGuess(robberNode), santasList(COPS, vector(COPS, 0) ), tracks(1, vector(worldSize, -100)) { /* carMap = new nodePair*[N]; footMap = new nodePair*[N]; pureCarMap = new nodePair*[N]; pureFootMap = new nodePair*[N]; for (int i=0; i tmpset; tmpset.insert(w.robberStartPos); c.trustedRobPos.push_back(tmpset); c.naiveRobPos.push_back(tmpset); c.lastEvidenceUsed = 0; c.foreignInfo.push_back(vector(0)); makeMatrix(w.car, c.carMap, c.N); makeMatrix(w.foot, c.footMap, c.N); c.floyds( w.hq ); while (recvTurn(w)) { #ifdef DEBUG debug << "Received state " << endl; #endif c.processState(w); debug << "Done processing state\n"; vector< vector > info( COPS, vector() ), plans( COPS, vector() ); debug << "About to send info\n"; sendInform( c.makeInfo(w) ); recvInform( info ); debug << "About to process info\n"; c.processInfo( w, info ); debug << "About to updateRobPos\n"; c.updateRobPos(w); debug << "About to make plan\n"; c.makePlan(w); debug << "About to send plan\n"; sendPlan( c.myPlan ); debug << "About to receive plans\n"; recvPlan( plans ); debug << "About to rank plans\n"; vector votes = c.rankPlans(plans, w); /* votes.push_back(w.me); for (int i=0; i -1) c.setLastAcceptedPlan( plans[voteResult], w.n, voteResult ); debug << "About to make move\n"; vector ret = c.makeMove(w); #ifdef DEBUG //debug << "Picked move "<< ret.first << "," << ret.second << endl; #endif // Here, we need to determine whether we're a clean cop, or a dirty // cop, and call the appropriate move method sendCleanCopMove( ret, c.copsToAccuse ); c.copsToAccuse.clear(); // sendDirtyCopMove( vector of moves ); } #ifdef DEBUG debug << "Betrayals:" << endl; for (unsigned int i=0; i CopData::makeMove(World& w) { vector retval; vector hasMoved(COPS, false); for (unsigned int i=0; i CopData::makeInfo( World& w ) { #ifdef DEBUG debug << __FUNCTION__ << "( world:" << w.n << " )" < info; set adj; if ( w.smell > 0 ) { set adj = w.smellyNodes(pureFootMap); } else { w.smell = 1; set tmp1 = w.smellyNodes(pureFootMap); w.smell = 2; set tmp2 = w.smellyNodes(pureFootMap); set adj = intersectNodes(tmp1, tmp2); w.smell = 0; } for (set::iterator I=adj.begin(); I != adj.end(); I++) info.push_back( guess( w.robberId, *I, ROBBER, w.n, (w.smell==0 ? -100 : 25))); /*for (unsigned int i=0; i