Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

agentpolice.h

00001 /***************************************************************************
00002                         agentpolice.h  -  description
00003                             -------------------
00004     begin                : nov 29th 2005
00005     copyright            : (C) 2005 by Duong-Khang NGUYEN
00006     email                : neoneurone @ users sourceforge net
00007     author               : Victor STINNER
00008     
00009     $Id: agentpolice.h 32 2006-08-06 18:59:25Z neoneurone $
00010  ***************************************************************************/
00011 
00012 /***************************************************************************
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   any later version.                                                    *
00018  *                                                                         *
00019  ***************************************************************************/
00020 
00021 #ifndef _OPENCITY_AGENTPOLICE_H_
00022 #define _OPENCITY_AGENTPOLICE_H_ 1
00023 
00024 #include "agent.h"
00025 #include <vector>
00026 
00027 // Forward declarations
00028 class Destination;
00029 
00030    /*=====================================================================*/
00034 class AgentPolice : public Agent
00035 {
00036 public:
00037     typedef enum
00038     {
00039         POLICE_LOOK,
00040         POLICE_PURSUE,
00041         POLICE_LOST_PURSUE,
00042         POLICE_COLLABORATE
00043     } police_state_t;
00044 
00045     AgentPolice(Kernel& kernel, Environment& env, int x, int y);
00046     virtual ~AgentPolice();
00047 
00048     virtual void processMessage();
00049     virtual void born();
00050     virtual void live();
00051     virtual void die();
00052     virtual void output(std::ostream& os) const;
00053 
00054 protected:
00055     police_state_t m_state;
00056     unsigned int m_sleep;
00057     unsigned int m_pursue;
00058     unsigned int m_lost_pursue;
00059     
00060     Agent* SeeBadGuy(direction_t dir);
00061     void Look();
00062     void Pursue();
00063     void Collaborate();
00064     void SetState(police_state_t state);
00065     void NoticePursue(Agent *agent);
00066     Agent* FindBadGuy(bool test_backward=true);
00067     void LostPursue();
00068     Agent* IsNearBadGuy();
00069 
00070 // For collaboration and path finding
00071     unsigned int m_index;
00072     std::vector<Destination> m_path;
00073     typedef std::vector<Destination>::iterator m_path_it;
00074 
00075 private:
00076    /*=====================================================================*/
00077    /*                        PRIVATE     METHODS                          */
00078    /*=====================================================================*/
00079     void followPath();
00080 };
00081 
00082 #endif
00083 
00084 
00085 
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 

Generated on Sat Nov 11 10:21:09 2006 for OpenCity by  doxygen 1.4.2