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
Hare_Juvenile Class Reference

Class for juvenile hares (after 5 weeks old, fully mobile) More...

#include <Hare_All.h>

Inheritance diagram for Hare_Juvenile:
THare TAnimal TALMaSSObject Hare_Female Hare_Male

Public Member Functions

void BeginStep (void) override
 BeginStep for Hare_Juvenile. More...
 
void Step (void) override
 Step for Hare_Juvenile. More...
 
void EndStep (void) override
 BeginStep for Hare_Juvenile. More...
 
 Hare_Juvenile (int p_x, int p_y, Landscape *p_L, THare_Population_Manager *p_PPM, double p_weight)
 Constructor for the juvenile hare object. More...
 
void ReInit (struct_Hare a_data)
 Juvenile object reinitiation. More...
 
void Init (double p_weight)
 Object initiation. More...
 
 ~Hare_Juvenile () override
 Destructor for the juvenile hare object. More...
 
void ON_Dead () override
 
- Public Member Functions inherited from THare
 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...
 
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...
 
int GetRefNum ()
 Get the refnum for this hare. 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...
 

Protected Member Functions

virtual TTypeOfHareState st_Developing ()
 The development code for Hare_Juvenile. More...
 
TTypeOfHareState st_Dispersal () override
 Juvenile Dispersal. More...
 
TTypeOfHareState st_Foraging ()
 Juvenile foraging. More...
 
void st_NextStage ()
 Maturation to Hare_Male or Hare_Female. More...
 
TTypeOfHareState st_Resting ()
 Juvenile Resting. More...
 
bool ShouldMature ()
 Test for maturation. More...
 
bool WasPredated () override
 Test for mortality. More...
 
- Protected Member Functions inherited from THare
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...
 

Additional Inherited Members

- Static Public Member Functions inherited from THare
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 inherited from THare
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 Attributes inherited from THare
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...
 
- 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

Class for juvenile hares (after 5 weeks old, fully mobile)

Constructor & Destructor Documentation

◆ Hare_Juvenile()

Hare_Juvenile::Hare_Juvenile ( int  p_x,
int  p_y,
Landscape p_L,
THare_Population_Manager p_PPM,
double  p_weight 
)

Constructor for the juvenile hare object.

1973  : THare(p_x, p_y, p_L, p_PPM) { Init(p_weight); }

References Init().

◆ ~Hare_Juvenile()

Hare_Juvenile::~Hare_Juvenile ( )
override

Destructor for the juvenile hare object.

1994  {
1995  //Nothing to do
1996 }

Member Function Documentation

◆ BeginStep()

void Hare_Juvenile::BeginStep ( void  )
overridevirtual

BeginStep for Hare_Juvenile.

Resets the day's activity counter and checks for default mortalities and potentially extra mortalities. Calculates energy usage for movement based on todays weight

Reimplemented from THare.

Reimplemented in Hare_Female, and Hare_Male.

2007  {
2008  if (m_CurrentStateNo == -1) return;
2009  m_ActivityTime = 1440; // Start the day
2010  m_old_weight = m_weight - 1; // we are not interested in tiny fluctuations
2011  m_KJWalking = m_OurPopulationManager->GetKJperM(static_cast<int>(m_weight));
2012  m_KJRunning = m_KJWalking * 2;
2014 
2015 #ifdef __DDEPMORT
2017 #ifdef __THRESHOLD_DD
2018  if (dens<m_OurPopulationManager->m_HareThresholdDD) dens=0;
2020 #endif
2021  double inter=m_OurPopulationManager->GetInterference(dens);
2022  if (g_rand_uni() > inter) {
2023  ON_Dead();
2024  m_StepDone=true; // We need to skip the step code, we are dead
2025  return;
2026  }
2027 #endif
2028 
2030  {
2031  ON_Dead();
2032  m_StepDone = true; // We need to skip the step code, we are dead
2033  return;
2034  }
2035 
2037 #ifdef __DISEASEDDM3
2038  m_ddindex++;
2039  if (m_ddindex==365) {
2040  m_ddindex=0;
2041  }
2045  m_lastYearsDensity= int(m_DensitySum * (1.0/365.0));
2046 #endif
2047  // Set the maximum possible energy intake
2049  CheckManagement();
2050 }

