Loading [MathJax]/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
THare Class Reference

The base class for all hare classes. More...

#include <Hare_All.h>

Inheritance diagram for THare:
TAnimal TALMaSSObject Hare_Infant Hare_Juvenile Hare_Young Hare_Female Hare_Male

Public Member Functions

 THare (int p_x, int p_y, Landscape *p_L, THare_Population_Manager *p_PPM)
 Constructor. More...
 
void THareInit (int p_x, int p_y, THare_Population_Manager *p_PPM)
 Object Initiation. More...
 
 ~THare () override
 Destructor. More...
 
virtual TTypeOfHareState st_Dispersal ()
 Base implementation only - reimplemented. More...
 
void BeginStep (void) override
 Base implementation only - reimplemented. More...
 
void Step (void) override
 Base implementation only - reimplemented. More...
 
void EndStep (void) override
 Base implementation only - reimplemented. More...
 
double GetWeight ()
 
double GetTotalWeight ()
 Provide the wet weight of the hare. More...
 
int GetAge ()
 Provide the age of the hare. More...
 
void ON_MumDead (Hare_Female *a_Mum)
 Inform Mum that we are dead. More...
 
Hare_FemaleGetMum ()
 Get the mother pointer. More...
 
double GetRMR ()
 Get todays RMR. More...
 
virtual bool WasPredated ()
 Test for predation. More...
 
int GetRefNum ()
 Get the refnum for this hare. More...
 
virtual void ON_Dead (void)
 Mortality - overridden in descendent classes. More...
 
void loadVegPalatability (void)
 Loads static member m_vegPalatability with data. More...
 
- Public Member Functions inherited from TAnimal
 TAnimal (int x, int y, Landscape *L)
 The TAnimal constructor saving the x,y, location and the landscape pointer. More...
 
 TAnimal (int x, int y)
 The TAnimal constructor saving the x,y used if landscape is already set. More...
 
void SetGuardMapIndex (int a_index_x, int a_index_y)
 Set the guard map index, this is used to avoid two animals operating in the same location when using multithread. More...
 
unsigned SupplyFarmOwnerRef () const
 Get the current location farm ref if any. More...
 
AnimalPosition SupplyPosition () const
 Returns the objects location and habitat type and veg type. More...
 
APoint SupplyPoint () const
 Returns the objects location in ALMaSS coordinates. More...
 
int SupplyPolygonRef () const
 Returns the polygon reference where the object is located. More...
 
TTypesOfLandscapeElement SupplyPolygonType () const
 Returns the polygon type where the object is located. More...
 
int Supply_m_Location_x () const
 Returns the ALMaSS x-coordinate. More...
 
int Supply_m_Location_y () const
 Returns the ALMaSS y-coordinate. More...
 
int SupplyGuardCellX () const
 Returns the x-index to the guard cell. More...
 
int SupplyGuardCellY () const
 Returns the y-index to the guard cell. More...
 
int SupplyAge () const
 Returns the animals age in days. More...
 
void SetAge (int a_age)
 Sets the animals age in days. More...
 
virtual void KillThis ()
 Sets all parameters ready for object destruction. More...
 
virtual void CopyMyself ()
 Used to copy the object details to another in descendent classes. More...
 
void SetX (const int a_x)
 Sets the x-coordinate. More...
 
void SetY (const int a_y)
 Sets the y-coordinate. More...
 
virtual void ReinitialiseObject (int a_x, int a_y, Landscape *a_l_ptr)
 
virtual void ReinitialiseObject (int a_x, int a_y)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual int WhatState ()
 Returns the objects current state number. More...
 
virtual void Dying ()
 A wrapped for KillThis - ideally should not be used. More...
 
void CheckManagement ()
 Used to start a check for any management related effects at the objects current location. More...
 
void CheckManagementXY (int a_x, int a_y)
 Used to start a check for any management related effects at x,y. More...
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo () const
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone () const
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
void ReinitialiseObjectBase ()
 Used to initialise an object. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()=default
 The destructor for TALMaSSObject. More...
 

Static Public Member Functions

static void SetMum (Hare_Female *)
 Set the mother pointer. Reimplemented in Hare_Infant. More...
 
- Static Public Member Functions inherited from TAnimal
static void SetSimulationWidth (int a_value)
 Sets the simulation width. More...
 
static void SetSimulationHeight (int a_value)
 Sets the simulation height. More...
 
static void SetDayInYear (int a_value)
 Sets the day in year attribute. More...
 
static void SetOurLandscape (Landscape *a_value)
 Sets the landscape pointer. More...
 
static void SetTempToday (double a_value)
 Sets the temperature today attribute. More...
 
- Static Public Member Functions inherited from TALMaSSObject
static void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 

Static Public Attributes

static double * m_vegPalatability = nullptr
 Will hold and array of palatability for hare for each tov type. Most are 1, but unpalatable vegetation can be specified here. More...
 

Protected Member Functions

bool Run (int a_dist, int a_direction)
 Run a distance in a direction. More...
 
void EnergyBalance (TTypeOfActivity a_activity, int dist)
 Adjust energy balance for an activity. More...
 
void TimeBudget (TTypeOfActivity a_activity, int dist)
 Adjust time budger for an activity. More...
 
void st_Dying ()
 Tidy up before removing the object on death. More...
 
virtual void Running (int a_max_dist)
 Run. More...
 
void Walking (int a_dist, int a_direction)
 Walking. More...
 
double Forage (int &time)
 Foraging. More...
 
double ForageP (int &time)
 Foraging but also incorporating pesticide exposure. More...
 
virtual void InternalPesticideHandlingAndResponse ()
 Handles internal effects of pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes. More...
 
virtual void GeneralEndocrineDisruptor (double)
 Handles internal effects of endocrine distrupter pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes. More...
 
virtual void GeneralOrganoPhosphate (double)
 Handles internal effects of organophosphate pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes. More...
 
double ForageSquare (int a_x, int a_y)
 Forage from an area. More...
 
double ForageSquareP (int a_x, int a_y, double *a_pestexposure)
 Forage from an area and resturn pesticide exposure as well as food. More...
 
int GetPegDistance ()
 Get peg distance. More...
 
int GetPegPull ()
 Get attractive force of peg. More...
 
int GetPegDirection ()
 Get direction of peg. More...
 
void MovePeg ()
 Move the peg according to attraction forces. More...
 
bool OnFarmEvent (FarmToDo event) override
 Do we require a response to a farm event. More...
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 

Protected Attributes

TTypeOfHareState m_CurrentHState
 Defines the current activity. More...
 
int m_Age = 0
 State variale - hare age. More...
 
Hare_Object m_Type
 State variale - the type of hare. More...
 
double m_weight = 0.0
 State variale - hare weight g. More...
 
double m_old_weight = 0.0
 State variale - last hare weight. More...
 
Hare_Femalem_MyMum = nullptr
 Pointer to the hare's mum. More...
 
THare_Population_Managerm_OurPopulationManager
 Pointer to the hare population manager. More...
 
int m_Lifespan = 0
 Physiolocal lifespan, assuming nothing else kills the hare (unlikely to reach this age) More...
 
int m_ActivityTime = 0
 Minutes of potential activity time per day. More...
 
int m_StarvationDays = 0
 State variable - the number of consecutive days in negative energy balance. More...
 
double m_fatReserve = 0.0
 State variable - the energy reserve of the hare. More...
 
double m_TodaysEnergy = 0.0
 State variable - the amount of energy available today, can be in deficit. More...
 
double m_EnergyMax = 0.0
 State variable - the amount of energy it is possible to eat as a multiplyer or RMR. More...
 
double m_KJRunning = 0.0
 KJ/m cost of running per kg hare. More...
 
double m_KJWalking = 0.0
 KJ/m cost of walking per kg hare. More...
 
double m_KJForaging = 0.0
 KJ/m cost of foraging per kg hare. More...
 
double m_SpeedRunning = 0.0
 m/min speed of running per kg hare More...
 
double m_SpeedWalking = 0.0
 m/min speed of walking per kg hare More...
 
double m_foragingenergy = 0.0
 Energy obtained from foraging/feeding. More...
 
int m_peg_x = 0
 peg x-coordinate More...
 
int m_peg_y = 0
 peg y-coordinate More...
 
int m_RefNum = 0
 Unique hare reference number, also functions as sex flag. More...
 
int m_experiencedDensity = 0
 State variable used in alternative density-dependent configurations. More...
 
int m_lastYearsDensity = 0
 State variable used in alternative density-dependent configurations. More...
 
int m_ddindex = 0
 State variable used in alternative density-dependent configurations. More...
 
int m_expDensity [365] = {}
 State variable used in alternative density-dependent configurations. More...
 
int m_DensitySum = 0
 State variable used in alternative density-dependent configurations. More...
 
