Goose Management Model ODdox
1.02
|
The base class for hunters encompsassing all their general behaviours. More...
#include <Hunters_all.h>
Public Member Functions | |
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... | |
virtual int | GetSeasonLengthLeft (int) |
Returns the length of the hunting season in days - MUST be overridden in descendent class. 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... | |
virtual bool | InSeason (int) |
Is it hunting season? - MUST be overridden in descendent class. More... | |
bool | IsOutHunting () |
A debug function, but may be useful in other contexts. Returns true of currently out hunting. More... | |
virtual bool | IsSeasonEnd (int) |
Is it the end of the hunting season? - MUST be overridden in descendent class. More... | |
virtual void | OnGoHome () |
On gohome message handler - must be overidden in descendent classes. More... | |
void | OnMorning () |
Optimism in the morning, perhaps we should hunt? More... | |
virtual void | OnShoot () |
On shoot message handler - must be overidden in descendent classes. More... | |
virtual void | ResetBag () |
Sets the annual hunting bag to zero. 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 void | SaveMyData (ofstream *) |
Each hunter needs to save different kinds of data, so we use a polymorphic method for this. 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... | |
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... | |
virtual TypeOfHunterState | st_ShouldGoHunting (void) |
Decide whether to go out hunting on a specific day. More... | |
Protected Attributes | |
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 base class for hunters encompsassing all their general behaviours.
The hunter class specifies general hunter behaviours that are common to all hunter types.
Definition at line 120 of file Hunters_all.h.
Hunter::Hunter | ( | struct_Hunter * | p_data, |
Hunter_Population_Manager * | p_PPM | ||
) |
The constructor for the Hunter class.
Definition at line 1075 of file Hunters_all.cpp.
References Init(), and m_OurPopulationManager.
|
virtual |
The destructor for the Hunter class.
Definition at line 1081 of file Hunters_all.cpp.
|
inlineprotectedvirtual |
If the hunter checks for game at their hunting locations then this is done here. Must be overridden.
Reimplemented in GooseHunter.
Definition at line 179 of file Hunters_all.h.
|
inline |
Gets the annual hunting bag.
Definition at line 193 of file Hunters_all.h.
References m_bag.
Referenced by GooseHunter::SaveMyData().
|
inline |
Supplies the clock time.
Definition at line 210 of file Hunters_all.h.
References m_clock.
Referenced by Hunter_Population_Manager::DoFirst().
|
inline |
|
inline |
|
inline |
Get the polygon reference number to our current hunting field (which is at a hunting location)
Definition at line 234 of file Hunters_all.h.
References m_huntfield_polyref.
Referenced by Hunter_Population_Manager::DoFirst().
|
inline |
Gets the annual hunting attempts count.
Definition at line 189 of file Hunters_all.h.
References m_huntingdays.
Referenced by GooseHunter::SaveMyData().
|
inline |
Provide our hunting location coords.
Definition at line 238 of file Hunters_all.h.
References m_HuntLocs.
|
inline |
|
inlinevirtual |
Returns the length of the hunting season in days - MUST be overridden in descendent class.
Reimplemented in GooseHunter.
Definition at line 250 of file Hunters_all.h.
Referenced by IsTodayAChosenHuntDay().
|
inline |
Gets the number of shots this season to-date.
Definition at line 197 of file Hunters_all.h.
References m_myShots.
Referenced by GooseHunter::SaveMyData().
|
protectedvirtual |
Initiation of a basic hunter here.
Definition at line 1086 of file Hunters_all.cpp.
References cfg_hunter_magazinecapacity, m_bag, m_baglimit, m_clock, m_CurrentHState, struct_Hunter::m_efficiency, m_efficiency, struct_Hunter::m_farms, struct_Hunter::m_goosecountchance, m_goosecountchance, struct_Hunter::m_home, m_Home, m_huntingdays, struct_Hunter::m_huntingdayslimit, m_huntlimit, struct_Hunter::m_huntlocrefs, m_HuntLocRefs, struct_Hunter::m_huntlocs, m_HuntLocs, m_lasthuntday, m_myMagazine, m_myname, m_myShots, m_NoHuntLocs, m_OurFarmers, struct_Hunter::m_ref, struct_Hunter::m_weekend, m_weekend, tohts_InitialState, and CfgInt::value().
Referenced by Hunter().
|
inlinevirtual |
Is it hunting season? - MUST be overridden in descendent class.
Reimplemented in GooseHunter.
Definition at line 242 of file Hunters_all.h.
Referenced by st_ShouldGoHunting().
|
inline |
A debug function, but may be useful in other contexts. Returns true of currently out hunting.
Definition at line 223 of file Hunters_all.h.
References m_CurrentHState, and tohts_OutHunting.
Referenced by Hunter_Population_Manager::DoFirst().
|
inlinevirtual |
Is it the end of the hunting season? - MUST be overridden in descendent class.
Reimplemented in GooseHunter.
Definition at line 246 of file Hunters_all.h.
Referenced by Hunter_Population_Manager::DoFirst().
|
inlineprotected |
Uses a probability test to determine whether to go hunting today.
[in] | a_today | The day in the year |
Calculates the season length left, then divides the number of hunting days still needed by this to get a probability of going each day. This probability is scaled to hedge our bets for going earlier in the season. Then a probability test is taken and the value returned as true = go today, or false = don't go To calculate this we need the remaining season length. Then if a weekend hunter this is multiplied by 2/7 to get weekends. We assume that we will hedge our bets to some extent, so the probability is based on scaler*daysneeded/dayspossible e.g. if scaler is 2 and we need 2 days and 10 are left, the chance of going is 2*2/10 per day = 40%.
Definition at line 1158 of file Hunters_all.cpp.
References cfg_hunterhuntdayprobscaler, g_rand_uni, GetSeasonLengthLeft(), m_huntingdays, m_huntlimit, m_weekend, and CfgFloat::value().
Referenced by st_ShouldGoHunting().
|
inlineprotected |
Checks for the hunting day preference (weekday or any day)
[in] | a_today | The day in the year |
Checks whether today is a weekend, if so and weekend hunter then hunt chance today, if not no chance. Otherwise if not a weekend hunter all is good to hunt.
Definition at line 1137 of file Hunters_all.cpp.
References cfg_hunterrefractionperiod, m_lasthuntday, m_weekend, and CfgInt::value().
Referenced by st_ShouldGoHunting().
|
inlinevirtual |
On gohome message handler - must be overidden in descendent classes.
Reimplemented in GooseHunter.
Definition at line 260 of file Hunters_all.h.
|
inline |
Optimism in the morning, perhaps we should hunt?
Definition at line 228 of file Hunters_all.h.
References m_CurrentHState, and tohts_Hunting.
Referenced by Hunter_Population_Manager::DoFirst().
|
inlinevirtual |
On shoot message handler - must be overidden in descendent classes.
Reimplemented in GooseHunter.
Definition at line 258 of file Hunters_all.h.
|
inlinevirtual |
Sets the annual hunting bag to zero.
Reimplemented in GooseHunter.
Definition at line 201 of file Hunters_all.h.
References m_bag, and m_myShots.
Referenced by GooseHunter::ResetBag(), and ResetSeasonData().
|
inline |
Sets the clock back to zero.
Definition at line 214 of file Hunters_all.h.
References m_clock.
Referenced by Hunter_Population_Manager::DoFirst(), and GooseHunter::Init().
|
inline |
Sets the annual hunting attempts count to zero.
Definition at line 206 of file Hunters_all.h.
References m_huntingdays.
Referenced by ResetSeasonData().
|
inline |
Sets the bag and hunting counters to zero.
Definition at line 218 of file Hunters_all.h.
References ResetBag(), and ResetHuntingOpportunities().
Referenced by Hunter_Population_Manager::DoFirst(), and GooseHunter::Init().
|
inlinevirtual |
Each hunter needs to save different kinds of data, so we use a polymorphic method for this.
Reimplemented in GooseHunter.
Definition at line 254 of file Hunters_all.h.
Referenced by Hunter_Population_Manager::DoFirst().
|
protected |
The basic hunting behaviour.
Must not be called, has to be overridden in descendent classes.
Definition at line 1177 of file Hunters_all.cpp.
References tohts_foobar.
|
protected |
Finished hunting and waiting for the next opportunity.
Just stays doing this until called out again by the population manager
Definition at line 1185 of file Hunters_all.cpp.
References tohts_Resting.
Referenced by GooseHunter::Step().
|
protectedvirtual |
Decide whether to go out hunting on a specific day.
This is called at the beginning of each day, if it is decided to go hunting then this is done for each 10 minute period. First check we have not shot our limit this year or done our allocated number of days, if so do nothing.
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.
We've established that it is legal to hunt today but whether the hunter goes depends on how eager he is. This is determined by a probability that is based on the number of days needed to fulfil the hunting day limit, and the number of possible days left in the season. This will also depend on whether they are a weekend hunter or not, and finally whether he checks if there are geese on his hunting locations (done in st_OutHunting ).
When all the days are used up, the hunter will no longer enter this decision process.
Reimplemented in GooseHunter.
Definition at line 1109 of file Hunters_all.cpp.
References InSeason(), IsTodayAChosenHuntDay(), IsTodayAPreferredHuntDay(), m_bag, m_baglimit, m_huntingdays, m_huntlimit, tohts_OutHunting, and tohts_Resting.
Referenced by GooseHunter::st_ShouldGoHunting().
|
protected |
The numbers of game items shot todate this year.
Definition at line 133 of file Hunters_all.h.
Referenced by GetBag(), Init(), GooseHunter::OnShotABird(), ResetBag(), and st_ShouldGoHunting().
|
protected |
Annual self-imposed limit on number shot - unused at present.
Definition at line 143 of file Hunters_all.h.
Referenced by Init(), and st_ShouldGoHunting().
|
protected |
Records the time spent hunting per day.
Definition at line 131 of file Hunters_all.h.
Referenced by GetClock(), Init(), ResetClock(), and GooseHunter::st_OutHunting().
|
protected |
The current hunter behavioural state.
Definition at line 127 of file Hunters_all.h.
Referenced by Init(), IsOutHunting(), GooseHunter::OnGoHome(), OnMorning(), and GooseHunter::Step().
|
protected |
Probability of 'hitting' a game item.
Definition at line 147 of file Hunters_all.h.
Referenced by Init(), GooseHunter::OnShoot(), and GooseHunter::st_OutHunting().
|
protected |
Probability of checking for geese in hunting area.
Definition at line 149 of file Hunters_all.h.
Referenced by GooseHunter::CheckForGame(), and Init().
|
protected |
/brief The home location for the hunter
Definition at line 155 of file Hunters_all.h.
|
protected |
The polygon reference number to our current hunting field (which is at a hunting location)
Definition at line 157 of file Hunters_all.h.
Referenced by GetHuntField(), GooseHunter::OnGoHome(), GooseHunter::OnShoot(), and GooseHunter::st_OutHunting().
|
protected |
The numbers of days used for hunting this year.
Definition at line 139 of file Hunters_all.h.
Referenced by GetHuntingDays(), Init(), IsTodayAChosenHuntDay(), ResetHuntingOpportunities(), GooseHunter::st_OutHunting(), and st_ShouldGoHunting().
|
protected |
Annual self-imposed limit on number of days spent hunting.
Definition at line 145 of file Hunters_all.h.
Referenced by Init(), IsTodayAChosenHuntDay(), and st_ShouldGoHunting().
|
protected |
\ The hunting location ref numbers
Definition at line 161 of file Hunters_all.h.
Referenced by Init().
|
protected |
\ The hunting locations centroid of the farm held in m_OurFarmer
Definition at line 163 of file Hunters_all.h.
Referenced by GetHuntLoc(), and Init().
|
protected |
The date for the last hunt day.
Definition at line 141 of file Hunters_all.h.
Referenced by Init(), IsTodayAPreferredHuntDay(), and GooseHunter::st_OutHunting().
|
protected |
The number of shells in the magazine.
Definition at line 137 of file Hunters_all.h.
Referenced by Init(), and GooseHunter::st_OutHunting().
|
protected |
A reference number unique to this hunter.
Definition at line 125 of file Hunters_all.h.
Referenced by GetRef(), Init(), GooseHunter::OnShotABird(), and GooseHunter::SaveMyData().
|
protected |
The numbers of shots to-date this year.
Definition at line 135 of file Hunters_all.h.
Referenced by GetShots(), Init(), GooseHunter::OnShoot(), ResetBag(), and GooseHunter::st_OutHunting().
|
protected |
/brief The number of farms he can hunt on
Definition at line 159 of file Hunters_all.h.
Referenced by Init(), and GooseHunter::Init().
|
protected |
List of pointers to the farmers whose land the hunter hunts
Definition at line 153 of file Hunters_all.h.
Referenced by GetFarmerRef(), GooseHunter::GooseHunter(), Init(), and GooseHunter::Init().
|
protected |
Pointer to the population manager.
Definition at line 129 of file Hunters_all.h.
Referenced by GooseHunter::GetSeasonLengthLeft(), Hunter(), GooseHunter::InSeason(), GooseHunter::IsSeasonEnd(), GooseHunter::OnShotABird(), and GooseHunter::st_OutHunting().
|
protected |
Code for weekly hunting activity.
Definition at line 151 of file Hunters_all.h.
Referenced by Init(), IsTodayAChosenHuntDay(), and IsTodayAPreferredHuntDay().