BioinstSim  2
 All Classes Functions Variables
robotagent_optimised.h
1 #ifndef ROBOTAGENTOPTIMISED_H_
2 #define ROBOTAGENTOPTIMISED_H_
3 
4 /******************************************************************************/
5 /******************************************************************************/
6 
8 
9 /******************************************************************************/
10 /******************************************************************************/
11 
13 
14 /******************************************************************************/
15 /******************************************************************************/
16 
18 {
19  unsigned int uFV;
20  double fRobots;
21  unsigned int uMostWantedState;
22 
23  structFVsSensed(unsigned int fv, double density)
24  {
25  uFV = fv;
26  fRobots = density;
27  }
28 };
29 
30 /******************************************************************************/
31 /******************************************************************************/
32 
33 #include <list>
34 #include "common.h"
35 #include "agent.h"
36 #include "behavior.h"
37 #include "crminrobotagent_optimised.h"
38 
39 /******************************************************************************/
40 /******************************************************************************/
41 
42 using namespace std;
43 
44 /******************************************************************************/
45 /******************************************************************************/
46 
48 {
49 public:
50  CRobotAgentOptimised(const char* pch_name, unsigned int un_identification, CArguments* pc_agent_arguments, CArguments* pc_model_arguments, TBehaviorVector vec_behaviors);
51  virtual ~CRobotAgentOptimised();
52 
53  // This method is called if the agent moves to a new arena square.
54  // Useful to calculate distances to other agents, update physical
55  // links etc.
56  virtual void SimulationStepUpdatePosition();
57  virtual void SetBehaviors(TBehaviorVector vec_behaviors);
58  virtual TBehaviorVector GetBehaviors();
59 
60  virtual inline EAgentType GetType() {return ROBOT;}
61 
62  virtual CRobotAgentOptimised* GetRandomRobotWithWeights(double f_range);
63  virtual CRobotAgentOptimised* GetRandomRobotWithWeights(unsigned int u_nearestnbrs);
64 
65  virtual inline CRMinRobotAgentOptimised* GetCRMinRobotAgent() {return crminAgent;}
66 
67  virtual void SetWeight(double f_weight);
68  virtual double GetWeight() const;
69 
70  virtual inline const CFeatureVector* GetFeatureVector() const {return m_pcFeatureVector;}
71  virtual void Sense(unsigned int u_nearestnbrs);
72  virtual void UpdateFeatureVectorDistribution(unsigned int fv, double increment);
73  virtual inline list<structFVsSensed>* GetFeatureVectorsSensed() {return &listFVsSensed;}
74  virtual void PrintFeatureVectorDistribution(unsigned int id);
75 
76  virtual inline double GetFVSenseRange() const;
77 
78  virtual unsigned int GetColor();
79 
80  virtual inline unsigned int GetSelectedNumNearestNbrs() {return m_uSelectedNumNearestNbrs;}
81 
82  virtual void SetMostWantedList(list<structFVsSensed>::iterator* it, unsigned int state);
83  virtual unsigned int GetMostWantedState(unsigned int fv);
84 
85  virtual void CheckNeighborsResponseToMyFV(unsigned int* pun_number_of_toleraters, unsigned int* pun_number_of_attackers, unsigned int* pun_number_of_unconverged, bool b_logs);
86 
87  virtual void PrintDecidingAgentDetails(CFeatureVector* m_pcFV, CRobotAgentOptimised* decidingrobot);
88 
89  virtual inline unsigned int Attack(CFeatureVector* pc_feature_vector)
90  {return GetMostWantedState(pc_feature_vector->GetValue());}
91 
92  virtual inline void IncNumberFloatingPtOperations() {++m_uNumberFloatingPtOperations;}
93  virtual inline void IncNumberFloatingPtOperations(unsigned int count)
94  {for(unsigned int i=0;i<count;++i)
95  IncNumberFloatingPtOperations();}
96 
97  virtual inline unsigned long long GetNumberFloatingPtOperations()
98  { return m_uNumberFloatingPtOperations; }
99 
100 protected:
101  virtual double CountWeightsInAgentListList(TAgentListList* ptlist_agent_list_list, double f_range);
102 
103  double m_fFVSenseRange;
104  CFeatureVector* m_pcFeatureVector;
105  TBehaviorVector m_vecBehaviors;
106  CRMinRobotAgentOptimised* crminAgent;
107 
108  double m_fWeight;
109  double m_fBitflipProbabililty;
110 
111 // float* m_pfFeaturesSensed; //2^n
112 // unsigned int* m_pbMostWantedList; //2^n
113  list<structFVsSensed> listFVsSensed;
114 // list<unsigned> vecMostWantedList; // lets just use crminAgent->vecAPCs
115 
116  virtual inline void IncIt(list<structFVsSensed>::iterator *it_fvsensed, list<structFVsSensed> *list)
117  { (*it_fvsensed) == list->end() ? (*it_fvsensed):++(*it_fvsensed); }
118 
119  double m_fResponseRange;
120  unsigned int m_uSelectedNumNearestNbrs;
121 
122  unsigned long long m_uNumberFloatingPtOperations;
123 };
124 
125 /******************************************************************************/
126 /******************************************************************************/
127 
128 #endif // ROBOTAGENTOPTIMISED_H_
129 
130 /******************************************************************************/
131 /******************************************************************************/