References cfg_hare_escape_dist, cfg_hare_proximity_alert, cfg_MaxEnergyIntakeScaler, TAnimal::CheckManagement(), g_rand_uni_fnc(), THare_Population_Manager::GetInterference(), THare_Population_Manager::GetKJperM(), THare::GetRMR(), THare_Population_Manager::GetTotalDensity(), THare::m_ActivityTime, TALMaSSObject::m_CurrentStateNo, THare::m_ddindex, THare::m_DensitySum, THare::m_EnergyMax, THare::m_expDensity, THare_Population_Manager::m_HareThresholdDD, THare_Population_Manager::m_JuvMortRate, THare::m_KJForaging, THare::m_KJRunning, THare::m_KJWalking, THare::m_lastYearsDensity, TAnimal::m_Location_x, TAnimal::m_Location_y, THare::m_old_weight, THare::m_OurPopulationManager, TALMaSSObject::m_StepDone, THare::m_weight, ON_Dead(), THare::Running(), CfgInt::value(), and CfgFloat::value().

◆ EndStep()

void Hare_Juvenile::EndStep ( void  )
overridevirtual

BeginStep for Hare_Juvenile.

Just moves the homerange centre peg closer to where the hare has been active today

Reimplemented from THare.

Reimplemented in Hare_Female, and Hare_Male.

References cfg_hare_pesticideresponse_on, THare::InternalPesticideHandlingAndResponse(), THare::MovePeg(), and CfgBool::value().

◆ Init()

void Hare_Juvenile::Init ( double  p_weight)

Object initiation.

1984  {
1985  m_Type = hob_Juvenile;
1986  m_weight = p_weight;
1987  m_Age = 35; // By definition we are 35 days old today
1988 }

References hob_Juvenile, THare::m_Age, THare::m_Type, and THare::m_weight.

Referenced by Hare_Juvenile(), and ReInit().

◆ ON_Dead()

void Hare_Juvenile::ON_Dead ( void  )
overridevirtual

Do the housekeeping necessary for removal of the object - in this case minimal.

Reimplemented from THare.

Reimplemented in Hare_Female, and Hare_Male.

2389  {
2391  m_CurrentStateNo = -1;
2392  m_StepDone = true;
2393 }

References THare::m_CurrentHState, TALMaSSObject::m_CurrentStateNo, TALMaSSObject::m_StepDone, and tohs_DestroyObject.

Referenced by BeginStep(), and Step().

◆ ReInit()

void Hare_Juvenile::ReInit ( struct_Hare  a_data)

Juvenile object reinitiation.

1974  {
1975  m_Location_x = a_data.x;
1976  m_Location_y = a_data.y;
1977  m_OurLandscape = a_data.L;
1978  m_CurrentStateNo = 0;
1979  THareInit(a_data.x, a_data.y, a_data.HM);
1980  Init(a_data.weight);
1981 }

References struct_Hare::HM, Init(), struct_Hare::L, TALMaSSObject::m_CurrentStateNo, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, THare::THareInit(), struct_Hare::weight, struct_Hare::x, and struct_Hare::y.

◆ ShouldMature()

bool Hare_Juvenile::ShouldMature ( )
protected

Test for maturation.

This method will be used to determine whether the hare becomes sexually active - and therefore needs to become an adult hare.

2366  {
2371  if (++m_Age < 180) return false;
2372  // Do not do it below six months
2373  // If 6mths old and it is before October, then can mature
2374  if (m_OurLandscape->SupplyDayInYear() < 270) return true;
2375  if (m_Age > 364) return true;
2376  return true;
2377 }

References THare::m_Age, TAnimal::m_OurLandscape, and Landscape::SupplyDayInYear().

Referenced by st_Developing().

◆ st_Developing()

TTypeOfHareState Hare_Juvenile::st_Developing ( )
protectedvirtual

The development code for Hare_Juvenile.

Tests for the onset of maturation. Also tests for minimum growth attainment if this is switched on - too low growth results in death.

Assumes that the fatReserve has been added to by st_Foraging from yesterday.
This is the last behaviour state called each day, so we can use this to sort out the energetics.

Reimplemented in Hare_Female, and Hare_Male.

