Goose Management Model ODdox
1.02
|
The class to handle all predator population related matters. More...
#include <Hunters_all.h>
Public Member Functions | |
bool | AddHunterHunting (int a_polyref, Hunter *a_hunter) |
Adds a hunter hunting, returns true if that hunter is the leader otherwise false. More... | |
bool | CheckDensity (int a_ref, vector< int > *a_illegalfarms, vector< FarmOccupcancyData > *a_FarmOccupancy) |
helper method to reduce code size in hunter rules - checks density rules More... | |
void | CreateObjects (int ob_type, TAnimal *, struct_Hunter *data, int number) |
Creates hunter objects and assigns them to the population manager lists. More... | |
void | DistributeHunters (void) |
Distributes hunters to hunting locations (farms). More... | |
void | DistributeHuntersByRules (vector< HunterInfo > *a_hunterlist, int a_no_hunters, int a_ruleset) |
Implements the rule sets to distributes hunters to hunting locations (farms). More... | |
APoint | GetHunterHome (int a_index, int a_list) |
Returns the hunter home location. More... | |
APoint | GetHunterHuntLoc (int a_index, int a_list, unsigned a_ref) |
Returns the hunter hunting location location. More... | |
int | GetHuntingSeasonEnd () |
Get the end of the overall hunting season. More... | |
int | GetHuntingSeasonStart () |
Get the start of the overall hunting season. More... | |
unsigned | GetNoHuntLocs () |
Calculates the number of hunting locations based on a distribution. More... | |
Hunter_Population_Manager (Landscape *p_L) | |
Hunter population manager constructor. More... | |
void | HunterLeaderMessage (TypeOfHunterLeaderMessage a_signal, int a_polyref) |
A message system to rely messages from the leader hunter to others in his team. More... | |
void | Init (void) |
Create the initial hunter population and initializes any output options. More... | |
bool | IsPolyrefOnActiveList (int a_polyref) |
Debugging check method. More... | |
void | RecordHuntingSuccess (int poly, int birds, int a_hunter) |
Hunting bag output. More... | |
void | RuleSet10Based (int a_no_hunters, vector< int > *a_farmsizes, vector< HunterInfo > *a_hunterlist, vector< APoint > *a_roostlocs, int a_ruleset) |
Used to implement rule sets based on rule set 10. More... | |
void | SaveDistributedHunters (vector< HunterInfo > *a_hunterlist, int a_no_hunters) |
Saves the results of the hunter distribution to an output file. More... | |
void | SaveFarmHunters (vector< HunterInfo > *a_hunterlist, int a_no_hunters) |
Saves the results of the hunter distribution to an output file by farm. More... | |
void | SetHuntingSeason () |
This returns the number of geese which are legal quarry on the polygon the day before. More... | |
virtual | ~Hunter_Population_Manager (void) |
Hunter population manager destructor. More... | |
Public Attributes | |
vector< HunterList * > | m_ActiveHuntingLocationsHunters |
Lists of hunters at all active hunting locations (updated daily) More... | |
vector< int > | m_ActiveHuntingLocationsPolyrefs |
Lists of polygon reference numbers for all active hunting locations (updated daily) More... | |
Protected Member Functions | |
virtual void | DoAfter () |
Available for hunter management - not used currently. More... | |
virtual void | DoBefore () |
Available for hunter management - not used currently. More... | |
virtual void | DoFirst () |
Does general daily tasks e.g. reset time of day, reset bag lists if start of year etc.. More... | |
virtual void | DoLast () |
Available for hunter management - not used currently. More... | |
virtual bool | StepFinished () |
Protected Attributes | |
unsigned | m_daytime |
Used to follow the time of day in 10 minute steps. More... | |
ofstream * | m_HuntingBagRecord |
Output file for hunting bag record. More... | |
int | m_HuntingSeasonEnd |
End of the overall hunting season. More... | |
int | m_HuntingSeasonStart |
Start of the overall hunting season. More... | |
The class to handle all predator population related matters.
Definition at line 334 of file Hunters_all.h.
Hunter_Population_Manager::Hunter_Population_Manager | ( | Landscape * | p_L | ) |
Hunter population manager constructor.
There are two possibilities here - we can be in simulation mode or distribution mode. Simulation mode calls Init and runs hunters as normal whereas distribution mode will attempt to distribute hunters to hunting locations based on model rules. This is also needed for the first time simulations are run to distribute the hunters and produce input for Hunter_Initiation.txt
Definition at line 119 of file Hunters_all.cpp.
References cfg_Hunters_Distribute, DistributeHunters(), Init(), m_HuntingSeasonEnd, m_HuntingSeasonStart, SetHuntingSeason(), and CfgBool::value().
|
virtual |
Hunter population manager destructor.
Definition at line 141 of file Hunters_all.cpp.
References cfg_Hunters_RecordBag, m_HuntingBagRecord, and CfgBool::value().
bool Hunter_Population_Manager::AddHunterHunting | ( | int | a_polyref, |
Hunter * | a_hunter | ||
) |
Adds a hunter hunting, returns true if that hunter is the leader otherwise false.
The field that a hunter is hunting is referenced by a_polyref. First we need to check whether this location already exists. NB this list is emptied every day, so only contains locations where hunters have been or are allocated today.
If the location is found, then the hunter is not a leader and we need to tell them that (returns false)
If the polyref does not already exist the location was not found, it must be new, so we need to add it to the list and tell the hunter he is a leader
Definition at line 1478 of file Hunters_all.cpp.
References m_ActiveHuntingLocationsHunters, and m_ActiveHuntingLocationsPolyrefs.
Referenced by GooseHunter::st_OutHunting().
bool Hunter_Population_Manager::CheckDensity | ( | int | a_ref, |
vector< int > * | a_illegalfarms, | ||
vector< FarmOccupcancyData > * | a_FarmOccupancy | ||
) |
helper method to reduce code size in hunter rules - checks density rules
[in] | a_ref | The farm reference number |
[in] | a_illegalfarms | The list of farms with densities exceeding the limit set for this run |
[in] | a_FarmOccupancy | The list of farms that are occupied and the number of hunters allocated to them |
Area is in m2, so divide by 10000. Hunter density in hunters/ha
Loop through all the farms that are already occupied and figure out if we have this one already
Definition at line 300 of file Hunters_all.cpp.
References FarmManager::AddToIllegalList(), cfg_goose_MinForageOpenness, cfg_Hunters_MaxDensity, FarmManager::GetFarmAreaOpenFields(), FarmOccupcancyData::m_FarmRef, FarmOccupcancyData::m_no_hunters, and CfgFloat::value().
Referenced by DistributeHuntersByRules(), and RuleSet10Based().
void Hunter_Population_Manager::CreateObjects | ( | int | ob_type, |
TAnimal * | , | ||
struct_Hunter * | data, | ||
int | number | ||
) |
Creates hunter objects and assigns them to the population manager lists.
Definition at line 925 of file Hunters_all.cpp.
References g_PopulationManagerList, and toh_GooseHunter.
Referenced by Init().
void Hunter_Population_Manager::DistributeHunters | ( | void | ) |
Distributes hunters to hunting locations (farms).
Reads in the hunter home data which consists of a hunter reference and home x,y coordinates only. Hunter type is by default 0 i.e. goose hunter (to be changed when we have more hunter base types)
We now need to add the number of hunting locations to each hunter. This is done by the method GetNoHuntLocs() which returns the number of locations. We use this to resize the storage for the number of locations.
Definition at line 151 of file Hunters_all.cpp.
References cfg_Hunters_Distribute_Ruleset, DistributeHuntersByRules(), g_msg, GetNoHuntLocs(), SaveDistributedHunters(), SaveFarmHunters(), CfgInt::value(), and MapErrorMsg::Warn().
Referenced by Hunter_Population_Manager().
void Hunter_Population_Manager::DistributeHuntersByRules | ( | vector< HunterInfo > * | a_hunterlist, |
int | a_no_hunters, | ||
int | a_ruleset | ||
) |
Implements the rule sets to distributes hunters to hunting locations (farms).
To distribute the hunters to farms we need the farm information. This resides in the FarmManager held by the landscape, so first we need a pointer to that. The Farm Manager has handy routines for use with the farm allocations .
We need to be able to do the following:
Rule set 0 is simply random distribution to any farm
Rule set 1 - the closest farm
Rule set 2 - Random with openness above cfg_GooseMinForageOpenness
Rule set 3 - random subject to hunter density restrictions
Rule set 4 - openness above cfg_GooseMinForageOpenness but closest to home
Rule set 5 - Pick the closest farm but upto a max hunter density
Rule set 6 - Pick a random farm with openness above and upto a maximum density of hunters
Rule set 7 - Pick the closest farm with openness above and upto a maximum density of hunters
Rule set 8 - the closest farm but based on probability. Requires a probability function which is a power curve using one parameter.
Rule set 9 - the closest farm with openness above X, but based on probability for closeness. Requires a probability function which is a power curve using one parameter.
Rule set 10 - the closest farm with openness above X, on probability for closeness and on density. Requires a probability function which is a power curve using one parameter.
Rule set 11 - the closest farm with openness above X, on probability for closeness and on a probability of the acceptance being reduced with farm size. Requires a probability function which is a power curve using one parameter for distance and a second for area.
Rule set 12 - the closest farm with openness above X, on probability for closeness and on a probability of the acceptance being reduced with distance from roost. Requires a probability function which is a power curve using one parameter for distance and a second for roost distance.
Definition at line 346 of file Hunters_all.cpp.
References FarmManager::CalcCentroids(), cfg_goose_MinForageOpenness, cfg_Hunters_Distribute_Ruleset, cfg_Hunters_MaxDensity, CheckDensity(), FarmManager::FindClosestFarm(), FarmManager::FindClosestFarmOpenness(), FarmManager::FindClosestFarmOpennessProb(), FarmManager::FindFarmWithOpenness(), FarmManager::FindFarmWithRandom(), FarmManager::FindOpennessFarm(), g_msg, FarmManager::GetFarmTotalSize(), FarmManager::GetNoFarms(), FarmManager::GetRandomFarmRefnum(), FarmManager::IsDuplicateRef(), RuleSet10Based(), CfgInt::value(), CfgFloat::value(), and MapErrorMsg::Warn().
Referenced by DistributeHunters().
|
inlineprotectedvirtual |
Available for hunter management - not used currently.
Definition at line 402 of file Hunters_all.h.
|
inlineprotectedvirtual |
Available for hunter management - not used currently.
Definition at line 400 of file Hunters_all.h.
|
protectedvirtual |
Does general daily tasks e.g. reset time of day, reset bag lists if start of year etc..
Definition at line 947 of file Hunters_all.cpp.
References g_msg, Hunter::GetClock(), Hunter::GetHuntField(), GooseHunter::IsLeader(), Hunter::IsOutHunting(), Hunter::IsSeasonEnd(), m_ActiveHuntingLocationsHunters, m_ActiveHuntingLocationsPolyrefs, m_daytime, Hunter::OnMorning(), Hunter::ResetClock(), Hunter::ResetSeasonData(), Hunter::SaveMyData(), and MapErrorMsg::Warn().
|
inlineprotectedvirtual |
Available for hunter management - not used currently.
Definition at line 404 of file Hunters_all.h.
APoint Hunter_Population_Manager::GetHunterHome | ( | int | a_index, |
int | a_list | ||
) |
Returns the hunter home location.
Definition at line 1016 of file Hunters_all.cpp.
APoint Hunter_Population_Manager::GetHunterHuntLoc | ( | int | a_index, |
int | a_list, | ||
unsigned | a_ref | ||
) |
Returns the hunter hunting location location.
Definition at line 1021 of file Hunters_all.cpp.
|
inline |
Get the end of the overall hunting season.
Definition at line 381 of file Hunters_all.h.
References m_HuntingSeasonEnd.
Referenced by GooseHunter::GetSeasonLengthLeft(), GooseHunter::InSeason(), and GooseHunter::IsSeasonEnd().
|
inline |
Get the start of the overall hunting season.
Definition at line 379 of file Hunters_all.h.
References m_HuntingSeasonStart.
Referenced by GooseHunter::GetSeasonLengthLeft(), and GooseHunter::InSeason().
unsigned Hunter_Population_Manager::GetNoHuntLocs | ( | ) |
Calculates the number of hunting locations based on a distribution.
Calculates the number of hunting locations based on a distribution. Uses probability of one location, two locations or three+
Definition at line 186 of file Hunters_all.cpp.
References cfg_hunterlocFOUR, cfg_hunterlocONE, cfg_hunterlocTHREE, cfg_hunterlocTWO, g_rand_uni, and CfgFloat::value().
Referenced by DistributeHunters().
void Hunter_Population_Manager::HunterLeaderMessage | ( | TypeOfHunterLeaderMessage | a_signal, |
int | a_polyref | ||
) |
A message system to rely messages from the leader hunter to others in his team.
This is used to relay a message from a leader hunter to any other hunters in a field at the same time as the leader. The leader passes the polygon reference number which is used to find the list of hunters. They are then each called passing them an event specified by a_signal (currently there is only two types of message, but this can be expanded).
Definition at line 1027 of file Hunters_all.cpp.
References g_msg, hlm_gohome, hlm_shoot, m_ActiveHuntingLocationsHunters, m_ActiveHuntingLocationsPolyrefs, and MapErrorMsg::Warn().
Referenced by GooseHunter::st_OutHunting().
void Hunter_Population_Manager::Init | ( | void | ) |
Create the initial hunter population and initializes any output options.
Here we need to create the initial hunter population with each individual with its own hunting pattern in terms of timing, location, and intensity/efficiency. Information on hunters is specified in the Hunter_Hunting_Locations.txt file.
One of the challenges is to ensure that we have a matching prey population for each hunter. This is achieved by two structures, the first being a variable in each Population_Manager that states its type (m_population_type) and its associated enum TTypesOfPopulation. The second is a globally visible structure holding a list of any active population managers.
This method also initializes any output options.
Definition at line 837 of file Hunters_all.cpp.
References cfg_Hunters_RecordBag, CreateObjects(), g_msg, g_PopulationManagerList, m_daytime, struct_Hunter::m_efficiency, struct_Hunter::m_farms, struct_Hunter::m_goosecountchance, struct_Hunter::m_home, struct_Hunter::m_HType, m_HuntingBagRecord, struct_Hunter::m_huntingdayslimit, struct_Hunter::m_huntlocrefs, struct_Hunter::m_huntlocs, struct_Hunter::m_L, struct_Hunter::m_preyPM, struct_Hunter::m_ref, struct_Hunter::m_weekend, toh_GooseHunter, CfgBool::value(), and MapErrorMsg::Warn().
Referenced by Hunter_Population_Manager().
bool Hunter_Population_Manager::IsPolyrefOnActiveList | ( | int | a_polyref | ) |
Debugging check method.
Definition at line 1059 of file Hunters_all.cpp.
References m_ActiveHuntingLocationsPolyrefs.
void Hunter_Population_Manager::RecordHuntingSuccess | ( | int | poly, |
int | birds, | ||
int | a_hunter | ||
) |
Hunting bag output.
This method stores information about the birds that have been shot. It is essential that the hunting bag record file is open when this is called - there is no checking. This is controlled by a configuration variable cfg_Hunters_RecordBag
Definition at line 1002 of file Hunters_all.cpp.
References g_date, Calendar::GetHour(), and Calendar::GetMinute().
Referenced by GooseHunter::OnShotABird().
void Hunter_Population_Manager::RuleSet10Based | ( | int | a_no_hunters, |
vector< int > * | a_farmsizes, | ||
vector< HunterInfo > * | a_hunterlist, | ||
vector< APoint > * | a_roostlocs, | ||
int | a_ruleset | ||
) |
Used to implement rule sets based on rule set 10.
Definition at line 800 of file Hunters_all.cpp.
References cfg_goose_MinForageOpenness, cfg_Hunters_Distribute_Ruleset, CheckDensity(), FarmManager::FindClosestFarmOpennessProb(), FarmManager::FindClosestFarmOpennessProbNearRoostIsBest(), FarmManager::FindClosestFarmOpennessProbSmallIsBest(), g_msg, FarmManager::GetNoFarms(), CfgInt::value(), CfgFloat::value(), and MapErrorMsg::Warn().
Referenced by DistributeHuntersByRules().
void Hunter_Population_Manager::SaveDistributedHunters | ( | vector< HunterInfo > * | a_hunterlist, |
int | a_no_hunters | ||
) |
Saves the results of the hunter distribution to an output file.
Definition at line 198 of file Hunters_all.cpp.
Referenced by DistributeHunters().
void Hunter_Population_Manager::SaveFarmHunters | ( | vector< HunterInfo > * | a_hunterlist, |
int | a_no_hunters | ||
) |
Saves the results of the hunter distribution to an output file by farm.
Definition at line 233 of file Hunters_all.cpp.
References cfg_goose_MinForageOpenness, FarmManager::GetFarmArableSize(), FarmManager::GetFarmAreaOpenFields(), FarmManager::GetFarmCentroid(), FarmManager::GetFarmNoFields(), FarmManager::GetFarmNoOpenFields(), Farm::GetFarmNumber(), FarmManager::GetFarmPtrIndex(), FarmManager::GetFarmTotalSize(), FarmManager::GetFarmType(), FarmManager::GetFarmValidCoords(), FarmManager::GetNoFarms(), farminfo::m_areaopenfields, farminfo::m_farmarable, farminfo::m_farmcentroid, farminfo::m_farmref, farminfo::m_farmsize, farminfo::m_farmtype, farminfo::m_farmvalid, farminfo::m_nofields, farminfo::m_NoHunters, farminfo::m_openfields, and CfgFloat::value().
Referenced by DistributeHunters().
void Hunter_Population_Manager::SetHuntingSeason | ( | ) |
This returns the number of geese which are legal quarry on the polygon the day before.
The goose hunting season is complicated because it runs over a year boundary (or it can)
Definition at line 1498 of file Hunters_all.cpp.
References cfg_goose_greylagopenseasonend, cfg_goose_greylagopenseasonstart, cfg_goose_pinkfootopenseasonend, cfg_goose_pinkfootopenseasonstart, g_msg, m_HuntingSeasonEnd, m_HuntingSeasonStart, CfgInt::value(), and MapErrorMsg::Warn().
Referenced by Hunter_Population_Manager().
|
inlineprotectedvirtual |
Definition at line 396 of file Hunters_all.h.
vector<HunterList*> Hunter_Population_Manager::m_ActiveHuntingLocationsHunters |
Lists of hunters at all active hunting locations (updated daily)
Definition at line 371 of file Hunters_all.h.
Referenced by AddHunterHunting(), DoFirst(), and HunterLeaderMessage().
vector<int> Hunter_Population_Manager::m_ActiveHuntingLocationsPolyrefs |
Lists of polygon reference numbers for all active hunting locations (updated daily)
Definition at line 373 of file Hunters_all.h.
Referenced by AddHunterHunting(), DoFirst(), HunterLeaderMessage(), and IsPolyrefOnActiveList().
|
protected |
Used to follow the time of day in 10 minute steps.
Definition at line 386 of file Hunters_all.h.
|
protected |
Output file for hunting bag record.
Definition at line 388 of file Hunters_all.h.
Referenced by Init(), and ~Hunter_Population_Manager().
|
protected |
End of the overall hunting season.
Definition at line 392 of file Hunters_all.h.
Referenced by GetHuntingSeasonEnd(), Hunter_Population_Manager(), and SetHuntingSeason().
|
protected |
Start of the overall hunting season.
Definition at line 390 of file Hunters_all.h.
Referenced by GetHuntingSeasonStart(), Hunter_Population_Manager(), and SetHuntingSeason().