Goose Management Model ODdox
1.02
|
The class for goose hunters encompsassing all their specific behaviours. More...
#include <Hunters_all.h>
Public Member Functions | |
GooseHunter (struct_Hunter *p_data, Hunter_Population_Manager *p_PPM) | |
GooseHunter constructor. More... | |
bool | IsLeader () |
Returns the leader flag. More... | |
void | OnShotABird (int a_birdtype, int a_poly) |
Message received when a goose is successully shot. More... | |
virtual void | ResetBag () |
Sets the annual hunting bag to zero. More... | |
virtual void | SaveMyData (ofstream *a_ofile) |
Each hunter needs to save different kinds of data, so we use a polymorphic method for this. More... | |
virtual void | Step () |
GooseHunter Step code. More... | |
virtual | ~GooseHunter () |
GooseHunter destructor. More... | |
Public Member Functions inherited from Hunter | |
int | GetBag () |
Gets the annual hunting bag. More... | |
int | GetClock () |
Supplies the clock time. More... | |
Farm * | GetFarmerRef (unsigned a_ref) |
Provide our ref name. More... | |
APoint | GetHome () |
Provide our home coords. More... | |
int | GetHuntField () |
Get the polygon reference number to our current hunting field (which is at a hunting location) More... | |
int | GetHuntingDays () |
Gets the annual hunting attempts count. More... | |
APoint | GetHuntLoc (unsigned a_ref) |
Provide our hunting location coords. More... | |
int | GetRef () |
Provide our ref name. More... | |
int | GetShots () |
Gets the number of shots this season to-date. More... | |
Hunter (struct_Hunter *p_data, Hunter_Population_Manager *p_PPM) | |
The constructor for the Hunter class. More... | |
bool | IsOutHunting () |
A debug function, but may be useful in other contexts. Returns true of currently out hunting. More... | |
void | OnMorning () |
Optimism in the morning, perhaps we should hunt? More... | |
void | ResetClock () |
Sets the clock back to zero. More... | |
void | ResetHuntingOpportunities () |
Sets the annual hunting attempts count to zero. More... | |
void | ResetSeasonData () |
Sets the bag and hunting counters to zero. More... | |
virtual | ~Hunter () |
The destructor for the Hunter class. More... | |
Protected Member Functions | |
virtual int | CheckForGame (void) |
If the hunter checks for game at their hunting locations then this is done here. Must be overridden. More... | |
bool | FindHuntingLocation (void) |
Locate the hunt for today. More... | |
virtual int | GetSeasonLengthLeft (int day) |
Returns the length of the hunting season in days - MUST be overridden in descendent class. More... | |
virtual void | Init () |
Initiation of a specific goose hunter here. More... | |
virtual bool | InSeason (int day) |
Is it goose hunting season? - MUST be overridden in descendent class. More... | |
virtual bool | IsSeasonEnd (int day) |
Is it the end of the goose hunting season? - MUST be overridden in descendent class. More... | |
virtual void | OnGoHome () |
On gohome message handler. More... | |
virtual void | OnShoot () |
On shoot message handler. More... | |
TypeOfHunterState | st_OutHunting (void) |
The basic hunting behaviour. More... | |
virtual TypeOfHunterState | st_ShouldGoHunting (void) |
Behavior involved in deciding whether to go hunting. More... | |
Protected Member Functions inherited from Hunter | |
virtual void | Init (struct_Hunter *p_data) |
Initiation of a basic hunter here. More... | |
bool | IsTodayAChosenHuntDay (int a_today) |
Uses a probability test to determine whether to go hunting today. More... | |
bool | IsTodayAPreferredHuntDay (int a_today) |
Checks for the hunting day preference (weekday or any day) More... | |
TypeOfHunterState | st_OutHunting (void) |
The basic hunting behaviour. More... | |
TypeOfHunterState | st_Resting (void) |
Finished hunting and waiting for the next opportunity. More... | |
Protected Attributes | |
bool | m_dugin |
Flag to show whether a hunting location has been found. More... | |
int | m_goosebag [gst_foobar] |
A special bag data structure so the hunter knows what kind of geese he shot. More... | |
int | m_greylagbaglimit |
Bag limit for greylag. More... | |
polylist * | m_huntfields |
Our list of possible hunting fields as polygon reference numbers as supplied by Landscape::SupplyPolyRef(int,int);. More... | |
bool | m_leader |
When hunting this indicates whether the hunter is a team leader. More... | |
int | m_pinkfootbaglimit |
Bag limit for pinkfoot. More... | |
Goose_Population_Manager * | m_preyPopulationManger |
Pointer to our game population, the geese. More... | |
Protected Attributes inherited from Hunter | |
int | m_bag |
The numbers of game items shot todate this year. More... | |
int | m_baglimit |
Annual self-imposed limit on number shot - unused at present. More... | |
int | m_clock |
Records the time spent hunting per day. More... | |
TypeOfHunterState | m_CurrentHState |
The current hunter behavioural state. More... | |
double | m_efficiency |
Probability of 'hitting' a game item. More... | |
double | m_goosecountchance |
Probability of checking for geese in hunting area. More... | |
APoint | m_Home |
int | m_huntfield_polyref |
The polygon reference number to our current hunting field (which is at a hunting location) More... | |
int | m_huntingdays |
The numbers of days used for hunting this year. More... | |
int | m_huntlimit |
Annual self-imposed limit on number of days spent hunting. More... | |
vector< int > | m_HuntLocRefs |
vector< APoint > | m_HuntLocs |
int | m_lasthuntday |
The date for the last hunt day. More... | |
int | m_myMagazine |
The number of shells in the magazine. More... | |
int | m_myname |
A reference number unique to this hunter. More... | |
int | m_myShots |
The numbers of shots to-date this year. More... | |
int | m_NoHuntLocs |
vector< Farm * > | m_OurFarmers |
List of pointers to the farmers whose land the hunter hunts More... | |
Hunter_Population_Manager * | m_OurPopulationManager |
Pointer to the population manager. More... | |
int | m_weekend |
Code for weekly hunting activity. More... | |
The class for goose hunters encompsassing all their specific behaviours.
Definition at line 268 of file Hunters_all.h.
GooseHunter::GooseHunter | ( | struct_Hunter * | p_data, |
Hunter_Population_Manager * | p_PPM | ||
) |
GooseHunter constructor.
Definition at line 1197 of file Hunters_all.cpp.
References cfg_hunter_greylagbaglimit, cfg_hunter_pinkfootbaglimit, Init(), struct_Hunter::m_farms, m_greylagbaglimit, m_leader, Hunter::m_OurFarmers, m_pinkfootbaglimit, struct_Hunter::m_preyPM, m_preyPopulationManger, and CfgInt::value().
|
virtual |
|
protectedvirtual |
If the hunter checks for game at their hunting locations then this is done here. Must be overridden.
The hunter checks for legal game at their hunting fields if they are set to do so, otherwise they take a random shot at a place.
If they don't check then they automatically assume they can go out hunting.
Here we assume they check all their hunting locations and pick the best. We might also want as a later refinement to know how many geese because and only go out when there are a lot.
Reimplemented from Hunter.
Definition at line 1231 of file Hunters_all.cpp.
References g_rand_uni, Hunter::m_goosecountchance, and m_huntfields.
Referenced by st_OutHunting().
|
protected |
Locate the hunt for today.
|
protectedvirtual |
Returns the length of the hunting season in days - MUST be overridden in descendent class.
The goose hunting season is complicated because it runs over a year boundary (or it can)
Reimplemented from Hunter.
Definition at line 1296 of file Hunters_all.cpp.
References Hunter_Population_Manager::GetHuntingSeasonEnd(), Hunter_Population_Manager::GetHuntingSeasonStart(), Hunter::m_OurPopulationManager, and start.
|
protectedvirtual |
Initiation of a specific goose hunter here.
Here we need to create a list of possible goose hunting fields in our hunting locations. So we ask for openness scores for any fields with at each of our hunting locations. This is provided by Farm::ListOpenFields
Definition at line 1212 of file Hunters_all.cpp.
References cfg_goose_MinForageOpenness, m_huntfields, Hunter::m_NoHuntLocs, Hunter::m_OurFarmers, Hunter::ResetClock(), Hunter::ResetSeasonData(), and CfgFloat::value().
Referenced by GooseHunter().
|
protectedvirtual |
Is it goose hunting season? - MUST be overridden in descendent class.
The goose hunting season is complicated because it runs over a year boundary (or it can) Particularly the first year of the simulation is tricky, because we start out in January which can be legal hunting season, but the geese don't arrive until the fall.
Reimplemented from Hunter.
Definition at line 1271 of file Hunters_all.cpp.
References Hunter_Population_Manager::GetHuntingSeasonEnd(), Hunter_Population_Manager::GetHuntingSeasonStart(), Hunter::m_OurPopulationManager, and start.
|
inline |
Returns the leader flag.
Definition at line 325 of file Hunters_all.h.
References m_leader.
Referenced by Hunter_Population_Manager::DoFirst().
|
protectedvirtual |
Is it the end of the goose hunting season? - MUST be overridden in descendent class.
Reimplemented from Hunter.
Definition at line 1260 of file Hunters_all.cpp.
References Hunter_Population_Manager::GetHuntingSeasonEnd(), and Hunter::m_OurPopulationManager.
|
protectedvirtual |
On gohome message handler.
Reimplemented from Hunter.
Definition at line 1438 of file Hunters_all.cpp.
References Hunter::m_CurrentHState, m_dugin, Hunter::m_huntfield_polyref, m_leader, and tohts_Resting.
|
protectedvirtual |
On shoot message handler.
This is a message handler for the situation when a hunter is in a team but not the leader. When the leader decides to shoot the other team members hunter will shoot. When a bird is shot the message is sent to the goose population manager. This works out which birds are shot and removes them, calling back with an OnShotABird message so the hunter can record what has been shot. It is here that the bag record is kept.
Reimplemented from Hunter.
Definition at line 1419 of file Hunters_all.cpp.
References Goose_Population_Manager::BirdsShot(), Goose_Population_Manager::BirdsToShootAtPoly(), g_rand_uni, Hunter::m_efficiency, Hunter::m_huntfield_polyref, Hunter::m_myShots, and m_preyPopulationManger.
void GooseHunter::OnShotABird | ( | int | a_birdtype, |
int | a_poly | ||
) |
Message received when a goose is successully shot.
Definition at line 1413 of file Hunters_all.cpp.
References cfg_Hunters_RecordBag, Hunter::m_bag, m_goosebag, Hunter::m_myname, Hunter::m_OurPopulationManager, Hunter_Population_Manager::RecordHuntingSuccess(), and CfgBool::value().
Referenced by Goose_Population_Manager::BirdsShot().
|
inlinevirtual |
Sets the annual hunting bag to zero.
Reimplemented from Hunter.
Definition at line 320 of file Hunters_all.h.
References gst_foobar, m_goosebag, and Hunter::ResetBag().
|
virtual |
Each hunter needs to save different kinds of data, so we use a polymorphic method for this.
Reimplemented from Hunter.
Definition at line 1469 of file Hunters_all.cpp.
References Hunter::GetBag(), Hunter::GetHuntingDays(), Hunter::GetShots(), gst_foobar, m_goosebag, and Hunter::m_myname.
|
protected |
The basic hunting behaviour.
First at last check if the hunter checks for geese before going, if there are none he does not go out. Simulates a 10 minute hunting timestep. Must determine the time spent hunting and the time of day. Then wait for geese, and determine the probability of shooting them. Once the hunting time is used up, then come home.
We have a place to hunt - so look and see if there is anything to shoot Must assess a range from our location - we will be centrally placed in a field - so the real location is not precise beyond this resolution. Birds will also be located at the field level, so a simplifying assumption here is that a bird in the same field is 'fair game', outside the field it is not. Once we determine that there is something to shoot at, then we need to determine whether, we try and shoot, if so whether we hit the bird. If we shoot this must be registered in the system as an event, and any goose near enough to be affected will need to be told of this.
m_huntloc_index holds the polyref, from which we can get access to the forage locations in the goose manager - this has a list of who is there at any one moment in time.
When assessing whether to shoot the mix of the birds present will be critical. If it is primarily Barnacles then these are protected so the hunter will not shoot if not he can go ahead. The current solution just ignores barnacle geese - they cannot be shot and are not counted in the number of geese on a field.
A further consideration is whether the geese land near to the hunter. If too far away then they will not shoot. This depends on the area of the field. We assume that any field of less than 2Ha, then the geese are close enough, but if over this then there is a cfg_largefieldgooseproximity chance of shooting.
To Determine if we try to shoot and the chance of hitting, right now we assume we always shoot and the chance of hitting something is our skill - held in m_efficiency. The hunter has as many shots as is in his magazine (determined by the member variable m_myMagazine)
When a bird is shot the message is sent to the goose population manager. This works out which birds are shot and removes them, calling back with an OnShotABird message so the hunter can record what has been shot. It is here that the bag record is kept.
Definition at line 1332 of file Hunters_all.cpp.
References Hunter_Population_Manager::AddHunterHunting(), Goose_Population_Manager::BangAtPoly(), Goose_Population_Manager::BirdsShot(), Goose_Population_Manager::BirdsToShootAtPoly(), cfg_huntlength, cfg_largefieldgooseproximity, cfg_largefieldgooseproximitysizecutoff, CheckForGame(), g_rand_uni, hlm_gohome, hlm_shoot, Hunter_Population_Manager::HunterLeaderMessage(), Hunter::m_clock, m_dugin, Hunter::m_efficiency, Hunter::m_huntfield_polyref, Hunter::m_huntingdays, Hunter::m_lasthuntday, m_leader, Hunter::m_myMagazine, Hunter::m_myShots, Hunter::m_OurPopulationManager, m_preyPopulationManger, tohts_OutHunting, tohts_Resting, CfgInt::value(), and CfgFloat::value().
Referenced by Step().
|
protectedvirtual |
Behavior involved in deciding whether to go hunting.
Here we check for any goose specific bag limits
Otherwise we want to find out if we should hunt today - this depends on the season for our game species, and whether we want to hunt today - which depends on whether it is a weekend or not - and then how eager we are.
Reimplemented from Hunter.
Definition at line 1315 of file Hunters_all.cpp.
References gst_PinkfootFamilyGroup, gst_PinkfootNonBreeder, m_goosebag, m_pinkfootbaglimit, Hunter::st_ShouldGoHunting(), and tohts_Resting.
Referenced by Step().
|
virtual |
GooseHunter Step code.
Definition at line 1446 of file Hunters_all.cpp.
References Hunter::m_CurrentHState, st_OutHunting(), Hunter::st_Resting(), st_ShouldGoHunting(), tohts_Hunting, tohts_InitialState, tohts_OutHunting, and tohts_Resting.
|
protected |
Flag to show whether a hunting location has been found.
Definition at line 277 of file Hunters_all.h.
Referenced by OnGoHome(), and st_OutHunting().
|
protected |
A special bag data structure so the hunter knows what kind of geese he shot.
Definition at line 279 of file Hunters_all.h.
Referenced by OnShotABird(), ResetBag(), SaveMyData(), and st_ShouldGoHunting().
|
protected |
|
protected |
Our list of possible hunting fields as polygon reference numbers as supplied by Landscape::SupplyPolyRef(int,int);.
Definition at line 275 of file Hunters_all.h.
Referenced by CheckForGame(), Init(), and ~GooseHunter().
|
protected |
When hunting this indicates whether the hunter is a team leader.
Definition at line 285 of file Hunters_all.h.
Referenced by GooseHunter(), IsLeader(), OnGoHome(), and st_OutHunting().
|
protected |
Bag limit for pinkfoot.
Definition at line 281 of file Hunters_all.h.
Referenced by GooseHunter(), and st_ShouldGoHunting().
|
protected |
Pointer to our game population, the geese.
Definition at line 273 of file Hunters_all.h.
Referenced by GooseHunter(), OnShoot(), and st_OutHunting().