bool m_IamSick = false
 flag for sickness - used in conjunction with disease configurations More...
 
double m_pesticide_burden = 0.0
 State variable used to hold the current body-burden of pesticide. More...
 
double m_pesticidedegradationrate = 0.0
 State variable used to hold the daily degredation rate of the pesticide in the body. More...
 
bool m_pesticideInfluenced1 = false
 Flag to indicate pesticide effects (e.g. can be used for endocrine distruptors with delayed effects until birth). More...
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 The objects ALMaSS x coordinate. More...
 
int m_Location_y
 The objects ALMaSS y coordinate. More...
 
int m_guard_cell_x
 The index x to the guard cell. More...
 
int m_guard_cell_y
 The index y to the guard cell. More...
 
int m_AgeDays {0}
 To hold the age in days. More...
 
PesticideToxicity m_my_pesticide
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from TAnimal
static Landscapem_OurLandscape = nullptr
 A pointer to the landscape object shared with all TAnimal objects. More...
 
static int m_SimulationWidth = 0
 A static member for the simulation width because it is often used by descendent classes. More...
 
static int m_SimulationHeight = 0
 A static member for the simulation height because it is often used by descendent classes. More...
 
static double m_TemperatureToday = 0.0
 A holder for the temperature today shared with all TAnimal objects. More...
 
static int m_DayInYear = 0
 A holder for the day in year shared with all TAnimal objects. More...
 

Detailed Description

The base class for all hare classes.

Constructor & Destructor Documentation

◆ THare()

THare::THare ( int  p_x,
int  p_y,
Landscape p_L,
THare_Population_Manager p_PPM 
)

Constructor.

THare constructor code

65  : TAnimal(p_x, p_y)
66 {
67  THareInit(p_x, p_y, p_PPM);
68 }

References THareInit().

◆ ~THare()

THare::~THare ( )
override

Destructor.

THare destructor

110 {
111 }

Member Function Documentation

◆ BeginStep()

void THare::BeginStep ( void  )
inlineoverridevirtual

Base implementation only - reimplemented.

Reimplemented from TALMaSSObject.

Reimplemented in Hare_Female, Hare_Male, Hare_Juvenile, Hare_Young, and Hare_Infant.

344  {
345  }

◆ EndStep()

void THare::EndStep ( void  )
inlineoverridevirtual

Base implementation only - reimplemented.

Reimplemented from TALMaSSObject.

Reimplemented in Hare_Female, Hare_Male, Hare_Juvenile, Hare_Young, and Hare_Infant.

356 { MovePeg(); }

References MovePeg().

◆ EnergyBalance()

void THare::EnergyBalance ( TTypeOfActivity  a_activity,
int  dist 
)
protected

Adjust energy balance for an activity.

This method calculates energy used and subtracts this from the fat store.
The fat store is KJ so no conversion is required here. The fat store can only be a maximum X% of the body weight

262 {
267  switch (a_activity)
268  {
269  case activity_Resting:
271  break;
272  case activity_Running:
273  // Note here it is the fatReserve that is altered
274  // This is because this activity could be called at anytime, and we
275  // do not know if m_TodaysEnergy is set to anything sensible. fatReserve is
276  // always sensible though. Note this will potentially influence behaviour
277  // if running causes a low fatReserve.
278  m_fatReserve-=dist*m_KJRunning; // dist in metres
279  break;
280  case activity_Dispersal:
281  m_TodaysEnergy-=dist*m_KJWalking; // dist in metres
282  break;
283  case activity_Walking:
284  m_TodaysEnergy-=dist*m_KJWalking; // dist in metres
285  break;
286  case activity_Foraging:
287  m_TodaysEnergy-=dist*m_KJForaging; // dist in minutes
288  // Checking code
290  break;
291  default:
292  m_OurLandscape->Warn("THare::EnergyBalance - unknown activity",NULL);
293  exit(1);
294  }
295 }

References activity_Dispersal, activity_Foraging, activity_Resting, activity_Running, activity_Walking, THare_Population_Manager::GetRMR(), GetTotalWeight(), m_Age, m_fatReserve, m_foragingenergy, m_KJForaging, m_KJRunning, m_KJWalking, TAnimal::m_OurLandscape, m_OurPopulationManager, m_TodaysEnergy, and Landscape::Warn().

Referenced by Forage(), ForageP(), Running(), Hare_Male::st_Developing(), Hare_Female::st_Developing(), Hare_Juvenile::st_Dispersal(), Hare_Young::st_Resting(), and Hare_Juvenile::st_Resting().

◆ Forage()

double THare::Forage ( int &  time)
protected

Foraging.

This could be implemented in each hare's st_Foraging, but is implemented as a common method because all the hares do it the same way. This method determine how much energy can be foraged from the current location in the time available (a_time).
It is important that energy used for foraging is deducted from the energybudget calculations before calculating the target - otherwise growth will be affected.
Efficiency can be roughly calculated for optimal forage by calculating the number squares and the cost of foraging together with the return. e.g. 100m2 -> 10m2 forage with ext of 5.0 = 50KJ at a cost of 100*m_KJForaging.
Hence return can be calculated and the target adjusted accordingly

m_EnergyMax is the max amount of energy possible in one day (intake/cfg_hare_ExtEff to reduce calculations). This needs to be no more than they ever need, the closer to this limit the faster the code will run due to avoiding unnecessary searching, but also will prevent high energy usage being offset by too high intake. m_EnergyMax is set at the beginnng of each day in BeginStep.

53 {
62  #define __SQRS 100 // __SQRS is the number of m2 foraged per forage square
63  int y_add[8] = { -10, -10, 0, 10, 10, 10, 0, -10 }; // N,NE,E,SE,S,SW,W,NW
64  int x_add[8] = { 0, 10, 10, 10, 0, -10, -10, -10 }; // N,NE,E,SE,S,SW,W,NW
65  unsigned next=0;
66  double food[8];
67  int bestsquare = 0;
75  // Get the top corner of our square
76  int x=m_Location_x;
77  int y=m_Location_y;
78  // Search central square
79  double TotalFood = ForageSquare(x,y); // this calls walking automatically
80  a_time -= __SQRS;
81  EnergyBalance(activity_Foraging, __SQRS * 5); // Assume a 20cm swath, therefore distance = 5 * m2
82  if ((a_time - __SQRS)<0)
83  {
84  return TotalFood;
85  }
86  // Set up searching for the next 8 squares around this one
87  food[0]=0;
88  int equal=0;
89  double best=-1;
90  for (int i=0; i<8; i++)
91  {
92  x = m_Location_x+x_add[i];
93  y = m_Location_y+y_add[i];
94  food[i]=ForageSquare(x,y);
95  if (food[i]>best) {
96  best=food[i];
97  equal=0;
98  bestsquare=i;
99  } else if (food[i]==best)
100  {
101  equal++;
102  }
103  }
104  if (equal>0)
105  {
106  // No real direction to move in, so go towards our peg if this is OK
107  unsigned pd=(GetPegDirection());
108  // Our normal directions are 0-7 N,NE,E,SE,S,SW,W,NW //
109  if (food[pd] == best) bestsquare=pd;
110  else {
111  pd= (pd-1) & 0x07;
112  if (food[pd] == best) bestsquare=pd;
113  else {
114  // First check the directions
115  bestsquare=-1;
116  while (bestsquare==-1)
117  {
118  int t=g_random_fnc(8);
119  if (food[t]==best) bestsquare=t;
120  }
121  }
122  }
123  }
124  // Now move to the next square, also the best in food return
125  a_time -= __SQRS;
127  Walking(10, bestsquare);
128  TotalFood+=food[bestsquare];
129  if (TotalFood>=m_EnergyMax)
130  {
131  return m_EnergyMax;
132  }
133  // OK now dependent upon the direction bestsquare, we need to check 3 or 5 new squares for food
134  while (a_time>0)
135  {
136  int nsqs;
137  int subtract=1+(bestsquare & 1);
138  if ( subtract == 1) nsqs = 3; else nsqs = 5;
139  for (int j=0; j<nsqs; j++) {
140  next=((bestsquare-subtract)+j) & 7;
141  x = m_Location_x+x_add[next];
142  y = m_Location_y+y_add[next];
143  food[j]=ForageSquare(x,y);
144  TotalFood+=food[j];
145  a_time -= __SQRS;
147  }
148  // Choose the best
149  int found=0;
150  //bestsquare=0;
151  for (int j=1; j<nsqs; j++) {
152  if (food[j]>food[found]) found=j;
153  else if (food[j]==food[found]) {
154  if (g_random_fnc(3)==0) {
155  found=j;
156  }
157  }
158  }
159  bestsquare=((bestsquare-subtract)+found) & 7;
161  {
162  bestsquare=(GetPegDirection());
163  // Our normal directions are 0-7 N,NE,E,SE,S,SW,W,NW
164  }
165  //
166  Walking(10,bestsquare);
167  if (TotalFood>m_EnergyMax) {
168  return m_EnergyMax;
169  }
170  }
171  if (TotalFood > m_EnergyMax)
172  {
173  TotalFood = m_EnergyMax;
174  }
175  return TotalFood;
176 }