2266  {
2267  // Test for the onset of reproductive activity
2268  // This should be done now because otherwise it is possible to skip this test and get too old
2269  if (ShouldMature()) { return tohs_NextStage; }
2270 #ifdef __MINGROWTHATTAIN
2271  // Take a check on our growth - if we are below X% of the min repro weight, assume we died
2272  //if (m_weight < (cfg_hare_minimum_breeding_weight.value()*cfg_min_growth_attain.value())) return tohs_Dying;
2273  if (m_weight < m_OurPopulationManager->m_DMWeight[m_Age]) { return tohs_Dying; }
2274 #endif
2275 
2282  if (m_TodaysEnergy < Target) Target = m_TodaysEnergy;
2283  double addedtoday = Target * m_OurPopulationManager->GetGrowthEfficiencyP(m_Age);
2284  m_weight += addedtoday;
2285  m_TodaysEnergy -= Target;
2287  if (m_TodaysEnergy < Target) Target = m_TodaysEnergy;
2288  addedtoday = Target * m_OurPopulationManager->GetGrowthEfficiencyF(m_Age);
2289  m_weight += addedtoday;
2290  m_TodaysEnergy -= Target;
2291  if (m_weight < 0) { return tohs_Dying; }
2292  if (m_TodaysEnergy > 0)
2293  {
2294  // Put what remains back into fat reserve
2296  // 366 is the fat conversion efficiency
2297  m_TodaysEnergy = 0;
2298  // Cap the fat reserve and store surplus energy for today
2300  m_StarvationDays = 0; // Not starving
2301  return tohs_Foraging;
2302  }
2304  // 366 is the fat conversion efficiency
2305  if (m_fatReserve < 0)
2306  {
2308  m_fatReserve = 0.0;
2309  }
2310  else m_TodaysEnergy = 0;
2311  // What should the criteria for a starvation day be? Here chosen to be any negative energy balance.
2312  // Have also considered and rejected a proportion of rmr:
2313  //double rmr=m_OurPopulationManager->GetRMR(m_Age, GetTotalWeight());
2314  // if (m_TodaysEnergy<(0.0-(rmr*0.25)))
2315  if (m_TodaysEnergy < 0.0)
2316  {
2317 #ifndef __NOJUVSTARVE
2318  // Oh oh, we are starving need to lose body weight and maybe we will die?
2319 #ifdef __ADULT_WT_STARVE_CHANCE
2321  {
2322  if (g_rand_uni_fnc() * 10000 > cfg_juv_starve.value()) { return tohs_Dying; }
2323  }
2324 #else
2326  return tohs_Dying;
2327  }
2328 #endif
2329 #endif
2330  }
2331  else
2332  {
2333  m_StarvationDays--; // Not starving
2334  if (m_StarvationDays < 0) m_StarvationDays = 0;
2335  m_TodaysEnergy = 0;
2336  }
2337  return tohs_Foraging;
2338 }

References cfg_AdultMaxFat, cfg_juv_starve, cfg_juvenile_starvation_threshold, g_rand_uni_fnc(), THare_Population_Manager::GetGrowthEfficiencyF(), THare_Population_Manager::GetGrowthEfficiencyP(), THare_Population_Manager::GetMaxDailyGrowthEnergyF(), THare_Population_Manager::GetMaxDailyGrowthEnergyP(), THare::m_Age, THare::m_fatReserve, THare::m_OurPopulationManager, THare::m_StarvationDays, THare::m_TodaysEnergy, THare::m_weight, ShouldMature(), tohs_Dying, tohs_Foraging, tohs_NextStage, CfgInt::value(), and CfgFloat::value().

Referenced by Step().

◆ st_Dispersal()

TTypeOfHareState Hare_Juvenile::st_Dispersal ( void  )
overrideprotectedvirtual

Juvenile Dispersal.

Makes a test of habitat quality (basically food) in 8 directions, then moves to the best one. This is basically a teleport move, so testing for barriers is not done. This will need to be added if it becomes a problem (e.g. hares appearing on islands they could not otherwise get too), however, this will also confer an extreme performance penalty!

Reimplemented from THare.

Reimplemented in Hare_Female.

