File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/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
TPredator Class Reference

The base class for predators encompsassing all their general behaviours. More...

#include <Predators.h>

Inheritance diagram for TPredator:
TAnimal TALMaSSObject Owl Weasel

Public Member Functions

 TPredator (Vole_Population_Manager *ThePrey, int p_x, int p_y, Landscape *p_L, TPredator_Population_Manager *p_PPM)
 
 ~TPredator ()
 
bool OverlapMyTerritory (unsigned x, unsigned y)
 
virtual void st_Dispersal ()
 
virtual void st_Movement ()
 
virtual int st_Hunting ()
 
virtual void BeginStep (void)
 BeingStep behaviour - must be implemented in descendent classes. More...
 
virtual void Step (void)
 Step behaviour - must be implemented in descendent classes. More...
 
virtual void EndStep (void)
 EndStep behaviour - must be implemented in descendent classes. More...
 
unsigned SupplySpeciesID ()
 
int SupplyKill ()
 
bool SupplyTerr ()
 
int SupplyKillEff ()
 
int SupplyHomeRange ()
 
- 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...
 
virtual bool OnFarmEvent (FarmToDo)
 Must be reimplemented if used in descendent classes. Sets the action on a management event. 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 Attributes

TTypeOfPredatorState CurrentPState
 
unsigned SpeciesID
 
unsigned m_DispersalMax
 
unsigned m_SearchArea
 
int m_kills_this_season
 
int PreyResponse1
 
int PreyResponse2
 
int m_Search_x
 
int m_Search_y
 
int SimW
 
int SimH
 
unsigned m_FailureCount
 
unsigned m_NoFailuresBeforeDispersal
 
unsigned m_HomeRange
 
bool m_HaveTerritory
 
int m_KillEfficiency
 
Vole_Population_Managerm_Prey
 
TPredator_Population_Managerm_OurPopulationManager
 
vector< Vole_Base * > * CurrentPrey
 
- 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 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...
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. 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

The base class for predators encompsassing all their general behaviours.

Defines simple predators that are really nothing more than moving mortality probabilities of different sizes and strengths. Breeding is once a year if enough prey are eaten, and death occurs if a starvation criteria is reached. The last individual cannot die so the population can never go extinct. If predators do not eat for a definable number of hunts then they may disperse, otherwise they move only locally. Different types of predators can be defined in the same simulation by defining the Weasel and Owl classes using configuration variables to create e.g. specialist or generalist predators, with different movement patterns, hunting efficiency and numerical responses.

Constructor & Destructor Documentation

◆ TPredator()

◆ ~TPredator()

TPredator::~TPredator ( )
719 {
720 
721 }

Member Function Documentation

◆ BeginStep()

virtual void TPredator::BeginStep ( void  )
inlinevirtual

BeingStep behaviour - must be implemented in descendent classes.

Reimplemented from TALMaSSObject.

Reimplemented in Owl, and Weasel.

130 {}

◆ EndStep()

virtual void TPredator::EndStep ( void  )
inlinevirtual

EndStep behaviour - must be implemented in descendent classes.

Reimplemented from TALMaSSObject.

Reimplemented in Owl, and Weasel.

132 {}

◆ OverlapMyTerritory()

bool TPredator::OverlapMyTerritory ( unsigned  x,
unsigned  y 
)
771 {
772  // ensure we can't go negative
773  x+=SimW;
774  y+=SimH;
775  unsigned mx = m_Location_x+SimW;
776  unsigned my = m_Location_y+SimH;
777  // most likely that it is not in so test for false
778  if (x<mx-m_HomeRange) return false;
779  else if (x>=mx+m_HomeRange) return false;
780  else if (y<my-m_HomeRange) return false;
781  else if (y>=my+m_HomeRange) return false;
782  else return true;
783 }

References m_HomeRange, TAnimal::m_Location_x, TAnimal::m_Location_y, SimH, and SimW.

Referenced by TPredator_Population_Manager::InOtherTerritory().

◆ st_Dispersal()

void TPredator::st_Dispersal ( void  )
virtual

Moves the home range to an area where it does not overlap with a conspecific