References __SQRS, activity_Foraging, cfg_hare_pegmoveto_chance, EnergyBalance(), ForageSquare(), g_random_fnc(), GetPegDirection(), GetPegPull(), m_EnergyMax, TAnimal::m_Location_x, TAnimal::m_Location_y, CfgInt::value(), and Walking().

Referenced by Hare_Young::st_Foraging(), Hare_Juvenile::st_Foraging(), Hare_Male::st_Foraging(), and Hare_Female::st_Foraging().

◆ ForageP()

double THare::ForageP ( int &  time)
protected

Foraging but also incorporating pesticide exposure.

This could be implemented in each hare's st_Foraging, but is implemented as a common method because all the hares do it the same way. This method determine how much energy can be foraged from the current location in the time available (a_time).
It is important that energy used for foraging is deducted from the energybudget calculations before calculating the target - otherwise growth will be affected.
Efficiency can be roughly calculated for optimal forage by calculating the number squares and the cost of foraging together with the return. e.g. 100m2 -> 10m2 forage with ext of 5.0 = 50KJ at a cost of 100*m_KJForaging. Hence return can be calculated and the target adjusted accordingly
The only difference between this method and THare::Forage is that this one calls the version of ForageSquare that also calculates pesticide exposure.

m_EnergyMax is the max amount of energy possible in one day. This needs to be no more than they ever need, the closer to this limit the faster the code will run due to avoiding unnecessary searching, but also will prevent high energy usage being offset by too high intake. m_EnergyMax is set at the beginnng of each day in BeginStep.

180 {
192  #define __SQRS 100 // __SQRS is the number of m2 foraged per forage square
193  int y_add[8] = { -10, -10, 0, 10, 10, 10, 0, -10 }; // N,NE,E,SE,S,SW,W,NW
194  int x_add[8] = { 0, 10, 10, 10, 0, -10, -10, -10 }; // N,NE,E,SE,S,SW,W,NW
195  unsigned next = 0;
196  double food[8];
197  double pesticide[8];
198  int bestsquare = 0;
206  // Get the top corner of our square
207  int x = m_Location_x;
208  int y = m_Location_y;
209  // Search central square
210  double PesticideExposure = 0.0;
211  double TotalFood = ForageSquareP(x, y, &PesticideExposure); // this calls walking automatically
212  a_time -= __SQRS;
213  EnergyBalance(activity_Foraging, __SQRS * 5); // Assume a 20cm swath, therefore distance = 5 * m2
214  if ((a_time - __SQRS)<0)
215  {
216  m_pesticide_burden += PesticideExposure;
217  return TotalFood;
218  }
219  // Set up searching for the next 8 squares around this one
220  food[0] = 0;
221  int equal = 0;
222  double best = -1;
223  double tempP;
224  for (int i = 0; i<8; i++)
225  {
226  x = m_Location_x + x_add[i];
227  y = m_Location_y + y_add[i];
228  tempP = 0.0;
229  food[i] = ForageSquareP(x, y, &tempP);
230  pesticide[i] = tempP;
231  if (food[i]>best) {
232  best = food[i];
233  equal = 0;
234  bestsquare = i;
235  }
236  else if (food[i] >= best)
237  {
238  equal++;
239  }
240  }
241  if (equal>0)
242  {
243  // No real direction to move in, so go towards our peg if this is OK
244  unsigned pd = (GetPegDirection());
245  // Our normal directions are 0-7 N,NE,E,SE,S,SW,W,NW //
246  if (food[pd] >= best) bestsquare = pd;
247  else {
248  pd = (pd - 1) & 0x07;
249  if (food[pd] >= best) bestsquare = pd;
250  else {
251  // First check the directions
252  bestsquare = -1;
253  while (bestsquare == -1)
254  {
255  int t = g_random_fnc(8);
256  if (food[t] >= best) bestsquare = t;
257  }
258  }
259  }
260  }
261  // Now move to the next square, also the best in food return
262  Walking(10, bestsquare);
263  a_time -= __SQRS;
265  TotalFood += food[bestsquare];
266  PesticideExposure += pesticide[bestsquare];
267  if (TotalFood >= m_EnergyMax)
268  {
269  m_pesticide_burden += PesticideExposure;
270  return TotalFood;
271  }
272  // OK now dependent upon the direction bestsquare, we need to check 3 or 5 new squares for food
273  while (a_time>0)
274  {
275  int nsqs;
276  int subtract = 1 + (bestsquare & 1);
277  if (subtract == 1) nsqs = 3; else nsqs = 5;
278  for (int j = 0; j<nsqs; j++) {
279  next = ((bestsquare - subtract) + j) & 7;
280  x = m_Location_x + x_add[next];
281  y = m_Location_y + y_add[next];
282  food[j] = ForageSquareP(x, y, &PesticideExposure);
283  TotalFood += food[j];
284  a_time -= __SQRS;
286  }
287  // Choose the best
288  int found = 0;
289  //bestsquare=0;
290  for (int j = 1; j<nsqs; j++) {
291  if (food[j]>food[found]) found = j;
292  else if (food[j] == food[found]) {
293  if (g_random_fnc(3) == 0) {
294  found = j;
295  }
296  }
297  }
298  bestsquare = ((bestsquare - subtract) + found) & 7;
300  {
301  bestsquare = (GetPegDirection());
302  // Our normal directions are 0-7 N,NE,E,SE,S,SW,W,NW
303  }
304  //
305  Walking(10, bestsquare);
306  if (TotalFood>m_EnergyMax) {
307  m_pesticide_burden += PesticideExposure;
308  return TotalFood;
309  }
310  }
311  if (TotalFood > m_EnergyMax)
312  {
313  TotalFood = m_EnergyMax;
314  }
315  m_pesticide_burden += PesticideExposure;
316  return TotalFood;
317 }

References __SQRS, activity_Foraging, cfg_hare_pegmoveto_chance, EnergyBalance(), ForageSquareP(), g_random_fnc(), GetPegDirection(), GetPegPull(), m_EnergyMax, TAnimal::m_Location_x, TAnimal::m_Location_y, m_pesticide_burden, CfgInt::value(), and Walking().

Referenced by Hare_Young::st_Foraging(), Hare_Juvenile::st_Foraging(), Hare_Male::st_Foraging(), and Hare_Female::st_Foraging().

◆ ForageSquare()

double THare::ForageSquare ( int  a_x,
int  a_y 
)
protected

Forage from an area.

321 {
322  int polyref;
323  double food=0.0;
326  // Do the search and return the value
327  // Now we need the irritating boundary check
328  if ((a_x >= sw-10) || (a_y > sh-10) || (a_x < 0 ) || (a_y < 0))
329  {
330  // We check __FSQRS% of the cell and assume that the hare can find forage matching the best square
331  for (int i=0; i<__FSQRS; i++)
332  {
333  // Here is the boundary check
334  int x = (sw+a_x+g_random_fnc(10)) % sw;
335  int y = (sh+a_y+g_random_fnc(10)) % sh;
336  // All OK now, so get the polygon information and food
337  polyref=m_OurLandscape->SupplyPolyRef(x,y);
338  double f=m_OurPopulationManager->GetPolyFood(polyref);
339  if (f < 0.0)
340  {
342  // if we are a field do this
343  if (toc != toc_None) f = m_OurLandscape->GetHareFoodQuality(polyref) * m_vegPalatability[toc];
344  else f = m_OurLandscape->GetHareFoodQuality(polyref); // not a field
346  }
347  food+=f; //Changed foraging methods - now find the best sample cell and assume the whole square is this good - allows focus in foraging
348  //if (f > food) food = f;
349 
350  }
351  } else
352  {
353  for (int i=0; i<__FSQRS; i++)
354  {
355  int x = a_x+g_random_fnc(10);
356  int y = a_y+g_random_fnc(10);
357  polyref=m_OurLandscape->SupplyPolyRef(x,y);
358  double f=m_OurPopulationManager->GetPolyFood(polyref);
359  if (f < 0.0)
360  {
362  // if we are a field do this
363  if (toc != toc_None) f = m_OurLandscape->GetHareFoodQuality(polyref) * m_vegPalatability[toc];
364  else f = m_OurLandscape->GetHareFoodQuality(polyref); // not a field
365  }
366  food+=f; //Changed foraging methods - now find the best sample cell and assume the whole square is this good - allows focus in foraging
367  //if (f > food) food = f;
368  }
369  }
370  return food * 10 * cfg_hare_ExtEff.value(); // Assume they eat from all 100 m2 at this rate
371 }

