ALMaSS Vole ODDox  1.1
The vole model description following ODdox protocol
TPredator Class Reference

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

#include <Predators.h>

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
unsigned SupplyFarmOwnerRef ()
 
AnimalPosition SupplyPosition ()
 
APoint SupplyPoint ()
 
int SupplyPolygonRef ()
 
int Supply_m_Location_x ()
 
int Supply_m_Location_y ()
 
virtual void KillThis ()
 
virtual void CopyMyself ()
 
void SetX (int a_x)
 
void SetY (int a_y)
 
 TAnimal (int x, int y, Landscape *L)
 
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual int WhatState ()
 
virtual void Dying ()
 
void CheckManagement (void)
 
void CheckManagementXY (int x, int y)
 
virtual bool OnFarmEvent (FarmToDo)
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone ()
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
 
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. 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
 
int m_Location_y
 
Landscapem_OurLandscape
 
- 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

- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. 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.

Definition at line 87 of file Predators.h.

Constructor & Destructor Documentation

◆ TPredator()

◆ ~TPredator()

TPredator::~TPredator ( )

Definition at line 719 of file Predators.cpp.

720 {
721 
722 }

Member Function Documentation

◆ BeginStep()

virtual void TPredator::BeginStep ( void  )
inlinevirtual

BeingStep behaviour - must be implemented in descendent classes.

Reimplemented from TAnimal.

Reimplemented in Owl, and Weasel.

Definition at line 130 of file Predators.h.

130 {}

◆ EndStep()

virtual void TPredator::EndStep ( void  )
inlinevirtual

EndStep behaviour - must be implemented in descendent classes.

Reimplemented from TAnimal.

Reimplemented in Owl, and Weasel.

Definition at line 132 of file Predators.h.

132 {}

◆ OverlapMyTerritory()

bool TPredator::OverlapMyTerritory ( unsigned  x,
unsigned  y 
)

Definition at line 770 of file Predators.cpp.

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 ( )
virtual

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

Definition at line 787 of file Predators.cpp.

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

References TPredator_Population_Manager::InOtherTerritory(), m_DispersalMax, m_HaveTerritory, TAnimal::m_Location_x, TAnimal::m_Location_y, m_OurPopulationManager, SimH, SimW, and SpeciesID.

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

◆ st_Hunting()

int TPredator::st_Hunting ( )
virtual

Definition at line 726 of file Predators.cpp.

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

References CurrentPrey, 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

Definition at line 753 of file Predators.cpp.

754 {
755  // Can relocate search_x & search_y to be up somewhere in the homerange
756  // but must have all the square in the HomeRange
757  // 1. Drift a bit
758  m_Location_x+=random(3)-1;
759  m_Location_y+=random(3)-1;
762  // 2. determine search area
763  int max_dist=m_HomeRange-m_SearchArea;
764  m_Search_x=(m_Location_x+random(max_dist))%SimW;
765  m_Search_y=(m_Location_y+random(max_dist))%SimH;
766 }

References m_HomeRange, TAnimal::m_Location_x, TAnimal::m_Location_y, m_Search_x, m_Search_y, m_SearchArea, SimH, and SimW.

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

◆ Step()

virtual void TPredator::Step ( void  )
inlinevirtual

Step behaviour - must be implemented in descendent classes.

Reimplemented from TAnimal.

Reimplemented in Owl, and Weasel.

Definition at line 131 of file Predators.h.

131 {}

◆ SupplyHomeRange()

int TPredator::SupplyHomeRange ( )
inline

Definition at line 138 of file Predators.h.

138 {return m_HomeRange;}

References m_HomeRange.

Referenced by TPredator_Population_Manager::PredSampleFile().

◆ SupplyKill()

int TPredator::SupplyKill ( )
inline

Definition at line 135 of file Predators.h.

135 {return m_kills_this_season;}

References m_kills_this_season.

Referenced by TPredator_Population_Manager::PredSampleFile().

◆ SupplyKillEff()

int TPredator::SupplyKillEff ( )
inline

Definition at line 137 of file Predators.h.

137 {return m_KillEfficiency;}

References m_KillEfficiency.

Referenced by TPredator_Population_Manager::PredSampleFile().

◆ SupplySpeciesID()

unsigned TPredator::SupplySpeciesID ( )
inline

Definition at line 134 of file Predators.h.

134 {return SpeciesID;}

References SpeciesID.

Referenced by TPredator_Population_Manager::PredSampleFile().

◆ SupplyTerr()

bool TPredator::SupplyTerr ( )
inline

Definition at line 136 of file Predators.h.

136 {return m_HaveTerritory;}

References m_HaveTerritory.

Referenced by TPredator_Population_Manager::PredSampleFile().

Member Data Documentation

◆ CurrentPrey