2185  {
2186 #ifdef __DISPMORTALITY
2187  if (WasPredated()) return tohs_Dying;
2188 #endif
2189  // Now to make this a little more clever we need to test all 8 directions
2190  int tx = m_Location_x;
2191  int ty = m_Location_y;
2192  int ttx = tx;
2193  int tty = ty;
2194  double oldfv = -99999999.0;
2195  int dstart = g_random_fnc(8);
2196  int d2 = 0;
2197  for (int j = 0; j < 100; j++)
2198  {
2199  int dist = 100 + g_random_fnc(cfg_hare_max_dispersal.value());
2200  for (int d = dstart; d < 8 + dstart; d++)
2201  {
2202  // We need to avoid a bias movement now too
2203  int d1 = d & 7; // 0-7
2204  Walking(dist, d1); // This modifies m_Location_x, m_Location_y
2205  // How much food here?
2208  double fv;
2209  // if we are a field do this
2210  if (toc != toc_None) fv = m_OurLandscape->GetHareFoodQuality(polyref) * m_vegPalatability[toc];
2211  else fv = m_OurLandscape->GetHareFoodQuality(polyref); // not a field
2213  if (oldfv <= fv)
2214  {
2215  oldfv = fv;
2216  ttx = m_Location_x;
2217  tty = m_Location_y;
2218  d2 = dist;
2219  // The best we can ever get is 0.8 so we can speed things up by dropping out if we are close to this.
2220  if (fv >= 0.75)
2221  {
2222  j = 101;
2223  break;
2224  }
2225  }
2226  // Set the xy back before trying the next direction
2227  m_Location_x = tx;
2228  m_Location_y = ty;
2229  }
2230  }
2231  // Now do it for real
2232  // We need to update the density maps temporarily to stop all the animals responding to old data until the beginning of the next timestep
2234  m_Location_x = ttx;
2235  m_Location_y = tty;
2236  //check the guard map for the new location
2238  //add it to the density map at new location
2240  d2 *= 5; // Lets assume it is not a beeline, and 5x distance is needed to find the place.
2243  // Move the peg with us.
2244  //m_peg_x = m_Location_x; /** Testing whether the peg will be dragged anyway if we don't set this 31/7/2014 */
2245  //m_peg_y = m_Location_y;
2246  return tohs_Foraging;
2247 }

References activity_Dispersal, THare_Population_Manager::AddHareDensity(), cfg_hare_max_dispersal, THare::EnergyBalance(), g_random_fnc(), THare_Population_Manager::GetAdultDensity(), Landscape::GetHareFoodQuality(), THare_Population_Manager::GetInterference(), TAnimal::m_guard_cell_x, TAnimal::m_guard_cell_y, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, THare::m_OurPopulationManager, THare::m_Type, THare::m_vegPalatability, THare_Population_Manager::SubtractHareDensity(), Landscape::SupplyCropType(), Landscape::SupplyPolyRef(), THare::TimeBudget(), toc_None, tohs_Dying, tohs_Foraging, Population_Manager::UpdateGuardMap(), CfgInt::value(), THare::Walking(), and WasPredated().

Referenced by Hare_Female::st_Dispersal(), Step(), and Hare_Male::Step().

◆ st_Foraging()

TTypeOfHareState Hare_Juvenile::st_Foraging ( )
protected

Juvenile foraging.

Given the time we have then we need to feed, which will return an energy value obtained.