References __FSQRS, cfg_hare_ExtEff, g_random_fnc(), Landscape::GetHareFoodQuality(), THare_Population_Manager::GetPolyFood(), TAnimal::m_OurLandscape, m_OurPopulationManager, m_vegPalatability, THare_Population_Manager::SetPolyFood(), Landscape::SupplyCropType(), Landscape::SupplyPolyRef(), Landscape::SupplySimAreaHeight(), Landscape::SupplySimAreaWidth(), toc_None, and CfgFloat::value().

Referenced by Forage().

◆ ForageSquareP()

double THare::ForageSquareP ( int  a_x,
int  a_y,
double *  a_pestexposure 
)
protected

Forage from an area and resturn pesticide exposure as well as food.

376 {
377  int polyref;
378  double somepesticide = 0.0;
379  double food = 0.0;
382  // Do the search and return the value
383  // Now we need the irritating boundary check
384  if ((a_x >= sw - 10) || (a_y > sh - 10) || (a_x < 0) || (a_y < 0))
385  {
386  // We check __FSQRS% of the cell and assume that the hare can find forage matching the best square
387  for (int i = 0; i<__FSQRS; i++)
388  {
389  // Here is the boundary check
390  int x = (sw + a_x + g_random_fnc(10)) % sw;
391  int y = (sh + a_y + g_random_fnc(10)) % sh;
392  // All OK now, so get the polygon information and food
393  polyref = m_OurLandscape->SupplyPolyRef(x, y);
394  somepesticide += m_OurLandscape->SupplyPesticideP(x, y, ppp_1);
395  double f = m_OurPopulationManager->GetPolyFood(polyref);
396  if (f < 0.0)
397  {
399  // if we are a field do this
400  if (toc != toc_None) f = m_OurLandscape->GetHareFoodQuality(polyref) * m_vegPalatability[toc];
401  else f = m_OurLandscape->GetHareFoodQuality(polyref); // not a field
402  }
403  food += f; //Changed foraging methods - now find the best sample cell and assume the whole square is this good - allows focus in foraging
404  }
405  }
406  else
407  {
408  for (int i = 0; i<__FSQRS; i++)
409  {
410  int x = a_x + g_random_fnc(10);
411  int y = a_y + g_random_fnc(10);
412  polyref = m_OurLandscape->SupplyPolyRef(x, y);
413  somepesticide += m_OurLandscape->SupplyPesticideP(x, y, ppp_1);
414  double f = m_OurPopulationManager->GetPolyFood(polyref); // returns -1 if not already set
415  if (f < 0.0)
416  {
418  // if we are a field do this
419  if (toc != toc_None) f = m_OurLandscape->GetHareFoodQuality(polyref) * m_vegPalatability[toc];
420  else f = m_OurLandscape->GetHareFoodQuality(polyref); // not a field
421  }
422  food += f;
423  }
424  }
425  // somepesticide now has the pesticide exposure in units per 10m2, but we need 100m and there are two routes with different rates of intake, so first X10
426  somepesticide *= 10;
427  // contact exposure
428  (*a_pesticideexposure) += somepesticide * cfg_hare_pesticide_contact_exposure_rate.value();
429  // ingestion exposure
430  (*a_pesticideexposure) += somepesticide * cfg_hare_pesticide_ingestion_exposure_rate.value();
431  return food * 10 * cfg_hare_ExtEff.value(); // Assume they eat from all 100 m2 at this rate
432 }

References __FSQRS, cfg_hare_ExtEff, cfg_hare_pesticide_contact_exposure_rate, cfg_hare_pesticide_ingestion_exposure_rate, g_random_fnc(), Landscape::GetHareFoodQuality(), THare_Population_Manager::GetPolyFood(), TAnimal::m_OurLandscape, m_OurPopulationManager, m_vegPalatability, ppp_1, Landscape::SupplyCropType(), Landscape::SupplyPesticideP(), Landscape::SupplyPolyRef(), Landscape::SupplySimAreaHeight(), Landscape::SupplySimAreaWidth(), toc_None, and CfgFloat::value().

Referenced by ForageP().

◆ GeneralEndocrineDisruptor()

virtual void THare::GeneralEndocrineDisruptor ( double  )
inlineprotectedvirtual

Handles internal effects of endocrine distrupter pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes.

Reimplemented in Hare_Male, and Hare_Female.

480  {
481  }

◆ GeneralOrganoPhosphate()

virtual void THare::GeneralOrganoPhosphate ( double  )
inlineprotectedvirtual

Handles internal effects of organophosphate pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes.

Reimplemented in Hare_Male, and Hare_Female.

486  {
487  }

◆ GetAge()

int THare::GetAge ( )
inline

Provide the age of the hare.

375 { return m_Age; }

References m_Age.

Referenced by THare_Population_Manager::DoFirst(), and Hare_Female::DoLactation().

◆ GetMum()

Hare_Female* THare::GetMum ( )
inline

Get the mother pointer.

402 { return m_MyMum; }

References m_MyMum.

Referenced by Hare_Female::SanityCheckYoungList().

◆ GetPegDirection()

int THare::GetPegDirection ( )
inlineprotected

Get direction of peg.

Daily movement is limited by a peg which does not really want to move, but can be dragged slowly. This requires a set of rapid functions because they will be used a lot. NB dispersal takes no account of the peg.
Figures out the closest direction to peg.
1 NE, 3 SE, 5 SWest & 7 NW
only uses 4 returns because this is very fast and relatively simple - 8 directions would be quite difficult to implement fast
This is also complicated by the fact that the peg can be at the other end of the world due to wrap around.

468 {
476  int d1 = m_Location_x - m_peg_x;
477  int d2 = m_Location_y - m_peg_y;
478  if ((d1 == 0) && (d2 == 0)) return g_random_fnc(8);
479  if (abs(d1) > (int)m_OurPopulationManager->SupplySimWH())
480  {
481  if (d1<0)
482  {
483  if ( abs(d2) > (int) m_OurPopulationManager->SupplySimHH())
484  {
485  if (d2<0) return 7; //NW;
486  else return 5; //SW;
487  }
488  else
489  {
490  if (d2<0) return 5; //SW;
491  else return 7; //NW;
492  }
493  }
494  else
495  {
496  if ( abs(d2) > (int) m_OurPopulationManager->SupplySimHH())
497  {
498  if (d2<0) return 1; //NE;
499  else return 3; //SE;
500  }
501  else {
502  if (d2<0) return 3; //SE;
503  else return 1; //NE;
504  }
505  }
506  }
507  else
508  {
509  if (d1<0)
510  {
511  if ( abs(d2) > (int) m_OurPopulationManager->SupplySimHH())
512  {
513  if (d2<0) return 1; //NE;
514  else return 3; //SE;
515  }
516  else {
517  if (d2<0) return 3; //SE;
518  else return 1; //NE;
519  }
520  }
521  else {
522  if ( abs(d2) > (int) m_OurPopulationManager->SupplySimHH()) {
523  if (d2<0) return 7; //NW;
524  else return 5; //SW;
525  }
526  else {
527  if (d2<0) return 5; //SW;
528  else return 7; //NW;
529  }
530  }
531  }
532 }

References g_random_fnc(), TAnimal::m_Location_x, TAnimal::m_Location_y, m_OurPopulationManager, m_peg_x, m_peg_y, Population_Manager_Base::SupplySimHH(), and Population_Manager_Base::SupplySimWH().

Referenced by Forage(), and ForageP().

◆ GetPegDistance()

int THare::GetPegDistance ( )
inlineprotected

Get peg distance.

Daily movement is limited by a peg which does not really want to move, but can be dragged slowly. This requires a set of rapid functions because they will be used a lot. NB dispersal takes no account of the peg.
Calculates the distance from our current x,y to the peg We must avoid sqrt and the like so our distance is in rectangular co-ordinates. This is complicated by the fact that the peg and hare may be on opposite sides of the world due to wrap around.

443 {
451  int d1=abs(m_Location_x-m_peg_x);
452  if (d1 > (int) m_OurPopulationManager->SupplySimWH()) d1 = abs(d1-m_OurPopulationManager->SupplySimW());
453  int d2=abs(m_Location_y-m_peg_y);
454  if (d2 > (int) m_OurPopulationManager->SupplySimWH()) d2 = abs(d2-m_OurPopulationManager->SupplySimH());
455  return d1+d2;
456 }

References TAnimal::m_Location_x, TAnimal::m_Location_y, m_OurPopulationManager, m_peg_x, m_peg_y, Population_Manager_Base::SupplySimH(), Population_Manager_Base::SupplySimW(), and Population_Manager_Base::SupplySimWH().

Referenced by GetPegPull().

◆ GetPegPull()

int THare::GetPegPull ( )
inlineprotected

Get attractive force of peg.

Returns the squared rectangular distance from the peg

