// agent.cpp: implementation of the agent class. // ////////////////////////////////////////////////////////////////////// #include "agent.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// agent::~agent() { } agent::agent(int n, int xc, int yc, int beh, int del, int bx, int by) { number = n; x = xc; y = yc; behavior = beh; boardx = bx; boardy = by; delay = del; } int agent::getX() { return x; } int agent::getY() { return y; } void agent::act() { switch(behavior) { case forwx: x = (x + 1)%boardx; break; case forwy: y = (y + 1)%boardy; break; case backx: x = (x - 1)%boardx; break; case backy: y = (y - 1)%boardx; break; case diag1: x = (x + 1)%boardx; y = (y + 1)%boardy; break; case diag2: x = (x - 1)%boardy; y = (y - y)%boardy; break; }; } int agent::getDelay() { return delay; } void agent::print() { cout << "Agent-" << number << "\t" << x << "," << y; }