2127  {
2131  double atime = m_ActivityTime * cfg_ForageRestingRatio.value();
2132  // We need to rest if there is no more time
2133  if (atime < 30) return tohs_Resting;
2134  // This version uses adult density for interference, other densities seem not to work so well
2135  //int hares=(m_OurPopulationManager->GetAdultDensity(m_Location_x, m_Location_y));
2136  //int hares=(m_OurPopulationManager->GetTotalDensity(m_Location_x, m_Location_y));
2137  int hares = 1;
2138 #ifdef __THRESHOLD_AD_DD
2139  if (hares<m_OurPopulationManager->m_HareThresholdDD) {
2140  hares=0;
2141  } else {
2143  }
2144 #endif
2145 #ifdef __THRESHOLD_DDJ
2146 // this section has been altered so many times it was not worth making it general - if it is used in release versions this can be implemented when we know how it should look - right now remember to change in code before compile-
2147  if (hares<6) hares=0;
2148  else hares*=hares;
2149 #endif
2150 
2151 #ifdef __SCALINGYOUNGDDM
2152  hares = (int) floor (0.5+(double)hares*cfg_JuvDDScale.value());
2153 #endif
2154 
2155  //interfer is between 1.0 and 0
2156  //double slope = 1.0+(cfg_AgeRelatedInterferenceScaling.value() * (1.0-(double(m_Age/365.0))));
2157  //double hs=hares*slope;
2158 #ifndef __DDEPMORT
2159  double inter = m_OurPopulationManager->GetInterference(hares);
2160 #else
2161  double inter=1.0;
2162 #endif
2163  if (inter < 0.5 && atime > 300)
2164  {
2165  if (g_rand_uni_fnc() > inter) // added to reduce rate of dispersal
2166  {
2167  //m_ActivityTime = (int)(atime / cfg_ForageRestingRatio.value());
2168  return tohs_Dispersal; // Added Sat 15th Dec 2007
2169  }
2170  }
2171  atime *= inter;
2172  int a_time = static_cast<int>(atime);
2174  else { m_TodaysEnergy = Forage(a_time); }
2175  // We need to spend energy on foraging and associated movement
2176  //
2177  TimeBudget(activity_Foraging, static_cast<int>(atime) - a_time);
2178  return tohs_Resting;
2179 }

References activity_Foraging, cfg_ForageRestingRatio, cfg_hare_pesticideresponse_on, cfg_JuvDDScale, THare::Forage(), THare::ForageP(), g_rand_uni_fnc(), THare_Population_Manager::GetInterference(), THare::m_ActivityTime, THare_Population_Manager::m_HareThresholdDD, THare::m_OurPopulationManager, THare::m_TodaysEnergy, THare::TimeBudget(), tohs_Dispersal, tohs_Resting, CfgFloat::value(), and CfgBool::value().

Referenced by Step().

◆ st_NextStage()

void Hare_Juvenile::st_NextStage ( )
protected

Maturation to Hare_Male or Hare_Female.

This creates a Hare_Juvenile object via a call to create objects, then sets the flag for destruction of this object.

2345  {
2346  auto sp = new struct_Hare;
2347  sp->HM = m_OurPopulationManager;
2348  sp->L = m_OurLandscape;
2349  sp->x = m_Location_x;
2350  sp->y = m_Location_y;
2351  sp->weight = m_weight;
2352  sp->Mum = nullptr;
2353  sp->age = m_Age;
2354  sp->RefNum = m_RefNum;
2355  // Sex ratio is set to be 50:50 at birth
2356  if ((m_RefNum & 0x01) == 0) // Male
2357  m_OurPopulationManager->CreateObjects(3, this, nullptr, sp, 1);
2358  else m_OurPopulationManager->CreateObjects(4, this, nullptr, sp, 1);
2359  // Clean-up
2360  m_CurrentStateNo = -1; // Destroys the object at the next opportunity
2362  delete sp;
2363 }

References THare_Population_Manager::CreateObjects(), struct_Hare::HM, THare::m_Age, THare::m_CurrentHState, TALMaSSObject::m_CurrentStateNo, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, THare::m_OurPopulationManager, THare::m_RefNum, THare::m_weight, and tohs_DestroyObject.

Referenced by Step().

◆ st_Resting()

TTypeOfHareState Hare_Juvenile::st_Resting ( )
protected

Juvenile Resting.

The hare spends some time resting (using time and a little energy)

2252  {
2253  EnergyBalance(activity_Resting, 0); // Just removes a days BMR
2255  return tohs_Developing;
2256 }

References activity_Resting, THare::EnergyBalance(), THare::m_ActivityTime, THare::TimeBudget(), and tohs_Developing.

Referenced by Step().

◆ Step()

void Hare_Juvenile::Step ( void  )
overridevirtual

Step for Hare_Juvenile.

As with all other ALMaSS animal objects, Step is where the primary state/transtion work is done

Reimplemented from THare.

Reimplemented in Hare_Female, and Hare_Male.