459 {
463  int d = GetPegDistance();
464  return d*d;
465 }

References GetPegDistance().

Referenced by Forage(), and ForageP().

◆ GetRefNum()

int THare::GetRefNum ( )
inline

Get the refnum for this hare.

417 { return m_RefNum; }

References m_RefNum.

◆ GetRMR()

double THare::GetRMR ( )

◆ GetTotalWeight()

double THare::GetTotalWeight ( )
inline

Provide the wet weight of the hare.

Uses a standard multiplier of 3.8 to convert dry to wet weight, then adds the fat (no water here).

370 { return m_weight * 3.8 + m_fatReserve; }

References m_fatReserve, and m_weight.

Referenced by EnergyBalance(), GetRMR(), Hare_Infant::st_Developing(), and Hare_Young::st_Foraging().

◆ GetWeight()

double THare::GetWeight ( )
inline

Provide the weight of the hare.

362 { return m_weight; }

References m_weight.

◆ InternalPesticideHandlingAndResponse()

void THare::InternalPesticideHandlingAndResponse ( )
protectedvirtual

Handles internal effects of pesticide exposure. If any effects are needed this method must be re-implemented by descendent classes.

This method needs to be re-implemented for any class which has pesticide response behaviour. e.g. see Hare_Female::InternalPesticideHandlingAndResponse

Reimplemented in Hare_Female, and Hare_Male.

560  {
564  m_pesticide_burden *= m_pesticidedegradationrate; // Does nothing by default except internal degredation of the pesticide
565  }

References m_pesticide_burden, and m_pesticidedegradationrate.

Referenced by Hare_Young::EndStep(), and Hare_Juvenile::EndStep().

◆ loadVegPalatability()

void THare::loadVegPalatability ( void  )

Loads static member m_vegPalatability with data.

115 {
116  m_vegPalatability = new double[ toc_Foobar ];
117 
119 }

References hare_tov_SetVegPalatability(), m_vegPalatability, and toc_Foobar.

◆ MovePeg()

void THare::MovePeg ( )
protected

Move the peg according to attraction forces.

Daily movement is limited by a peg which does not really want to move, but can be dragged slowly. This requires a set of rapid functions because they will be used a lot. NB dispersal takes no account of the peg.
Moves the peg towards the location, the speed of movement is dependent upon an inertia parameter.
Once again we have the problem of wrap around.

536 {
542  //
543  // Find the distance between the peg & x,y and add a fixed proportion to move peg
544  int d1=(m_Location_x-m_peg_x);
545  if (abs(d1)< (int) m_OurPopulationManager->SupplySimWH()) m_peg_x += int(d1*g_hare_peg_inertia); // Global used for speed
546  else {
548  m_peg_x += int(d1*g_hare_peg_inertia);
549  }
550  d1=(m_Location_y-m_peg_y);
551  if (abs(d1)< (int) m_OurPopulationManager->SupplySimHH()) m_peg_y += int(d1*g_hare_peg_inertia);
552  else {
554  m_peg_y += int(d1*g_hare_peg_inertia);
555  }
556  }

References g_hare_peg_inertia, TAnimal::m_Location_x, TAnimal::m_Location_y, m_OurPopulationManager, m_peg_x, m_peg_y, Population_Manager_Base::SupplySimHH(), and Population_Manager_Base::SupplySimWH().

Referenced by EndStep(), Hare_Infant::EndStep(), Hare_Young::EndStep(), Hare_Juvenile::EndStep(), Hare_Male::EndStep(), and Hare_Female::EndStep().

◆ ON_Dead()

virtual void THare::ON_Dead ( void  )
inlinevirtual

Mortality - overridden in descendent classes.

Reimplemented in Hare_Female, Hare_Male, Hare_Juvenile, Hare_Young, and Hare_Infant.

422  {
423  }

◆ ON_MumDead()

void THare::ON_MumDead ( Hare_Female a_Mum)
inline

Inform Mum that we are dead.

Really a Hare_Infant method. Implemented here because it is needed only for debug.

383  {
384  if (a_Mum != m_MyMum)
385  {
386  m_OurLandscape->Warn("Hare_Infant::On_MumDead - not my mum!!", "");
387  exit(1);
388  }
389  // I am now an orphan
390  m_MyMum = nullptr;
391  }

References m_MyMum, TAnimal::m_OurLandscape, and Landscape::Warn().

◆ OnFarmEvent()

bool THare::OnFarmEvent ( FarmToDo  event)
overrideprotectedvirtual

Do we require a response to a farm event.

Checks to see if any nasty farm event has caused any behaviour. Few do directly, most work by changes in vegetation or forage, but if they do they can be added here

Reimplemented from TAnimal.

Reimplemented in Hare_Young, and Hare_Infant.

361 {
362  if (event != sleep_all_day)
363  {
365  return true; // This will ensure that the next event checked is sensible.
366  }
367 }

References cfg_hare_escape_dist, Running(), sleep_all_day, and CfgInt::value().

◆ Run()

bool THare::Run ( int  a_dist,
int  a_direction 
)
protected

Run a distance in a direction.

187 {
188  // Need to move a_dist in direction a_direction
189  int Width=m_OurPopulationManager->SupplySimW();
190  int Height=m_OurPopulationManager->SupplySimH();
191  int tx=m_Location_x;
192  int ty=m_Location_y;
193  switch(a_direction)
194  {
195  case 0: // North
196  ty=m_Location_y-a_dist;
197  if (ty<0) ty+=Height;
198  break;
199  case 1: // NorthWest
200  // OK, OK I know, I should reduce the distance for the diagonal - but it
201  // costs two multiplications if I do, and this is used a lot
202  ty=m_Location_y-a_dist;
203  tx=m_Location_x+a_dist;
204  if (ty<0) ty+=Height;
205  if (tx>=Width) tx-=Width;
206  break;
207  case 2: // West
208  tx=m_Location_x+a_dist;
209  if (tx>=Width) tx-=Width;
210  break;
211  case 3: // SouthWest
212  ty=m_Location_y+a_dist;
213  tx=m_Location_x+a_dist;
214  if (tx>=Width) tx-=Width;
215  if (ty>=Height) ty-=Height;
216  break;
217  case 4: // South
218  ty=m_Location_y+a_dist;
219  if (ty>=Height) ty-=Height;
220  break;
221  case 5: // SouthEast
222  ty=m_Location_y+a_dist;
223  tx=m_Location_x-a_dist;
224  if (tx<0) tx+=Width;
225  if (ty>=Height) ty-=Height;
226  break;
227  case 6: // East
228  tx=m_Location_x-a_dist;
229  if (tx<0) tx+=Width;
230  break;
231  case 7: // NorthEast
232  ty=m_Location_y-a_dist;
233  tx=m_Location_x-a_dist;
234  if (tx<0) tx+=Width;
235  if (ty<0) ty+=Height;
236  break;
237  default: // No direction
238  break;
239 
240  }
241  // Now just before we do anything, check that we can go to tx,ty
243  {
244  m_Location_x = tx;
245  m_Location_y = ty;
246  //check the guard map for the new location
248  return true;
249  }
250  else
251  {
252  return false;
253  }
254 
255  // I know I can save code by only testing for boundary conditions
256  // at the end, but 50% of the time this will involve an unnecessary test and
257  // speed usually being the problem I think it is better this way
258 }

References hare_tole_can_walkacross(), TAnimal::m_guard_cell_x, TAnimal::m_guard_cell_y, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, m_OurPopulationManager, Population_Manager_Base::SupplySimH(), Population_Manager_Base::SupplySimW(), and Population_Manager::UpdateGuardMap().

Referenced by Running(), and Walking().

◆ Running()

void THare::Running ( int  a_max_dist)
protectedvirtual

Run.

Moves the hare and alters the energy and time budget to simulate running /n All proximity alerts or other causes of running for all hares are sent via this code - the code then calls a movement code and energetic code. However these are may not the same for all hare types, so if there is a specific routine for a type, that is called, if not the default is used - there is no need to worry about this as the calling program.

137 {
138  int dist;
139  bool b;
140  //remove it from the density map at current location
142 
143  // The length of this loop can cause problems, hence in very small landscapes max_dist has to be small. A minimum distance was not used because this invites infinite looping.
144  do {
145  // Choose a distance......
146  dist=a_max_dist;
147  // and see if it is possible to go there in a random direction
148  b=Run(a_max_dist++, g_random_fnc(8));
149  } while (b==false);
150 
152  //add it to the density map at new location
154 
155 
156  // Now adjust our energy balance
160 }

References activity_Recovery, activity_Running, THare_Population_Manager::AddHareDensity(), cfg_Hare_Recovery_Time, EnergyBalance(), g_random_fnc(), TAnimal::m_guard_cell_x, TAnimal::m_guard_cell_y, TAnimal::m_Location_x, TAnimal::m_Location_y, m_OurPopulationManager, m_Type, Run(), THare_Population_Manager::SubtractHareDensity(), TimeBudget(), Population_Manager::UpdateGuardMap(), and CfgInt::value().