vector<Vole_Base*>* TPredator::CurrentPrey
protected

Definition at line 121 of file Predators.h.

Referenced by st_Hunting().

◆ CurrentPState

TTypeOfPredatorState TPredator::CurrentPState
protected

Definition at line 103 of file Predators.h.

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

◆ m_DispersalMax

unsigned TPredator::m_DispersalMax
protected

Definition at line 105 of file Predators.h.

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

◆ m_FailureCount

unsigned TPredator::m_FailureCount
protected

Definition at line 114 of file Predators.h.

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

◆ m_HaveTerritory

bool TPredator::m_HaveTerritory
protected

Definition at line 117 of file Predators.h.

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

◆ m_HomeRange

unsigned TPredator::m_HomeRange
protected

◆ m_KillEfficiency

int TPredator::m_KillEfficiency
protected

Definition at line 118 of file Predators.h.

Referenced by Owl::Owl(), st_Hunting(), SupplyKillEff(), TPredator(), and Weasel::Weasel().

◆ m_kills_this_season

int TPredator::m_kills_this_season
protected

Definition at line 107 of file Predators.h.

Referenced by Weasel::BeginStep(), Owl::BeginStep(), st_Hunting(), SupplyKill(), and TPredator().

◆ m_NoFailuresBeforeDispersal

unsigned TPredator::m_NoFailuresBeforeDispersal
protected

Definition at line 115 of file Predators.h.

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

◆ m_OurPopulationManager

TPredator_Population_Manager* TPredator::m_OurPopulationManager
protected

Definition at line 120 of file Predators.h.

Referenced by Weasel::BeginStep(), Owl::BeginStep(), st_Dispersal(), and TPredator().

◆ m_Prey

Vole_Population_Manager* TPredator::m_Prey
protected

Definition at line 119 of file Predators.h.

Referenced by st_Hunting(), and TPredator().

◆ m_Search_x

int TPredator::m_Search_x
protected

Definition at line 110 of file Predators.h.

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

◆ m_Search_y

int TPredator::m_Search_y
protected

Definition at line 111 of file Predators.h.

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

◆ m_SearchArea

unsigned TPredator::m_SearchArea
protected

Definition at line 106 of file Predators.h.

Referenced by Owl::Owl(), st_Hunting(), st_Movement(), TPredator(), and Weasel::Weasel().

◆ PreyResponse1

int TPredator::PreyResponse1
protected

Definition at line 108 of file Predators.h.

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

◆ PreyResponse2

int TPredator::PreyResponse2
protected

Definition at line 109 of file Predators.h.

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

◆ SimH

int TPredator::SimH
protected

Definition at line 113 of file Predators.h.

Referenced by OverlapMyTerritory(), st_Dispersal(), st_Movement(), and TPredator().

◆ SimW

int TPredator::SimW
protected

Definition at line 112 of file Predators.h.

Referenced by OverlapMyTerritory(), st_Dispersal(), st_Movement(), and TPredator().

◆ SpeciesID

unsigned TPredator::SpeciesID
protected

Definition at line 104 of file Predators.h.

Referenced by Owl::Owl(), st_Dispersal(), SupplySpeciesID(), and Weasel::Weasel().


The documentation for this class was generated from the following files:
TAnimal::m_OurLandscape
Landscape * m_OurLandscape
Definition: PopulationManager.h:229
TPredator::PreyResponse2
int PreyResponse2
Definition: Predators.h:109
TAnimal::TAnimal
TAnimal(int x, int y, Landscape *L)
Definition: PopulationManager.cpp:1367
TPredator::m_Search_x
int m_Search_x
Definition: Predators.h:110
TPredator::m_SearchArea
unsigned m_SearchArea
Definition: Predators.h:106
Landscape::SupplySimAreaHeight
int SupplySimAreaHeight(void)
Definition: Landscape.h:1637
Vole_Population_Manager::SupplyVoleList
vector< Vole_Base * > * SupplyVoleList(unsigned x, unsigned y, unsigned range)
Definition: VolePopulationManager.cpp:3289
Landscape::SupplySimAreaWidth
int SupplySimAreaWidth(void)
Definition: Landscape.h:1632
TAnimal::m_Location_y
int m_Location_y
Definition: PopulationManager.h:228
TPredator::SimH
int SimH
Definition: Predators.h:113
TPredator::m_KillEfficiency
int m_KillEfficiency
Definition: Predators.h:118
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
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
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:671
TPredator::m_HomeRange
unsigned m_HomeRange
Definition: Predators.h:116
TPredator::m_NoFailuresBeforeDispersal
unsigned m_NoFailuresBeforeDispersal
Definition: Predators.h:115
TAnimal::m_Location_x
int m_Location_x
Definition: PopulationManager.h:225
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