788 {
789 
793  bool found=false;
794  unsigned Count=0;
795  while ((!found)&&(Count<100))
796  {
797  // Simple random walk
798  Count++;
802 
804  m_Location_y,this))
805  {
806  m_HaveTerritory=true;
807  found=true;
808  }
809  }
810 }

References g_random_fnc(), TPredator_Population_Manager::InOtherTerritory(), m_DispersalMax, TAnimal::m_guard_cell_x, TAnimal::m_guard_cell_y, m_HaveTerritory, TAnimal::m_Location_x, TAnimal::m_Location_y, m_OurPopulationManager, SimH, SimW, SpeciesID, and Population_Manager::UpdateGuardMap().

Referenced by Weasel::Step(), and Owl::Step().

◆ st_Hunting()

int TPredator::st_Hunting ( )
virtual
726 {
727  unsigned kills=0;
728  // count days since last kill
729  // Takes the Search_x, Search_y, SearchArea. Applies KillEfficiency to
730  // all voles defined by this square
732  //int s=CurrentPrey->size(); // **CJT** to help with debug
733  for (unsigned i=0; i<CurrentPrey->size(); i++)
734  {
735  if (g_random_fnc(1000)<m_KillEfficiency)
736  {
737  (*CurrentPrey)[i]->OnKilled();
738  kills++;
739  }
740  }
741  // Must tidy up here because m_Prey cannot know when to do it
742  CurrentPrey->clear();
743  delete CurrentPrey;
744  // record the kills
745  m_kills_this_season+=kills;
746  return kills;
747 }

References CurrentPrey, g_random_fnc(), m_KillEfficiency, m_kills_this_season, m_Prey, m_Search_x, m_Search_y, m_SearchArea, and Vole_Population_Manager::SupplyVoleList().

Referenced by Weasel::Step(), and Owl::Step().

◆ st_Movement()

void TPredator::st_Movement ( )
virtual
753 {
754  // Can relocate search_x & search_y to be up somewhere in the homerange
755  // but must have all the square in the HomeRange
756  // 1. Drift a bit
762  // 2. determine search area
763  int max_dist=m_HomeRange-m_SearchArea;
766 }

References g_random_fnc(), TAnimal::m_guard_cell_x, TAnimal::m_guard_cell_y, m_HomeRange, TAnimal::m_Location_x, TAnimal::m_Location_y, m_OurPopulationManager, m_Search_x, m_Search_y, m_SearchArea, SimH, SimW, and Population_Manager::UpdateGuardMap().

Referenced by Weasel::Step(), and Owl::Step().

◆ Step()

virtual void TPredator::Step ( void  )
inlinevirtual

Step behaviour - must be implemented in descendent classes.

Reimplemented from TALMaSSObject.

Reimplemented in Owl, and Weasel.

131 {}

◆ SupplyHomeRange()

int TPredator::SupplyHomeRange ( )
inline
138 {return m_HomeRange;}

References m_HomeRange.

Referenced by TPredator_Population_Manager::PredSampleFile().

◆ SupplyKill()

int TPredator::SupplyKill ( )
inline

◆ SupplyKillEff()

int TPredator::SupplyKillEff ( )
inline

◆ SupplySpeciesID()

unsigned TPredator::SupplySpeciesID ( )
inline
134 {return SpeciesID;}

References SpeciesID.

Referenced by TPredator_Population_Manager::PredSampleFile().

◆ SupplyTerr()

bool TPredator::SupplyTerr ( )
inline

Member Data Documentation

◆ CurrentPrey

vector<Vole_Base*>* TPredator::CurrentPrey
protected

Referenced by st_Hunting().

◆ CurrentPState

TTypeOfPredatorState TPredator::CurrentPState
protected

Referenced by Weasel::Step(), Owl::Step(), and TPredator().

◆ m_DispersalMax

unsigned TPredator::m_DispersalMax
protected

◆ m_FailureCount

unsigned TPredator::m_FailureCount
protected

Referenced by Weasel::Step(), Owl::Step(), and TPredator().

◆ m_HaveTerritory

bool TPredator::m_HaveTerritory
protected

◆ m_HomeRange

unsigned TPredator::m_HomeRange
protected