Referenced by Hare_Young::BeginStep(), Hare_Juvenile::BeginStep(), Hare_Male::BeginStep(), Hare_Female::BeginStep(), and OnFarmEvent().

◆ SetMum()

static void THare::SetMum ( Hare_Female )
inlinestatic

Set the mother pointer. Reimplemented in Hare_Infant.

396  {
397  }

Referenced by THare_Population_Manager::CreateObjects().

◆ st_Dispersal()

TTypeOfHareState THare::st_Dispersal ( void  )
virtual

Base implementation only - reimplemented.

This function is really a dummy - but it needs to be here.
The return values is meaningless, but stops the compiler complaining

Reimplemented in Hare_Female, Hare_Juvenile, and Hare_Young.

123 {
128  return tohs_InitialState;
129 }

References tohs_InitialState.

◆ st_Dying()

void THare::st_Dying ( void  )
protected

Tidy up before removing the object on death.

Do the housekeeping necessary to die

165  {
166  if (m_MyMum) m_MyMum->ON_YoungKilled(this);
168  m_CurrentStateNo=-1;
169  m_MyMum=NULL;
170  m_StepDone=true;
171 }

References m_CurrentHState, TALMaSSObject::m_CurrentStateNo, m_MyMum, TALMaSSObject::m_StepDone, Hare_Female::ON_YoungKilled(), and tohs_DestroyObject.

Referenced by Hare_Infant::ON_Dead(), and Hare_Young::ON_Dead().

◆ Step()

void THare::Step ( void  )
inlineoverridevirtual

Base implementation only - reimplemented.

Reimplemented from TALMaSSObject.

Reimplemented in Hare_Female, Hare_Male, Hare_Juvenile, Hare_Young, and Hare_Infant.

350  {
351  }

◆ THareInit()

void THare::THareInit ( int  p_x,
int  p_y,
THare_Population_Manager p_PPM 
)

Object Initiation.

71 {
72  // The THare constructor - only needs to know about the Hare Population
73  // Manager
76  // Set the lifespan
78  // Energetic values - these can be overwritten by the constructor of
79  // descendent classes
80  m_KJRunning=0;
81  m_KJWalking=0;
82  m_KJForaging=0;
85  m_fatReserve=0;
88  //m_in_dispersal = false;
89  //m_TimePerForageSquare= 13 * 13; // 24 squares
90  m_ActivityTime=1440; // In the case of object creation, this cannot be set in the begin step
91  m_foragingenergy=0.001; // a bit more than 0
92  m_peg_x=p_x;
93  m_peg_y=p_y;
96  for (int i=0; i<365; i++) m_expDensity[i]=0;
97  m_DensitySum=0;
98  m_ddindex=0;
99  m_RefNum=p_PPM->GetHareRefNum();
100  m_pesticideInfluenced1 = false;
101  m_pesticide_burden = 0.0;
102  m_pesticidedegradationrate = cfg_hare_pesticidedegradationrate.value(); // default of 0.0 will remove all body burden pesticide at the end of each day
103 }

References cfg_hare_max_age, cfg_hare_max_age_var, cfg_hare_pesticidedegradationrate, cfg_Hare_StdSpeedRunning, cfg_Hare_StdSpeedWalking, g_random_fnc(), THare_Population_Manager::GetHareRefNum(), m_ActivityTime, m_CurrentHState, m_ddindex, m_DensitySum, m_expDensity, m_experiencedDensity, m_fatReserve, m_foragingenergy, m_KJForaging, m_KJRunning, m_KJWalking, m_lastYearsDensity, m_Lifespan, m_OurPopulationManager, m_peg_x, m_peg_y, m_pesticide_burden, m_pesticidedegradationrate, m_pesticideInfluenced1, m_RefNum, m_SpeedRunning, m_SpeedWalking, m_StarvationDays, m_TodaysEnergy, tohs_InitialState, CfgInt::value(), and CfgFloat::value().

Referenced by Hare_Infant::ReInit(), Hare_Young::ReInit(), Hare_Juvenile::ReInit(), Hare_Male::ReInit(), Hare_Female::ReInit(), and THare().

◆ TimeBudget()

void THare::TimeBudget ( TTypeOfActivity  a_activity,
int  dist 
)
protected

Adjust time budger for an activity.

This method calculates time used for each activity and subtracts this from the day

299 {
303  switch (a_activity)
304  {
305  case activity_Resting:
306  m_ActivityTime-=dist; // dist is in time here (minutes)
307  break;
308  case activity_Running:
309  m_ActivityTime-=(int)(dist/m_SpeedRunning); // dist in metres
310  break;
311  case activity_Walking:
312  m_ActivityTime-=(int)(dist/m_SpeedWalking); // dist in metres
313  break;
314  case activity_Foraging:
315  m_ActivityTime-=dist; // dist in minutes
316  break;
317  case activity_Dispersal:
318  m_ActivityTime -= (int)(dist / m_SpeedWalking); // dist in metres
319  break;
320  case activity_Recovery:
321  m_ActivityTime-=dist; // dist in minutes
322  break;
323  default:
324  m_OurLandscape->Warn("THare::TimeBudget - unknown activity",NULL);
325  exit(1);
326  }
327 }

References activity_Dispersal, activity_Foraging, activity_Recovery, activity_Resting, activity_Running, activity_Walking, m_ActivityTime, TAnimal::m_OurLandscape, m_SpeedRunning, m_SpeedWalking, and Landscape::Warn().

Referenced by Running(), Hare_Juvenile::st_Dispersal(), Hare_Young::st_Foraging(), Hare_Juvenile::st_Foraging(), Hare_Male::st_Foraging(), Hare_Female::st_Foraging(), Hare_Young::st_Resting(), and Hare_Juvenile::st_Resting().

◆ Walking()

void THare::Walking ( int  a_dist,
int  a_direction 
)
protected

Walking.

Moves the hare and alters the energy budget to simulate walking.

177 {
178  while (!Run(a_dist, a_direction)) {
179  a_direction=g_random_fnc(8);
180  //a_dist=random(500); // This is just for cases like Illum� where it is possible to travel too far in all directions
181  a_dist--; // This is because hares can get stuck otherwise.
182  }
183 }

References g_random_fnc(), and Run().

Referenced by Forage(), ForageP(), and Hare_Juvenile::st_Dispersal().

◆ WasPredated()

bool THare::WasPredated ( )
virtual

Test for predation.

A mortality test. Also include optional code for size and low fat reserve increased mortality - tested under the POM

Reimplemented in Hare_Juvenile.

341  {
342  // This is only called by adult states, so don't call it from any other hare class
343 #ifdef __SIZERELATEDDEATH2
345 #endif
346 #ifdef __LOWFATRELATEDDEATH
347  if (m_Age>365) if (m_fatReserve<1.0) {
348  test= (int)(cfg_hare_lowfatextramort.value() * test); // Increase the chance of dying if fat reserves drop to low levels
349  }
350 #endif
352  return false;
353 }

References cfg_hare_lowfatextramort, cfg_hare_minimum_breeding_weight, g_rand_uni_fnc(), THare_Population_Manager::m_AdultMortRate, m_Age, m_fatReserve, m_OurPopulationManager, m_weight, CfgInt::value(), and CfgFloat::value().

Member Data Documentation

◆ m_ActivityTime

◆ m_Age

◆ m_CurrentHState

◆ m_ddindex

int THare::m_ddindex = 0
protected

State variable used in alternative density-dependent configurations.

Referenced by Hare_Juvenile::BeginStep(), Hare_Male::BeginStep(), Hare_Female::BeginStep(), and THareInit().

◆ m_DensitySum

int THare::m_DensitySum = 0
protected

State variable used in alternative density-dependent configurations.

Referenced by Hare_Juvenile::BeginStep(), Hare_Male::BeginStep(), Hare_Female::BeginStep(), and THareInit().

◆ m_EnergyMax

double THare::m_EnergyMax = 0.0
protected

State variable - the amount of energy it is possible to eat as a multiplyer or RMR.

Referenced by Hare_Young::BeginStep(), Hare_Juvenile::BeginStep(), Hare_Male::BeginStep(), Hare_Female::BeginStep(), Forage(), and ForageP().

◆ m_expDensity

int THare::m_expDensity[365] = {}
protected

State variable used in alternative density-dependent configurations.

Referenced by Hare_Juvenile::BeginStep(), Hare_Male::BeginStep(), Hare_Female::BeginStep(), and THareInit().

◆ m_experiencedDensity

int THare::m_experiencedDensity = 0
protected

State variable used in alternative density-dependent configurations.