2060  {
2061  if (m_StepDone || m_CurrentStateNo == -1) return;
2062  switch (m_CurrentHState)
2063  {
2064  case tohs_InitialState: // Initial state
2066  break;
2067  case tohs_Dispersal:
2068  // Dispersal is risky therefore take a test again
2069  // Legal returns are:
2070  // tohs_Foraging
2071 #ifdef __DISPERSALDDM
2072  if (g_rand_uni()<(cfg_hare_juvenile_predation.value())) {
2073  ON_Dead();
2074  m_StepDone=true; // We need to skip the step code, we are dead
2075  return;
2076  }
2077 #endif
2079  break;
2080  case tohs_Foraging:
2081  // Legal returns are:
2082  // tohs_JResting
2084  break;
2085  case tohs_Resting:
2086  // Legal returns are:
2087  // tohs_Developing
2089  break;
2090  case tohs_Developing:
2091  // Legal returns are:
2092  // tohs_Dispersal
2093  // tohs_NextStage
2094  // tohs_Resting
2096  if (m_CurrentHState == tohs_Foraging) m_StepDone = true;
2097  break;
2098  case tohs_NextStage:
2099  // Legal returns are:
2100  // NONE
2101  st_NextStage();
2102  m_StepDone = true;
2103  break;
2104  case tohs_Dying:
2105  ON_Dead();
2106  m_StepDone = true;
2107  break;
2108  default:
2109  m_OurLandscape->Warn("Hare_Juvenile::Step - unknown state", nullptr);
2110  exit(1);
2111  }
2112 }

References cfg_hare_juvenile_predation, THare::m_CurrentHState, TALMaSSObject::m_CurrentStateNo, TAnimal::m_OurLandscape, TALMaSSObject::m_StepDone, ON_Dead(), st_Developing(), st_Dispersal(), st_Foraging(), st_NextStage(), st_Resting(), tohs_Developing, tohs_Dispersal, tohs_Dying, tohs_Foraging, tohs_InitialState, tohs_NextStage, tohs_Resting, CfgFloat::value(), and Landscape::Warn().

◆ WasPredated()

bool Hare_Juvenile::WasPredated ( )
overrideprotectedvirtual

Test for mortality.

Reimplemented from THare.

2380  {
2381  if (g_rand_uni_fnc() < m_OurPopulationManager->m_JuvMortRate) return true;
2382  return false;
2383 }

References g_rand_uni_fnc(), THare_Population_Manager::m_JuvMortRate, and THare::m_OurPopulationManager.

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


