#include "pqueue.h" #include const int matrixX = 10; const int matrixY = 10; void main(){ int x,y; pqueue q(100);//create a priority queue with space for 100. agent agent0(0,0,0,forwx, 3, matrixX, matrixY); q.insert(5,&agent0);//his first move is at time 5. agent agent1(1,5,5,forwy, 5, matrixX, matrixX); q.insert(6,&agent1); agent agent2(2,3,3,diag1, 10, matrixX, matrixY); q.insert(4,&agent2); event nextEvent; int time, counter=0; agent * curAgent; while (counter++ < 23){// run for 23 cycles nextEvent = q.deleteMin(); //get next event curAgent = nextEvent.ag; //get the agent involved in the event time = nextEvent.time; //get the current time. if (time == -1) break; //no more events. so we quit. x = curAgent->getX(); y = curAgent->getY(); //agent's coordinates curAgent->act(); //tell agent to move x = curAgent->getX(); y = curAgent->getY(); //agent's new pos q.insert(time + curAgent->getDelay(), curAgent); //put the agent's event in q cout << time << "\t"; curAgent->print(); cout << endl;}; char c; cin >> c;}