Referenced by Hare_Male::BeginStep(), Hare_Female::BeginStep(), and THareInit().

◆ m_fatReserve

◆ m_foragingenergy

double THare::m_foragingenergy = 0.0
protected

Energy obtained from foraging/feeding.

Referenced by Hare_Male::BeginStep(), Hare_Female::BeginStep(), Hare_Female::dumpEnergy(), EnergyBalance(), and THareInit().

◆ m_IamSick

bool THare::m_IamSick = false
protected

flag for sickness - used in conjunction with disease configurations

Referenced by Hare_Male::BeginStep(), Hare_Female::BeginStep(), Hare_Female::Init(), and Hare_Female::UpdateOestrous().

◆ m_KJForaging

double THare::m_KJForaging = 0.0
protected

◆ m_KJRunning

double THare::m_KJRunning = 0.0
protected

◆ m_KJWalking

double THare::m_KJWalking = 0.0
protected

◆ m_lastYearsDensity

int THare::m_lastYearsDensity = 0
protected

State variable used in alternative density-dependent configurations.

Referenced by Hare_Juvenile::BeginStep(), Hare_Male::BeginStep(), Hare_Female::BeginStep(), Hare_Male::st_Foraging(), Hare_Female::st_Foraging(), and THareInit().

◆ m_Lifespan

int THare::m_Lifespan = 0
protected

Physiolocal lifespan, assuming nothing else kills the hare (unlikely to reach this age)

Referenced by Hare_Male::BeginStep(), Hare_Female::BeginStep(), and THareInit().

◆ m_MyMum

Hare_Female* THare::m_MyMum = nullptr
protected

◆ m_old_weight

◆ m_OurPopulationManager

◆ m_peg_x

int THare::m_peg_x = 0
protected

◆ m_peg_y

int THare::m_peg_y = 0
protected

◆ m_pesticide_burden

double THare::m_pesticide_burden = 0.0
protected

◆ m_pesticidedegradationrate

double THare::m_pesticidedegradationrate = 0.0
protected

State variable used to hold the daily degredation rate of the pesticide in the body.

Referenced by InternalPesticideHandlingAndResponse(), Hare_Male::InternalPesticideHandlingAndResponse(), Hare_Female::InternalPesticideHandlingAndResponse(), and THareInit().

◆ m_pesticideInfluenced1

bool THare::m_pesticideInfluenced1 = false
protected

Flag to indicate pesticide effects (e.g. can be used for endocrine distruptors with delayed effects until birth).

Referenced by Hare_Female::GeneralEndocrineDisruptor(), Hare_Female::GiveBirth(), and THareInit().

◆ m_RefNum

int THare::m_RefNum = 0
protected

Unique hare reference number, also functions as sex flag.

Referenced by GetRefNum(), Hare_Male::Init(), Hare_Female::Init(), Hare_Juvenile::st_NextStage(), and THareInit().

◆ m_SpeedRunning

double THare::m_SpeedRunning = 0.0
protected

m/min speed of running per kg hare

Referenced by THareInit(), and TimeBudget().

◆ m_SpeedWalking

double THare::m_SpeedWalking = 0.0
protected

m/min speed of walking per kg hare

Referenced by THareInit(), and TimeBudget().

◆ m_StarvationDays

int THare::m_StarvationDays = 0
protected

State variable - the number of consecutive days in negative energy balance.

Referenced by Hare_Infant::st_Developing(), Hare_Young::st_Developing(), Hare_Juvenile::st_Developing(), Hare_Male::st_Developing(), Hare_Female::st_Developing(), and THareInit().

◆ m_TodaysEnergy

◆ m_Type

◆ m_vegPalatability

double * THare::m_vegPalatability = nullptr
static

Will hold and array of palatability for hare for each tov type. Most are 1, but unpalatable vegetation can be specified here.

Referenced by ForageSquare(), ForageSquareP(), loadVegPalatability(), Hare_Juvenile::st_Dispersal(), and THare_Population_Manager::~THare_Population_Manager().

◆ m_weight


