00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "agentrobber.h"
00023 #include "kernel.h"
00024 #include "message.h"
00025
00026
00027
00028 AgentRobber::AgentRobber(Kernel& kernel, Environment& env, int x, int y):
00029 Agent(kernel, env, x, y, ROLE_ROBBER)
00030 {
00031 this->born();
00032
00033
00034 this->SetGraphicCode( OC_VEHICLE_ROBBER );
00035 }
00036
00037
00038
00039 AgentRobber::~AgentRobber()
00040 {
00041 if (m_agent_state != AGENT_DIE)
00042 this->die();
00043 }
00044
00045
00046
00047 void AgentRobber::processMessage()
00048 {
00049 }
00050
00051
00052
00053 void AgentRobber::born()
00054 {
00055 Agent::born();
00056 m_kernel.registerRole(this, ROLE_ROBBER);
00057 }
00058
00059
00060
00061 void AgentRobber::live()
00062 {
00063 static bool first = true;
00064 if (first)
00065 {
00066 sendMessage(
00067 ROLE_POLICE,
00068 Message( Message::MSG_NEW_ROBBER ) << 10 << 5);
00069 first = false;
00070 }
00071 }
00072
00073
00074
00075 void AgentRobber::die()
00076 {
00077 Agent::die();
00078 m_kernel.unregisterRole(this, this->getRole());
00079 }
00080
00081
00082
00083 void AgentRobber::output (std::ostream& os) const
00084 {
00085 os << "AgentRobber " << getId();
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119