◆ m_KillEfficiency

int TPredator::m_KillEfficiency
protected

◆ m_kills_this_season

int TPredator::m_kills_this_season
protected

◆ m_NoFailuresBeforeDispersal

unsigned TPredator::m_NoFailuresBeforeDispersal
protected

◆ m_OurPopulationManager

TPredator_Population_Manager* TPredator::m_OurPopulationManager
protected

◆ m_Prey

Vole_Population_Manager* TPredator::m_Prey
protected

Referenced by st_Hunting(), and TPredator().

◆ m_Search_x

int TPredator::m_Search_x
protected

Referenced by st_Hunting(), st_Movement(), and TPredator().

◆ m_Search_y

int TPredator::m_Search_y
protected

Referenced by st_Hunting(), st_Movement(), and TPredator().

◆ m_SearchArea

unsigned TPredator::m_SearchArea
protected

◆ PreyResponse1

int TPredator::PreyResponse1
protected

◆ PreyResponse2

int TPredator::PreyResponse2
protected

◆ SimH

int TPredator::SimH
protected

◆ SimW

int TPredator::SimW
protected

◆ SpeciesID

unsigned TPredator::SpeciesID
protected

The documentation for this class was generated from the following files:
TAnimal::m_guard_cell_y
int m_guard_cell_y
The index y to the guard cell.
Definition: PopulationManager.h:374
TPredator::PreyResponse2
int PreyResponse2
Definition: Predators.h:109
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
TPredator::m_Search_x
int m_Search_x
Definition: Predators.h:110
Vole_Population_Manager::SupplyVoleList
vector< Vole_Base * > * SupplyVoleList(unsigned x, unsigned y, unsigned range) const
Definition: VolePopulationManager.cpp:2611
TPredator::m_SearchArea
unsigned m_SearchArea
Definition: Predators.h:106
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
TPredator::SimH
int SimH
Definition: Predators.h:113
TPredator::m_KillEfficiency
int m_KillEfficiency
Definition: Predators.h:118
TAnimal::m_OurLandscape
static Landscape * m_OurLandscape
A pointer to the landscape object shared with all TAnimal objects.
Definition: PopulationManager.h:342
TPredator::PreyResponse1
int PreyResponse1
Definition: Predators.h:108
TPredator::m_FailureCount
unsigned m_FailureCount
Definition: Predators.h:114
TPredator::m_Search_y
int m_Search_y
Definition: Predators.h:111
TPredator::m_Prey
Vole_Population_Manager * m_Prey
Definition: Predators.h:119
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
TPredator::CurrentPState
TTypeOfPredatorState CurrentPState
Definition: Predators.h:103
TPredator::m_HaveTerritory
bool m_HaveTerritory
Definition: Predators.h:117
TPredator::m_OurPopulationManager
TPredator_Population_Manager * m_OurPopulationManager
Definition: Predators.h:120
TPredator::SpeciesID
unsigned SpeciesID
Definition: Predators.h:104
TPredator::m_DispersalMax
unsigned m_DispersalMax
Definition: Predators.h:105
TAnimal::m_guard_cell_x
int m_guard_cell_x
The index x to the guard cell.
Definition: PopulationManager.h:370
tops_InitialState
Definition: Predators.h:55
TPredator_Population_Manager::InOtherTerritory
bool InOtherTerritory(unsigned sp, int p_x, int p_y, TPredator *p_Pred)
Definition: Predators.cpp:670
TPredator::m_HomeRange
unsigned m_HomeRange
Definition: Predators.h:116
g_random_fnc
int g_random_fnc(const int a_range)
Definition: ALMaSS_Random.cpp:74
TPredator::m_NoFailuresBeforeDispersal
unsigned m_NoFailuresBeforeDispersal
Definition: Predators.h:115
TAnimal::m_Location_x
int m_Location_x
The objects ALMaSS x coordinate.
Definition: PopulationManager.h:362
TPredator::SimW
int SimW
Definition: Predators.h:112
TPredator::CurrentPrey
vector< Vole_Base * > * CurrentPrey
Definition: Predators.h:121
TPredator::m_kills_this_season
int m_kills_this_season
Definition: Predators.h:107