The documentation for this class was generated from the following files:
Population_Manager_Base::SupplySimHH
int SupplySimHH() const
Returns half the landscape height in m.
Definition: PopulationManager.h:573
toc_None
Definition: LandscapeFarmingEnums.h:925
THare_Population_Manager::SetPolyFood
void SetPolyFood(int a_poly, double a_value)
Set polygon food quality.
Definition: Hare_All.h:725
THare::m_vegPalatability
static double * m_vegPalatability
Will hold and array of palatability for hare for each tov type. Most are 1, but unpalatable vegetatio...
Definition: Hare_All.h:318
g_rand_uni_fnc
double g_rand_uni_fnc()
Definition: ALMaSS_Random.cpp:56
activity_Walking
Definition: Hare_All.h:93
THare::GetPegDirection
int GetPegDirection()
Get direction of peg.
Definition: HareForagenPeg.cpp:467
Population_Manager_Base::SupplySimH
int SupplySimH() const
Returns landscape height in m.
Definition: PopulationManager.h:569
THare::m_pesticidedegradationrate
double m_pesticidedegradationrate
State variable used to hold the daily degredation rate of the pesticide in the body.
Definition: Hare_All.h:306
THare::m_SpeedWalking
double m_SpeedWalking
m/min speed of walking per kg hare
Definition: Hare_All.h:248
THare::m_EnergyMax
double m_EnergyMax
State variable - the amount of energy it is possible to eat as a multiplyer or RMR.
Definition: Hare_All.h:223
TAnimal::m_guard_cell_y
int m_guard_cell_y
The index y to the guard cell.
Definition: PopulationManager.h:374
THare::m_Lifespan
int m_Lifespan
Physiolocal lifespan, assuming nothing else kills the hare (unlikely to reach this age)
Definition: Hare_All.h:198
THare_Population_Manager::m_AdultMortRate
double m_AdultMortRate
Input variable - Adult mortality rate.
Definition: Hare_All.h:741
__SQRS
#define __SQRS
CfgFloat::value
double value() const
Definition: Configurator.h:142
cfg_hare_ExtEff
CfgFloat cfg_hare_ExtEff
tohs_InitialState
Definition: Hare_All.h:72
THare_Population_Manager::GetHareRefNum
int GetHareRefNum()
Get the next ID number available.
Definition: Hare_All.h:546
THare::m_ActivityTime
int m_ActivityTime
Minutes of potential activity time per day.
Definition: Hare_All.h:203
THare_Population_Manager::AddHareDensity
void AddHareDensity(int x, int y, Hare_Object a_type)
Density function - adds one to the density in the square containing by x,y. Each square is 256x256m i...
Definition: Hare_All.h:642
Hare_Female::ON_YoungKilled
void ON_YoungKilled(THare *a_young)
A leveret has been killed.
Definition: Hare_All.cpp:3538
THare::ForageSquare
double ForageSquare(int a_x, int a_y)
Forage from an area.
Definition: HareForagenPeg.cpp:320
THare::m_OurPopulationManager
THare_Population_Manager * m_OurPopulationManager
Pointer to the hare population manager.
Definition: Hare_All.h:194
cfg_hare_escape_dist
CfgInt cfg_hare_escape_dist
cfg_hare_max_age_var
CfgInt cfg_hare_max_age_var
THare::m_KJForaging
double m_KJForaging
KJ/m cost of foraging per kg hare.
Definition: Hare_All.h:238
activity_Dispersal
Definition: Hare_All.h:94
Population_Manager_Base::SupplySimWH
int SupplySimWH() const
Returns half the landscape width in m.
Definition: PopulationManager.h:571
THare::THareInit
void THareInit(int p_x, int p_y, THare_Population_Manager *p_PPM)
Object Initiation.
Definition: Hare_THare.cpp:70
THare::GetPegDistance
int GetPegDistance()
Get peg distance.
Definition: HareForagenPeg.cpp:442
cfg_hare_pesticide_ingestion_exposure_rate
CfgFloat cfg_hare_pesticide_ingestion_exposure_rate("HARE_PESTICIDE_INGESTION_RATE", CFG_CUSTOM, 0.0)
TAnimal::TAnimal
TAnimal(int x, int y, Landscape *L)
The TAnimal constructor saving the x,y, location and the landscape pointer.
Definition: PopulationManager.cpp:1553
__FSQRS
#define __FSQRS
Definition: HareForagenPeg.cpp:46
THare::m_KJWalking
double m_KJWalking
KJ/m cost of walking per kg hare.
Definition: Hare_All.h:233
THare::m_fatReserve
double m_fatReserve
State variable - the energy reserve of the hare.
Definition: Hare_All.h:213
THare::m_lastYearsDensity
int m_lastYearsDensity
State variable used in alternative density-dependent configurations.
Definition: Hare_All.h:276
tohs_DestroyObject
Definition: Hare_All.h:81
THare::m_experiencedDensity
int m_experiencedDensity
State variable used in alternative density-dependent configurations.
Definition: Hare_All.h:271
THare::m_KJRunning
double m_KJRunning
KJ/m cost of running per kg hare.
Definition: Hare_All.h:228
Landscape::SupplySimAreaHeight
int SupplySimAreaHeight(void)
Gets the simulation landscape height.
Definition: Landscape.h:2302
Landscape::SupplySimAreaWidth
int SupplySimAreaWidth(void)
Gets the simulation landscape width.
Definition: Landscape.h:2297
TAnimal::m_Location_y
int m_Location_y
The objects ALMaSS y coordinate.
Definition: PopulationManager.h:366
THare::m_RefNum
int m_RefNum
Unique hare reference number, also functions as sex flag.
Definition: Hare_All.h:265
THare::m_pesticideInfluenced1
bool m_pesticideInfluenced1
Flag to indicate pesticide effects (e.g. can be used for endocrine distruptors with delayed effects u...
Definition: Hare_All.h:311
TAnimal::m_OurLandscape
static Landscape * m_OurLandscape
A pointer to the landscape object shared with all TAnimal objects.
Definition: PopulationManager.h:342
THare::Walking
void Walking(int a_dist, int a_direction)
Walking.
Definition: Hare_THare.cpp:176
hare_tole_can_walkacross
bool hare_tole_can_walkacross(Landscape *m_TheLandscape, int x, int y)
Definition: Hare_toletov.cpp:41
activity_Foraging
Definition: Hare_All.h:92
THare::MovePeg
void MovePeg()
Move the peg according to attraction forces.
Definition: HareForagenPeg.cpp:535
THare_Population_Manager::GetRMR
double GetRMR(int a_age, double a_size)
Returns the RMR given a specific age and mass.
Definition: Hare_All.cpp:932
THare::m_SpeedRunning
double m_SpeedRunning
m/min speed of running per kg hare
Definition: Hare_All.h:243
cfg_hare_pesticide_contact_exposure_rate
CfgFloat cfg_hare_pesticide_contact_exposure_rate("HARE_PESTICIDE_CONTACT_RATE", CFG_CUSTOM, 0.0)
cfg_hare_lowfatextramort
static CfgFloat cfg_hare_lowfatextramort("HARE_LOWFATEXTRAMORT", CFG_CUSTOM, 10.0)
THare::m_ddindex
int m_ddindex
State variable used in alternative density-dependent configurations.
Definition: Hare_All.h:281
THare::m_TodaysEnergy
double m_TodaysEnergy
State variable - the amount of energy available today, can be in deficit.
Definition: Hare_All.h:218
cfg_Hare_Recovery_Time
CfgInt cfg_Hare_Recovery_Time
TALMaSSObject::m_StepDone
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: PopulationManager.h:133
THare::EnergyBalance
void EnergyBalance(TTypeOfActivity a_activity, int dist)
Adjust energy balance for an activity.
Definition: Hare_THare.cpp:261
hare_tov_SetVegPalatability
void hare_tov_SetVegPalatability(double *vp)
Definition: Hare_toletov.cpp:61
THare::m_foragingenergy
double m_foragingenergy
Energy obtained from foraging/feeding.
Definition: Hare_All.h:252
CfgInt::value
int value() const
Definition: Configurator.h:116
Population_Manager::UpdateGuardMap
void UpdateGuardMap(int a_x, int a_y, int &a_index_x, int &a_index_y)
Get the index of the guard map for the given location.
Definition: PopulationManager.h:768
THare::m_expDensity
int m_expDensity[365]
State variable used in alternative density-dependent configurations.
Definition: Hare_All.h:286
THare::m_DensitySum
int m_DensitySum
State variable used in alternative density-dependent configurations.
Definition: Hare_All.h:291
TTypesOfCrops
TTypesOfCrops
Definition: LandscapeFarmingEnums.h:781
THare::ForageSquareP
double ForageSquareP(int a_x, int a_y, double *a_pestexposure)
Forage from an area and resturn pesticide exposure as well as food.
Definition: HareForagenPeg.cpp:375
THare::m_pesticide_burden
double m_pesticide_burden
State variable used to hold the current body-burden of pesticide.
Definition: Hare_All.h:301
THare::m_Age
int m_Age
State variale - hare age.
Definition: Hare_All.h:170
Landscape::SupplyPesticideP
double SupplyPesticideP(int a_x, int a_y, PlantProtectionProducts a_ppp)
Gets plant pesticide for a location.
Definition: Landscape.cpp:1420
cfg_hare_minimum_breeding_weight
CfgInt cfg_hare_minimum_breeding_weight
THare::m_CurrentHState
TTypeOfHareState m_CurrentHState
Defines the current activity.
Definition: Hare_All.h:165
cfg_hare_pesticidedegradationrate
static CfgFloat cfg_hare_pesticidedegradationrate("HARE_PESTICIDEDEGRADATIONRATE", CFG_CUSTOM, 0.0)
THare_Population_Manager::GetPolyFood
double GetPolyFood(int a_poly)
Get stored polygon food quality.
Definition: Hare_All.h:720
TAnimal::m_guard_cell_x
int m_guard_cell_x
The index x to the guard cell.
Definition: PopulationManager.h:370
THare::m_StarvationDays
int m_StarvationDays
State variable - the number of consecutive days in negative energy balance.
Definition: Hare_All.h:208
activity_Recovery
Definition: Hare_All.h:95
Population_Manager_Base::SupplySimW
int SupplySimW() const
Returns landscape width in m.
Definition: PopulationManager.h:567
activity_Running
Definition: Hare_All.h:91
cfg_hare_max_age
CfgInt cfg_hare_max_age
THare::GetTotalWeight
double GetTotalWeight()
Provide the wet weight of the hare.
Definition: Hare_All.h:370
THare::Running
virtual void Running(int a_max_dist)
Run.
Definition: Hare_THare.cpp:136
THare::GetPegPull
int GetPegPull()
Get attractive force of peg.
Definition: HareForagenPeg.cpp:458
THare::m_MyMum
Hare_Female * m_MyMum
Pointer to the hare's mum.
Definition: Hare_All.h:190
g_random_fnc
int g_random_fnc(const int a_range)
Definition: ALMaSS_Random.cpp:74
THare::m_peg_y
int m_peg_y
peg y-coordinate
Definition: Hare_All.h:260
cfg_Hare_StdSpeedWalking
CfgFloat cfg_Hare_StdSpeedWalking
THare::m_weight
double m_weight
State variale - hare weight g.
Definition: Hare_All.h:180
THare::m_Type
Hare_Object m_Type
State variale - the type of hare.
Definition: Hare_All.h:175
THare::Run
bool Run(int a_dist, int a_direction)
Run a distance in a direction.
Definition: Hare_THare.cpp:186
TALMaSSObject::m_CurrentStateNo
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: PopulationManager.h:131
THare_Population_Manager::SubtractHareDensity
void SubtractHareDensity(int x, int y, Hare_Object a_type)
Density function - subtracts one from the density in the square containing by x,y....
Definition: Hare_All.h:649
toc_Foobar
Definition: LandscapeFarmingEnums.h:926
THare::TimeBudget
void TimeBudget(TTypeOfActivity a_activity, int dist)
Adjust time budger for an activity.
Definition: Hare_THare.cpp:298
Landscape::Warn
void Warn(std::string a_msg1, std::string a_msg2)
Wrapper for the g_msg Warn function.
Definition: Landscape.h:2250
Landscape::SupplyCropType
TTypesOfCrops SupplyCropType(int a_x, int a_y)
Returns the crop type of the polygon using the polygon reference number a_polyref or coordinates a_x,...
Definition: Landscape.h:1931
TAnimal::m_Location_x
int m_Location_x
The objects ALMaSS x coordinate.
Definition: PopulationManager.h:362
Landscape::SupplyPolyRef
int SupplyPolyRef(int a_x, int a_y)
Get the in map polygon reference number from the x, y location.
Definition: Landscape.h:2157
ppp_1
Definition: LandscapeFarmingEnums.h:1079
cfg_Hare_StdSpeedRunning
CfgFloat cfg_Hare_StdSpeedRunning
THare::m_peg_x
int m_peg_x
peg x-coordinate
Definition: Hare_All.h:256
g_hare_peg_inertia
double g_hare_peg_inertia
Definition: Hare_All.cpp:48
cfg_hare_pegmoveto_chance
CfgInt cfg_hare_pegmoveto_chance("HARE_PEGMOVETOCHANCE", CFG_CUSTOM, 5000)
Landscape::GetHareFoodQuality
double GetHareFoodQuality(int a_polygon)
Returns the hare food quality of polygons LKM.
Definition: Landscape.cpp:5472
activity_Resting
Definition: Hare_All.h:90
sleep_all_day
Definition: Treatment.h:33