The documentation for this class was generated from the following files:
toc_None
Definition: LandscapeFarmingEnums.h:925
tohs_Dying
Definition: Hare_All.h:80
struct_Hare::x
int x
Definition: Hare_All.h:138
THare_Population_Manager::CreateObjects
void CreateObjects(int ob_type, TAnimal *pvo, void *null, struct_Hare *data, int number)
Method used to create new hares.
Definition: Hare_All.cpp:873
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
cfg_juv_starve
CfgInt cfg_juv_starve("HARE_JUV_STARVE", CFG_CUSTOM, 2500)
struct_Hare::y
int y
Definition: Hare_All.h:139
cfg_hare_pesticideresponse_on
CfgBool cfg_hare_pesticideresponse_on("HARE_PESTICIDERESPONSE_ON", CFG_CUSTOM, false)
If set to true then hares will collect and respond to pesticide information. This will slow the simul...
Hare_Juvenile::ON_Dead
void ON_Dead() override
Definition: Hare_All.cpp:2389
THare_Population_Manager::GetKJperM
double GetKJperM(int a_size)
Get the cost of moving 1m in KJ dependent upon mass (.
Definition: Hare_All.h:628
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
Hare_Juvenile::WasPredated
bool WasPredated() override
Test for mortality.
Definition: Hare_All.cpp:2380
Hare_Juvenile::Init
void Init(double p_weight)
Object initiation.
Definition: Hare_All.cpp:1984
hob_Juvenile
Definition: Hare_All.h:61
cfg_MaxEnergyIntakeScaler
static CfgFloat cfg_MaxEnergyIntakeScaler("HARE_MAXENERGYINTAKESCALER", CFG_CUSTOM, 1.825)
cfg_hare_max_dispersal
static CfgInt cfg_hare_max_dispersal("HARE_MAX_DISPERSAL", CFG_CUSTOM, 1000)
CfgFloat::value
double value() const
Definition: Configurator.h:142
tohs_InitialState
Definition: Hare_All.h:72
THare::InternalPesticideHandlingAndResponse
virtual void InternalPesticideHandlingAndResponse()
Handles internal effects of pesticide exposure. If any effects are needed this method must be re-impl...
Definition: HareForagenPeg.cpp:559
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
THare::m_OurPopulationManager
THare_Population_Manager * m_OurPopulationManager
Pointer to the hare population manager.
Definition: Hare_All.h:194
struct_Hare::HM
THare_Population_Manager * HM
Definition: Hare_All.h:142
THare_Population_Manager::GetMaxDailyGrowthEnergyF
double GetMaxDailyGrowthEnergyF(int a_age)
Get the maximum daily energy needed for growth for this a_age for use in fat construction.
Definition: Hare_All.h:576
cfg_ForageRestingRatio
CfgFloat cfg_ForageRestingRatio("HARE_FORAGERESTRATIO", CFG_CUSTOM, 0.67)
THare::m_KJForaging
double m_KJForaging
KJ/m cost of foraging per kg hare.
Definition: Hare_All.h:238
Hare_Juvenile::ShouldMature
bool ShouldMature()
Test for maturation.
Definition: Hare_All.cpp:2366
THare_Population_Manager::m_HareThresholdDD
int m_HareThresholdDD
Input variable - Threshold density dependence level.
Definition: Hare_All.h:757
activity_Dispersal
Definition: Hare_All.h:94
THare::GetRMR
double GetRMR()
Get todays RMR.
Definition: Hare_THare.cpp:333
THare::Forage
double Forage(int &time)
Foraging.
Definition: HareForagenPeg.cpp:52
THare::THareInit
void THareInit(int p_x, int p_y, THare_Population_Manager *p_PPM)
Object Initiation.
Definition: Hare_THare.cpp:70
CfgBool::value
bool value() const
Definition: Configurator.h:164
cfg_hare_juvenile_predation
static CfgFloat cfg_hare_juvenile_predation("HARE_JUVENILE_PREDATION", CFG_CUSTOM, 0.0027)
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
Hare_Juvenile::st_NextStage
void st_NextStage()
Maturation to Hare_Male or Hare_Female.
Definition: Hare_All.cpp:2345
THare::m_lastYearsDensity
int m_lastYearsDensity
State variable used in alternative density-dependent configurations.
Definition: Hare_All.h:276
tohs_Dispersal
Definition: Hare_All.h:75
tohs_DestroyObject
Definition: Hare_All.h:81
THare::m_KJRunning
double m_KJRunning
KJ/m cost of running per kg hare.
Definition: Hare_All.h:228
TAnimal::m_Location_y
int m_Location_y
The objects ALMaSS y coordinate.
Definition: PopulationManager.h:366
cfg_juvenile_starvation_threshold
static CfgInt cfg_juvenile_starvation_threshold("HARE_JUVENILE_STARVE_THRESHOLD", CFG_CUSTOM, 8)
THare::m_RefNum
int m_RefNum
Unique hare reference number, also functions as sex flag.
Definition: Hare_All.h:265
TAnimal::m_OurLandscape
static Landscape * m_OurLandscape
A pointer to the landscape object shared with all TAnimal objects.
Definition: PopulationManager.h:342
TAnimal::CheckManagement
void CheckManagement()
Used to start a check for any management related effects at the objects current location.
Definition: PopulationManager.cpp:1591
THare::Walking
void Walking(int a_dist, int a_direction)
Walking.
Definition: Hare_THare.cpp:176
struct_Hare::L
Landscape * L
Definition: Hare_All.h:141
activity_Foraging
Definition: Hare_All.h:92
THare_Population_Manager::GetMaxDailyGrowthEnergyP
double GetMaxDailyGrowthEnergyP(int a_age)
Get the maximum daily energy needed for growth for this a_age for use in protein construction.
Definition: Hare_All.h:563
THare::MovePeg
void MovePeg()
Move the peg according to attraction forces.
Definition: HareForagenPeg.cpp:535
Hare_Juvenile::st_Resting
TTypeOfHareState st_Resting()
Juvenile Resting.
Definition: Hare_All.cpp:2252
THare_Population_Manager::GetGrowthEfficiencyF
double GetGrowthEfficiencyF(int a_age)
Get the growth efficiency for this a_age for creating fat.
Definition: Hare_All.h:615
cfg_hare_escape_dist
CfgInt cfg_hare_escape_dist("HARE_ESCAPE_DIST", CFG_CUSTOM, 100)
THare::m_old_weight
double m_old_weight
State variale - last hare weight.
Definition: Hare_All.h:185
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
Landscape::SupplyDayInYear
int SupplyDayInYear(void)
Passes a request on to the associated Calendar class function, the day in the year.
Definition: Landscape.h:2267
TALMaSSObject::m_StepDone
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: PopulationManager.h:133
Hare_Juvenile::st_Dispersal
TTypeOfHareState st_Dispersal() override
Juvenile Dispersal.
Definition: Hare_All.cpp:2185
THare::EnergyBalance
void EnergyBalance(TTypeOfActivity a_activity, int dist)
Adjust energy balance for an activity.
Definition: Hare_THare.cpp:261
tohs_NextStage
Definition: Hare_All.h:73
CfgInt::value
int value() const
Definition: Configurator.h:116
THare_Population_Manager::m_JuvMortRate
double m_JuvMortRate
Input variable - Juvenile mortality rate.
Definition: Hare_All.h:737
THare_Population_Manager::GetAdultDensity
int GetAdultDensity(int x, int y)
Density function - returns the density of adults in the square containing by x,y. Each square is 256x...
Definition: Hare_All.h:688
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::m_Age
int m_Age
State variale - hare age.
Definition: Hare_All.h:170
THare::ForageP
double ForageP(int &time)
Foraging but also incorporating pesticide exposure.
Definition: HareForagenPeg.cpp:179
tohs_Developing
Definition: Hare_All.h:74
THare::m_CurrentHState
TTypeOfHareState m_CurrentHState
Defines the current activity.
Definition: Hare_All.h:165
cfg_AdultMaxFat
static CfgFloat cfg_AdultMaxFat("HARE_ADULT_MAXFAT", CFG_CUSTOM, 0.04/(0.33 *0.88))
struct_Hare
Class used to pass hare information to CreateObjects.
Definition: Hare_All.h:136
THare_Population_Manager::GetInterference
double GetInterference(int h)
Return the proportion of time used in communicating with con-specifics.
Definition: Hare_All.h:707
THare::THare
THare(int p_x, int p_y, Landscape *p_L, THare_Population_Manager *p_PPM)
Constructor.
Definition: Hare_THare.cpp:64
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
THare::Running
virtual void Running(int a_max_dist)
Run.
Definition: Hare_THare.cpp:136
g_random_fnc
int g_random_fnc(const int a_range)
Definition: ALMaSS_Random.cpp:74
THare::m_weight
double m_weight
State variale - hare weight g.
Definition: Hare_All.h:180
Hare_Juvenile::st_Foraging
TTypeOfHareState st_Foraging()
Juvenile foraging.
Definition: Hare_All.cpp:2127
THare_Population_Manager::GetGrowthEfficiencyP
double GetGrowthEfficiencyP(int a_age)
Get the growth efficiency for this a_age for creating protein.
Definition: Hare_All.h:602
THare::m_Type
Hare_Object m_Type
State variale - the type of hare.
Definition: Hare_All.h:175
tohs_Resting
Definition: Hare_All.h:77
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
struct_Hare::weight
double weight
Definition: Hare_All.h:145
cfg_JuvDDScale
CfgFloat cfg_JuvDDScale("HARE_JUVSCALEDD", CFG_CUSTOM, 0.5)
Hare_Juvenile::st_Developing
virtual TTypeOfHareState st_Developing()
The development code for Hare_Juvenile.
Definition: Hare_All.cpp:2266
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
THare_Population_Manager::GetTotalDensity
int GetTotalDensity(int x, int y)
Density function - returns the density of all hares in the square containing by x,...
Definition: Hare_All.h:683
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
cfg_hare_proximity_alert
static CfgFloat cfg_hare_proximity_alert("HARE_PROXIMITY_ALERT", CFG_CUSTOM, 0.05)
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
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
tohs_Foraging
Definition: Hare_All.h:76