Goose Management Model ODdox
1.02
|
Go to the documentation of this file.
34 #define __DEBUG_DENSITY
42 #include "../Landscape/ls.h"
43 #include "../BatchALMaSS/PopulationManager.h"
44 #include "../GooseManagement/GooseMemoryMap.h"
45 #include "../GooseManagement/Goose_Base.h"
46 #include "../BatchALMaSS/CurveClasses.h"
47 #include "../Hunters/Hunters_all.h"
48 #include "../GooseManagement/Goose_Population_Manager.h"
49 #include "../GooseManagement/GoosePinkFooted_All.h"
50 #include "../GooseManagement/GooseGreylag_All.h"
51 #include "../GooseManagement/GooseBarnacle_All.h"
53 #include "../BatchALMaSS/BoostRandomGenerators.h"
56 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> >
g_rand_uni;
57 extern boost::variate_generator<base_generator_type&, boost::uniform_int<> >
g_rand_uni2;
122 m_ListNames[0] =
"Goose Hunter";
123 m_ListNameLength = 1;
125 for (
unsigned i=0; i<(10-m_ListNameLength); i++)
129 BeforeStepActions[ 0 ] = 4;
156 ifstream huntercoords(
"./HunterHomeLocations.txt", ios::in);
157 if (!huntercoords.is_open()) {
158 m_TheLandscape->Warn(
"Hunter_Population_Manager::DistributeHunters()",
"HunterHomeLocations.txt missing" );
162 huntercoords >> no_hunters;
163 vector<HunterInfo>* OurHunters =
new vector<HunterInfo>;
164 OurHunters->resize( no_hunters );
165 for (
int i = 0; i < no_hunters; i++)
167 huntercoords >> (*OurHunters)[ i ].refID >> (*OurHunters)[ i ].homeX >> (*OurHunters)[ i ].homeY;
173 for (
int hl = 0; hl<(*OurHunters)[i].FarmHuntRef.size(); hl++) (*OurHunters)[i].FarmHuntRef[hl] = -1;
176 huntercoords.close();
182 g_msg->
Warn(
"Normal exit after hunter distribution. No of records written to Hunter_Hunting_Locations.txt was: ", no_hunters);
200 ofstream huntlocs(
"./Hunter_Hunting_Locations.txt", ios::out);
201 huntlocs << a_no_hunters << endl;
202 huntlocs <<
"HunterID" <<
'\t' <<
"HunterType" <<
'\t' <<
"HuntingDays" <<
'\t' <<
"WeekdayHunterChance" <<
'\t' <<
"GooseLookChance" <<
'\t' <<
"Efficiency" <<
'\t';
203 huntlocs <<
"HomeX" <<
'\t' <<
"HomeY" <<
'\t';
204 huntlocs <<
"NoFarmrefs" <<
'\t' <<
"FarmRef1" <<
'\t' <<
"FarmRef2" <<
'\t' <<
"FarmRef3" <<
'\t' <<
"FarmRef4" <<
'\t' <<
"FarmRef5" <<
'\t' <<
"FarmRef6" <<
'\t' <<
"FarmRef7" <<
'\t' <<
"FarmRef8" <<
'\t' <<
"FarmRef9" <<
'\t' <<
"FarmRef10" << endl;
208 for (
int i = 0; i < a_no_hunters; i++)
210 int nolocs = int((*a_hunterlist)[i].FarmHuntRef.size());
211 huntlocs << (*a_hunterlist)[ i ].refID <<
'\t' << 0 <<
'\t' << 0 <<
'\t' << 0 <<
'\t' << 0 <<
'\t' << 0 <<
'\t';
212 huntlocs << (*a_hunterlist)[ i ].homeX <<
'\t' << (*a_hunterlist)[ i ].homeY <<
'\t' << nolocs;
213 for (
int j = 0; j < nolocs; j++)
215 int ref = (*a_hunterlist)[ i ].FarmHuntRef[ j ];
224 huntlocs <<
'\t' << ref;
226 for (
int j = 10; j > nolocs; j--) huntlocs <<
'\t' <<
"NA";
234 FarmManager* FManager = m_TheLandscape->SupplyFarmManagerPtr();
235 ofstream huntlocs(
"./Hunter_Hunting_Locations_Farms.txt", ios::out);
236 huntlocs <<
"FarmRef" <<
'\t' <<
"FarmCentroidX" <<
'\t' <<
"FarmCentroidY" <<
'\t' <<
"FarmType" <<
'\t' <<
"FarmSize" <<
'\t'
237 <<
"FarmArableSize" <<
'\t' <<
"NoFields" <<
'\t' <<
"NoOpenFields" <<
'\t' <<
"AreaOpenFields" <<
'\t' <<
"NoHunters" << endl;
238 vector<farminfo*> FarmList;
239 for (
int i = 0; i < a_no_hunters; i++)
241 for (
int j = 0; j < (*a_hunterlist)[ i ].FarmHuntRef.size(); j++)
243 int ref = (*a_hunterlist)[ i ].FarmHuntRef[ j ];
245 for (
int f = 0; f < (int)FarmList.size(); f++) {
246 if (FarmList[f]->m_farmref == ref) {
261 fi->
m_farmref = (*a_hunterlist)[ i ].FarmHuntRef[ j ];
263 FarmList.push_back(fi);
265 else FarmList[found]->m_NoHunters++;
270 for (
int fa = 0; fa < nofarms; fa++) {
275 for (
int hf = 0; hf < FarmList.size( ); hf++)
277 if (FarmList[hf]->m_farmref == ref) {
279 cout << ref <<
'\t' << found << endl;
285 huntlocs << ref <<
'\t' << pt.m_x <<
'\t' << pt.m_y <<
'\t' << FManager->
GetFarmType(ref) <<
'\t' << FManager->
GetFarmTotalSize(ref) <<
'\t'
290 huntlocs << ref <<
'\t' << FarmList[found]->m_farmcentroid.m_x <<
'\t' << FarmList[found]->m_farmcentroid.m_y <<
'\t' << FarmList[found]->m_farmtype <<
'\t' << FarmList[found]->m_farmsize <<
'\t'
291 << FarmList[found]->m_farmarable <<
'\t' << FarmList[found]->m_nofields <<
'\t' << FarmList[found]->m_openfields <<
'\t' << FarmList[found]->m_areaopenfields <<
'\t' << FarmList[found]->m_NoHunters << endl;
309 FarmManager* FManager = m_TheLandscape->SupplyFarmManagerPtr();
314 for (
int f = 0; f < a_FarmOccupancy->size(); f++) {
316 if ((*a_FarmOccupancy)[f].m_FarmRef == a_ref) {
317 double newhunters = (*a_FarmOccupancy)[f].m_no_hunters + 1.0;
319 (*a_FarmOccupancy)[f].m_no_hunters++;
340 a_FarmOccupancy->push_back(pt);
364 FarmManager* FManager = m_TheLandscape->SupplyFarmManagerPtr();
372 for (
int i = 0; i < a_no_hunters; i++)
375 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++)
382 (*a_hunterlist)[i].FarmHuntRef[h] = theref;
386 else if (a_ruleset == 1)
389 vector<int>* list =
new vector<int>;
392 for (
int i = 0; i < a_no_hunters; i++)
395 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++)
398 (*a_hunterlist)[i].FarmHuntRef[h] = FManager->
FindClosestFarm((*a_hunterlist)[i], &list[0]);
402 else if (a_ruleset == 2)
405 for (
int i = 0; i < a_no_hunters; i++)
408 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++)
415 (*a_hunterlist)[i].FarmHuntRef[h] = theref;
419 else if (a_ruleset == 3)
422 vector<int>* illegalfarms =
new vector<int>;
423 vector<FarmOccupcancyData>* FarmOccupancy =
new vector<FarmOccupcancyData>;
424 for (
int i = 0; i < a_no_hunters; i++)
426 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++)
440 found1 =
CheckDensity(theref, illegalfarms, FarmOccupancy);
443 (*a_hunterlist)[i].FarmHuntRef[h] = theref;
444 #ifdef __DEBUG_DENSITY
446 double nohunters = 0;
447 for (
int g = 0; g < a_no_hunters; g++)
450 for (
int hs = 0; hs < int((*a_hunterlist)[g].FarmHuntRef.size()); hs++)
452 if ((*a_hunterlist)[g].FarmHuntRef[hs] == theref) nohunters++;
460 for (
int frm = 0; frm < FarmOccupancy->size(); frm++)
464 for (
int g = 0; g < a_no_hunters; g++)
467 for (
int hs = 0; hs < int((*a_hunterlist)[g].FarmHuntRef.size()); hs++)
469 if ((*a_hunterlist)[g].FarmHuntRef[hs] == (*FarmOccupancy)[frm].m_FarmRef) nohunters++;
472 if ((*FarmOccupancy)[frm].m_no_hunters != nohunters)
483 else if (a_ruleset == 4)
486 vector<int>* list =
new vector<int>;
489 for (
int i = 0; i < a_no_hunters; i++)
491 for (
int f = 0; f < int((*a_hunterlist)[i].FarmHuntRef.size()); f++)
497 else if (a_ruleset == 5) {
502 vector<int>* illegalfarms =
new vector<int>;
503 vector<FarmOccupcancyData>* FarmOccupancy =
new vector<FarmOccupcancyData>;
506 for (
int i = 0; i < a_no_hunters; i++) {
507 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++)
522 found1 =
CheckDensity(theref, illegalfarms, FarmOccupancy);
524 (*a_hunterlist)[i].FarmHuntRef[h] = theref;
525 #ifdef __DEBUG_DENSITY
527 double nohunters = 0;
528 for (
int g = 0; g < a_no_hunters; g++)
531 for (
int hs = 0; hs < int((*a_hunterlist)[g].FarmHuntRef.size()); hs++)
533 if ((*a_hunterlist)[g].FarmHuntRef[hs] == theref) nohunters++;
541 for (
int frm = 0; frm < FarmOccupancy->size(); frm++)
545 for (
int g = 0; g < a_no_hunters; g++)
548 for (
int hs = 0; hs < int((*a_hunterlist)[g].FarmHuntRef.size()); hs++)
550 if ((*a_hunterlist)[g].FarmHuntRef[hs] == (*FarmOccupancy)[frm].m_FarmRef) nohunters++;
553 if ((*FarmOccupancy)[frm].m_no_hunters != nohunters)
563 else if (a_ruleset == 6) {
565 vector<int>* illegalfarms =
new vector<int>;
566 vector<FarmOccupcancyData>* FarmOccupancy =
new vector<FarmOccupcancyData>;
570 for (
int i = 0; i < a_no_hunters; i++) {
571 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++) {
577 if (++iteration > Farms) {
589 if (illegalfarms->size() >= Farms - ((*a_hunterlist)[ i ].FarmHuntRef.size())) {
594 found1 =
CheckDensity(theref, illegalfarms, FarmOccupancy);
596 (*a_hunterlist)[i].FarmHuntRef[h] = theref;
597 #ifdef __DEBUG_DENSITY
599 double nohunters = 0;
600 for (
int g = 0; g < a_no_hunters; g++)
603 for (
int hs = 0; hs < int((*a_hunterlist)[g].FarmHuntRef.size()); hs++)
605 if ((*a_hunterlist)[g].FarmHuntRef[hs] == theref) nohunters++;
613 for (
int frm = 0; frm < FarmOccupancy->size(); frm++)
617 for (
int g = 0; g < a_no_hunters; g++)
620 for (
int hs = 0; hs < int((*a_hunterlist)[g].FarmHuntRef.size()); hs++)
622 if ((*a_hunterlist)[g].FarmHuntRef[hs] == (*FarmOccupancy)[frm].m_FarmRef) nohunters++;
625 if ((*FarmOccupancy)[frm].m_no_hunters != nohunters)
636 else if (a_ruleset == 7) {
641 vector<int>* illegalfarms =
new vector<int>;
642 vector<FarmOccupcancyData>* FarmOccupancy =
new vector<FarmOccupcancyData>;
645 for (
int i = 0; i < a_no_hunters; i++)
647 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++)
662 found1 =
CheckDensity(theref, illegalfarms, FarmOccupancy);
664 (*a_hunterlist)[i].FarmHuntRef[h] = theref;
665 #ifdef __DEBUG_DENSITY
667 double nohunters = 0;
668 for (
int g = 0; g < a_no_hunters; g++)
671 for (
int hs = 0; hs < int((*a_hunterlist)[g].FarmHuntRef.size()); hs++)
673 if ((*a_hunterlist)[g].FarmHuntRef[hs] == theref) nohunters++;
681 for (
int frm = 0; frm < FarmOccupancy->size(); frm++)
685 for (
int g = 0; g < a_no_hunters; g++)
688 for (
int hs = 0; hs < int((*a_hunterlist)[g].FarmHuntRef.size()); hs++)
690 if ((*a_hunterlist)[g].FarmHuntRef[hs] == (*FarmOccupancy)[frm].m_FarmRef) nohunters++;
693 if ((*FarmOccupancy)[frm].m_no_hunters != nohunters)
703 else if (a_ruleset == 8) {
705 vector<int>* list =
new vector<int>;
708 for (
int i = 0; i < a_no_hunters; i++) {
709 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++) {
714 else if (a_ruleset == 9) {
716 vector<int>* list =
new vector<int>;
719 for (
int i = 0; i < a_no_hunters; i++) {
720 for (
int h = 0; h < int((*a_hunterlist)[i].FarmHuntRef.size()); h++) {
725 else if (a_ruleset == 10) {
729 else if (a_ruleset == 11) {
733 vector<int>* farmsizes =
new vector<int>;
735 ifstream ifile(
"FarmTotalSizeData.txt", ios::in );
737 if (!ifile.is_open()) {
738 cout <<
"Cannot open input file " <<
"FarmTotalSizeData.txt" << endl;
746 if (noFarms != m_TheLandscape->SupplyNumberOfFarms()) {
747 cout <<
"Number of farms does not match farm number in ALMaSS " << noFarms <<
" != " << m_TheLandscape->SupplyNumberOfFarms() << endl;
753 for (
int f = 0; f < noFarms; f++) {
757 farmsizes->push_back( data );
761 RuleSet10Based( a_no_hunters, farmsizes, a_hunterlist, NULL, 11 );
764 else if (a_ruleset == 12) {
769 vector<APoint>* roostlocs =
new vector<APoint>;
771 ifstream ifile(
"GooseRoosts.txt", ios::in );
773 if (!ifile.is_open()) {
774 cout <<
"Cannot open input file " <<
"GooseRoosts.txt" << endl;
783 for (
int r = 0; r < noroosts; r++) {
786 ifile >> species >> data.m_x >> data.m_y;
787 roostlocs->push_back( data );
791 RuleSet10Based( a_no_hunters, NULL, a_hunterlist, roostlocs, 12 );
801 FarmManager* FManager = m_TheLandscape->SupplyFarmManagerPtr();
802 vector<int>* illegalfarms =
new vector<int>;
803 vector<FarmOccupcancyData>* FarmOccupancy =
new vector<FarmOccupcancyData>;
804 for (
int i = 0; i < a_no_hunters; i++) {
805 for (
int h = 0; h < int( (*a_hunterlist)[ i ].FarmHuntRef.size() ); h++) {
816 if (a_ruleset == 10) {
818 found1 =
CheckDensity( theref, illegalfarms, FarmOccupancy );
820 else if (a_ruleset == 11) {
823 found1 =
CheckDensity( theref, illegalfarms, FarmOccupancy );
825 else if (a_ruleset == 12) {
828 found1 =
CheckDensity( theref, illegalfarms, FarmOccupancy );
831 (*a_hunterlist)[ i ].FarmHuntRef[ h ] = theref;
852 sh.
m_L = m_TheLandscape;
853 ifstream hunterinifile(
"./Hunter_Hunting_Locations.txt", ios::in);
854 if (!hunterinifile.is_open()) {
855 m_TheLandscape->Warn(
"Hunter_Population_Manager::Init",
"Hunter_Hunting_Locations.txt missing" );
858 hunterinifile >> no_hunters;
861 for (
int i = 0; i < 19; i++) hunterinifile >> line;
862 if (line !=
"FarmRef10") {
863 m_TheLandscape->Warn(
"Hunter_Population_Manager::Init",
"Header line missing from Hunter_Hunting_Locations.txt" );
879 for (
int h = 0; h < no_hunters; h++)
885 sh.
m_farms.resize(no_huntlocs);
888 for (
int i = 0; i < no_huntlocs; i++)
891 APoint fp = m_TheLandscape->SupplyFarmManagerPtr()->GetFarmCentroid( sh.
m_huntlocrefs[ i ] );
897 for (
int i = 0; i < 10-no_huntlocs; i++)
899 hunterinifile >> line;
904 g_msg->
Warn(
"Hunter_Population_Manager::Init unknown hunter type: ", sh.
m_HType);
909 hunterinifile.close();
916 (*m_HuntingBagRecord) <<
"Year" <<
'\t' <<
"Day" <<
'\t' <<
"Hour" <<
'\t' <<
"Minute" <<
'\t' <<
"Season" <<
'\t' <<
917 "HunterRef" <<
'\t' <<
"PolygonRef" <<
'\t' <<
"x-coord" <<
'\t' <<
"y-coord" <<
'\t' <<
"GameType" << endl;
919 ofstream ofile(
"HuntingOpportunities.txt", ios::out);
920 ofile <<
"Year" <<
'\t' <<
"HunterRef" <<
'\t' <<
"HuntingDays" <<
'\t' <<
"TotalBag" <<
'\t' <<
"NumberOfShots" <<
'\t' <<
921 "GameType0" <<
'\t' <<
"GameType1" <<
'\t' <<
"GameType2" <<
'\t' <<
"GameType3" <<
'\t' <<
"GameType4" <<
'\t' <<
"GameType5" << endl;
928 for (
int i=0; i<a_number; i++)
935 TheArray[a_ob_type].push_back(GHunter);
939 sprintf( ob,
"%d", (
int) a_ob_type);
940 m_TheLandscape->Warn(
"Goose_Population_Manager::CreateObjects() unknown object type - ", ob);
949 int today = m_TheLandscape->SupplyDayInYear();
954 for (
unsigned i=0; i<m_ListNameLength; i++)
956 int sz = (int) TheArray[i].size();
957 for (
int j=0; j<sz; j++)
963 g_msg->
Warn(
"Hunter_Population_Manager::DoFirst() - hunter out hunting at midnight at ref ", h->
GetHuntField());
964 g_msg->
Warn(
"Hunter_Population_Manager::DoFirst() - hunter clock is ", h->
GetClock());
965 g_msg->
Warn(
"Hunter_Population_Manager::DoFirst() - hunter is leader ", h->
IsLeader());
966 g_msg->
Warn(
"Day in year is: ", m_TheLandscape->SupplyDayInYear());
967 g_msg->
Warn(
"Year is: ", m_TheLandscape->SupplyYearNumber());
980 for (
unsigned i = 0; i < m_ListNameLength; i++) {
981 if ((
int)TheArray[ i ].size() > 0) {
983 if (h->
IsSeasonEnd( today ) && m_SeasonNumber > 0) {
984 ofstream ofile(
"HuntingOpportunities.txt", ios::app | ios::out);
985 int year = m_TheLandscape->SupplyYearNumber()-1;
986 int sz = (int)TheArray[ i ].size();
987 for (
int j = 0; j < sz; j++) {
988 h = (
Hunter*)TheArray[ i ][ j ];
989 ofile << year <<
'\t';
999 if (today == 183 &&
m_daytime == 1430) m_SeasonNumber++;
1008 APoint pt = m_TheLandscape->SupplyCentroid(a_poly);
1009 (*m_HuntingBagRecord) << m_TheLandscape->SupplyYear() <<
'\t' << m_TheLandscape->SupplyDayInYear() <<
'\t' <<
g_date->
GetHour() <<
'\t' <<
1010 g_date->
GetMinute() <<
'\t' << GetSeasonNumber() <<
'\t' << a_hunter <<
'\t' << a_poly <<
'\t' << pt.m_x <<
'\t' << pt.m_y <<
'\t' << a_birds << endl;
1018 return dynamic_cast<Hunter*>(TheArray[a_list][a_index])->GetHome();
1023 return dynamic_cast<Hunter*>(TheArray[a_list][a_index])->GetHuntLoc(a_ref);
1048 g_msg->
Warn(
"Hunter_Population_Manager::HunterLeaderMessage unknown leader message: ", a_signal);
1055 g_msg->
Warn(
"Hunter_Population_Manager::HunterLeaderMessage polyref does not match any of the active polygons in list: ", a_polyref);
1119 int day = m_OurLandscape->SupplyDayInYear();
1148 if (a_today % 7 > 4)
return true;
else return false;
1171 if (
m_weekend == 0) seasonleft *= 2.0 / 7.0;
1242 int thepolyref = (*m_huntfields)[int(
g_rand_uni()*sz)];
1249 for (
int hfield = 0; hfield < sz; hfield++) {
1250 int geese = m_OurLandscape->GetQuarryNumbers((*
m_huntfields)[hfield]);
1251 if (geese > maxgeese) {
1253 polyref = (*m_huntfields)[hfield];
1263 m_OurLandscape->Warn(
"GooseHunter::IsSeasonEnd()",
"Hunting season end at day 365. First day of the year is 0 hence last day of year is 364");
1266 if (day == 1 + end)
return true;
1267 if (day == 0 && end == 364)
return true;
1283 if ((day <
start) && (day > end))
return false;
1290 if (day < start || day > end)
return false;
1304 if (day >=
start) left = (365 - day) + end;
1305 else left = end - day;
1311 if (left < 0)
return 0;
1378 double shootingchance = 1.0;
1385 if ((birds > 0) && (
g_rand_uni() < shootingchance) ) {
1395 if ((birds > i) || (numbershot == 0))
1401 if (numbershot > 0) {
1433 if (numbershot > 0) {
1448 if (m_StepDone || m_CurrentStateNo == -1)
return;
1464 m_OurLandscape->Warn(
"GooseHunter::Step()",
"unknown state - default");
1492 p_newhunterlist->push_back( a_hunter );
1505 if (end1 > start1 && end2 > start2) {
1513 if (start1 > end1 && start2 < end2)
1518 if (start1 < end1 && start2 > end2)
1523 if (start1 > end1 && start2 > end2)
1531 if (start1 > start2)
int m_pinkfootbaglimit
Bag limit for pinkfoot.
boost::variate_generator< base_generator_type &, boost::uniform_int<> > g_rand_uni2
static CfgInt cfg_Hunters_NonresidentPct("HUNTERS_NONRESIDENTPCT", CFG_CUSTOM, 30)
Number of hunters living out of area as a percentage of local hunters.
void BangAtPoly(int a_polyref)
Passes a 'Bang' message to birds near to the location specified by the polygon reference.
int GetFarmNoOpenFields(int a_farmref, int a_openness)
Returns the number of fields with openness more than a_openness.
unsigned GetNoHuntLocs()
Calculates the number of hunting locations based on a distribution.
Goose_Population_Manager * m_preyPopulationManger
Pointer to our game population, the geese.
APoint GetFarmValidCoords(int a_farmref)
Returns the number of fields owned by a from the farm ref num.
bool IsOutHunting()
A debug function, but may be useful in other contexts. Returns true of currently out hunting.
vector< unsigned > polylist
PopulationManagerList g_PopulationManagerList
int GetFarmTotalSize(int a_farmref)
Returns the total farm area from the farm ref num.
void SetHuntingSeason()
This returns the number of geese which are legal quarry on the polygon the day before.
static CfgInt cfg_gooseopenseasonend("GOOSE_OPENSEASON_END", CFG_CUSTOM, 364)
The end of the goose open season. Legal values are 0 to 364.
virtual void OnShoot()
On shoot message handler.
virtual void Init()
Initiation of a specific goose hunter here.
bool m_leader
When hunting this indicates whether the hunter is a team leader.
int m_baglimit
Annual self-imposed limit on number shot - unused at present.
int FindClosestFarmOpennessProbSmallIsBest(HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness, vector< int > *a_farmsizelist)
Finds the closest farm to this co-ordinate with openness more than a value but uses a probability dis...
int m_HuntingSeasonStart
Start of the overall hunting season.
int m_weekend
Code for weekly hunting activity.
The class to handle all predator population related matters.
int FindClosestFarmOpenness(HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness)
Finds the closest farm to this co-ordinate but uses a probability distribtution for acceptance.
void AddToIllegalList(int a_farm_ref, vector< int > *a_farmlist)
Add to a list if a farm is not already among the illegal list of references.
bool IsTodayAPreferredHuntDay(int a_today)
Checks for the hunting day preference (weekday or any day)
int m_huntfield_polyref
The polygon reference number to our current hunting field (which is at a hunting location)
virtual bool IsSeasonEnd(int)
Is it the end of the hunting season? - MUST be overridden in descendent class.
void DistributeHunters(void)
Distributes hunters to hunting locations (farms).
GooseHunter(struct_Hunter *p_data, Hunter_Population_Manager *p_PPM)
GooseHunter constructor.
static CfgFloat cfg_Hunters_MaxDensity("HUNTERS_MAXDENSITY", CFG_CUSTOM, 0.1)
Maximum hunter density per ha.
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
static CfgInt cfg_largefieldgooseproximitysizecutoff("HUNTER_LARGEFIELDGOOSEPROXIMITYCHANCESIZECUTOFF", CFG_CUSTOM, 20000)
The size of the field which will trigger the use of cfg_largefieldgooseproximity.
bool IsLeader()
Returns the leader flag.
Population_Manager * m_preyPM
vector< int > m_huntlocrefs
int GetFarmAreaOpenFields(int a_farmref, int a_openness)
Returns the area of fields with openness more than a_openness.
TypeOfHunterState st_OutHunting(void)
The basic hunting behaviour.
virtual bool IsSeasonEnd(int day)
Is it the end of the goose hunting season? - MUST be overridden in descendent class.
void HunterLeaderMessage(TypeOfHunterLeaderMessage a_signal, int a_polyref)
A message system to rely messages from the leader hunter to others in his team.
int m_huntingdays
The numbers of days used for hunting this year.
int GetShots()
Gets the number of shots this season to-date.
static CfgBool cfg_Hunters_Distribute("HUNTERS_DISTRIBUTE", CFG_CUSTOM, false)
Should we enter hunter distribution mode?
static CfgFloat cfg_Hunters_MaxDensityPower("HUNTERS_MAXDENSITYPOWER", CFG_CUSTOM, 0.741)
Maximum hunter density per ha - power parameter.
int m_lasthuntday
The date for the last hunt day.
bool m_dugin
Flag to show whether a hunting location has been found.
int m_huntlimit
Annual self-imposed limit on number of days spent hunting.
int GetBag()
Gets the annual hunting bag.
CfgInt cfg_goose_greylagopenseasonstart
The start of the greylag hunting season.
int FindFarmWithRandom(vector< int > *a_farmlist)
Finds a farm openness more than a value not on the list.
TypeOfHunterState
Hunters like other ALMaSS animals work using a state/transition concept. These are the hunter behavio...
virtual TypeOfHunterState st_ShouldGoHunting(void)
Decide whether to go out hunting on a specific day.
vector< Farm * > m_OurFarmers
List of pointers to the farmers whose land the hunter hunts
int FindFarmWithOpenness(vector< int > *a_farmlist, int a_openness)
Finds a farm openness more than a value not on the list.
static CfgBool cfg_Hunters_RecordBag("HUNTERS_RECORDBAG", CFG_CUSTOM, false)
Should we record the birds shot?
TypeOfHunterLeaderMessage
Types of message a hunter leader can pass on to team members.
static CfgInt cfg_hunter_pinkfootbaglimit("HUNTER_PINKFOOTBAGLIMIT", CFG_CUSTOM, 9999)
The pinkfoot hunting bag limit.
Hunter(struct_Hunter *p_data, Hunter_Population_Manager *p_PPM)
The constructor for the Hunter class.
virtual int CheckForGame(void)
If the hunter checks for game at their hunting locations then this is done here. Must be overridden.
Farm * GetFarmPtrIndex(int a_index)
Returns the pointer to a farm with a specific index.
static CfgInt cfg_huntlength("GOOSE_HUNTER_HUNT_LENGTH", CFG_CUSTOM, 180)
The default length of hunting.
The landscape class containing all environmental and topographical data.
Used during saving farm/hunter information.
APoint GetHunterHuntLoc(int a_index, int a_list, unsigned a_ref)
Returns the hunter hunting location location.
virtual ~Hunter()
The destructor for the Hunter class.
virtual void SaveMyData(ofstream *a_ofile)
Each hunter needs to save different kinds of data, so we use a polymorphic method for this.
virtual ~Hunter_Population_Manager(void)
Hunter population manager destructor.
void CreateObjects(int ob_type, TAnimal *, struct_Hunter *data, int number)
Creates hunter objects and assigns them to the population manager lists.
bool IsPolyrefOnActiveList(int a_polyref)
Debugging check method.
CfgFloat cfg_goose_MinForageOpenness
The minimum openness score that a goose will tolerate for foraging.
static CfgFloat cfg_hunterlocTWO("HUNTERS_HUNTERLOCPROB_TWO", CFG_CUSTOM, 0.616)
The cumulative probability of hunters having up to 2 hunter locations.
TypeOfHunterState st_OutHunting(void)
The basic hunting behaviour.
Bool configurator entry class.
virtual int GetSeasonLengthLeft(int day)
Returns the length of the hunting season in days - MUST be overridden in descendent class.
static CfgInt cfg_gooseopenseasonstart("GOOSE_OPENSEASON_START", CFG_CUSTOM, 243)
The start of the goose open season.
Hunter_Population_Manager * m_OurPopulationManager
Pointer to the population manager.
vector< APoint > m_HuntLocs
static CfgFloat cfg_hunterhuntdayprobscaler("HUNTER_HUNTDAYPROBSCALER", CFG_CUSTOM, 2.0)
Hedging bets scaler to the probability of going hunting on a particular day.
virtual TypeOfHunterState st_ShouldGoHunting(void)
Behavior involved in deciding whether to go hunting.
int GetFarmArableSize(int a_farmref)
Returns the arable area from the farm ref num.
static CfgFloat cfg_hunterlocTHREE("HUNTERS_HUNTERLOCPROB_THREE", CFG_CUSTOM, 0.806)
The cumulative probability of hunters having up to 3 hunter locations.
void Init(void)
Create the initial hunter population and initializes any output options.
polylist * m_huntfields
Our list of possible hunting fields as polygon reference numbers as supplied by Landscape::SupplyPoly...
int m_myMagazine
The number of shells in the magazine.
vector< int > m_ActiveHuntingLocationsPolyrefs
Lists of polygon reference numbers for all active hunting locations (updated daily)
int GetClock()
Supplies the clock time.
int GetHuntField()
Get the polygon reference number to our current hunting field (which is at a hunting location)
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
int GetHuntingDays()
Gets the annual hunting attempts count.
void SaveDistributedHunters(vector< HunterInfo > *a_hunterlist, int a_no_hunters)
Saves the results of the hunter distribution to an output file.
int m_myname
A reference number unique to this hunter.
int FindClosestFarm(HunterInfo a_hinfo, vector< int > *a_farmlist)
Finds the closest farm to this co-ordinate.
void SaveFarmHunters(vector< HunterInfo > *a_hunterlist, int a_no_hunters)
Saves the results of the hunter distribution to an output file by farm.
void BirdsShot(int a_polyref, int a_numbershot, GooseHunter *a_Hunter)
Passes the message to shoot a number of birds at a forage location.
int FindClosestFarmOpennessProbNearRoostIsBest(HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness, vector< APoint > *a_farmsizelist)
Finds the closest farm to this co-ordinate with openness more than a value but uses a probability dis...
double m_goosecountchance
Probability of checking for geese in hunting area.
static CfgFloat cfg_hunterlocFOUR("HUNTERS_HUNTERLOCPROB_FOUR", CFG_CUSTOM, 0.854)
The cumulative probability of hunters having up to 4 hunter locations.
The base class for hunters encompsassing all their general behaviours.
virtual ~GooseHunter()
GooseHunter destructor.
virtual void DoFirst()
Does general daily tasks e.g. reset time of day, reset bag lists if start of year etc....
CfgInt cfg_goose_greylagopenseasonend
The end of the greylag hunting season.
void OnMorning()
Optimism in the morning, perhaps we should hunt?
virtual int GetSeasonLengthLeft(int)
Returns the length of the hunting season in days - MUST be overridden in descendent class.
static CfgInt cfg_hunter_magazinecapacity("HUNTER_MAGAZINECAPACITY", CFG_CUSTOM, 2)
The number of shots a hunter can take per shooting event.
int m_goosebag[gst_foobar]
A special bag data structure so the hunter knows what kind of geese he shot.
int m_myShots
The numbers of shots to-date this year.
vector< APoint > m_huntlocs
int m_greylagbaglimit
Bag limit for greylag.
virtual void Step()
GooseHunter Step code.
vector< Hunter * > HunterList
virtual void OnGoHome()
On gohome message handler.
vector< int > m_HuntLocRefs
int FindOpennessFarm(int a_openness)
Finds a random farm with at least one field with openness above a_openness.
unsigned m_daytime
Used to follow the time of day in 10 minute steps.
bool IsDuplicateRef(int a_ref, HunterInfo *a_hinfo)
Checks if we already have this ref.
TypeOfHunterState m_CurrentHState
The current hunter behavioural state.
void RecordHuntingSuccess(int poly, int birds, int a_hunter)
Hunting bag output.
TTypesOfFarm GetFarmType(int a_farmref)
Returns the farm type from the farm ref num.
int GetHuntingSeasonEnd()
Get the end of the overall hunting season.
int GetHuntingSeasonStart()
Get the start of the overall hunting season.
int FindClosestFarmOpennessProb(HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness)
Finds the closest farm to this co-ordinate with openness more than a value but uses a probability dis...
CfgInt cfg_goose_pinkfootopenseasonend
The end of the pinkfoot hunting season.
Integer configurator entry class.
Used for creation of a new hunter object.
bool IsTodayAChosenHuntDay(int a_today)
Uses a probability test to determine whether to go hunting today.
static CfgFloat cfg_hunterlocONE("HUNTERS_HUNTERLOCPROB_ONE", CFG_CUSTOM, 0.297)
The probability of hunters having one hunter location.
The base class for all farm types.
ofstream * m_HuntingBagRecord
Output file for hunting bag record.
MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
static CfgFloat cfg_huntermaxprotectedpct("HUNTER_MAXPROTECTECTEDPCT", CFG_CUSTOM, 0.1)
The proportion of protected species in a flock above which there is no shooting
Double configurator entry class.
APoint GetHunterHome(int a_index, int a_list)
Returns the hunter home location.
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.
APoint GetFarmCentroid(int a_farmref)
Gets the farm centroid as an APoint.
static CfgInt cfg_hunterrefractionperiod("HUNTER_REFRACTIONPERIOD", CFG_CUSTOM, 7)
The number of days rest between going hunting.
int GetRandomFarmRefnum()
Returns a random farm reference number.
double m_goosecountchance
static CfgInt cfg_Hunters_Distribute_Ruleset("HUNTERS_DISTRIBUTE_RULESET", CFG_CUSTOM, 0)
The rule set to use for distributing hunters.
void ResetSeasonData()
Sets the bag and hunting counters to zero.
Hunter_Population_Manager(Landscape *p_L)
Hunter population manager constructor.
int GetFarmNoFields(int a_farmref)
Returns the number of fields owned by a from the farm ref num.
static CfgInt cfg_hunter_greylagbaglimit("HUNTER_GREYLAGBAGLIMIT", CFG_CUSTOM, 9999)
The greylag hunting bag limit.
static CfgInt cfg_Hunters_Distribute_NonResRuleset("HUNTERS_DISTRIBUTE_NONRESRULESET", CFG_CUSTOM, 0)
The rule set to use for distributing non-resident hunters.
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
int m_HuntingSeasonEnd
End of the overall hunting season.
vector< HunterList * > m_ActiveHuntingLocationsHunters
Lists of hunters at all active hunting locations (updated daily)
void ResetClock()
Sets the clock back to zero.
static CfgFloat cfg_largefieldgooseproximity("HUNTER_LARGEFIELDGOOSEPROXIMITYCHANCE", CFG_CUSTOM, 0.5)
The likelihood that geese are close enough to shoot on large fields
int m_clock
Records the time spent hunting per day.
void CalcCentroids()
calculate all farm centroids
int BirdsToShootAtPoly(int a_poly)
Returns the number of birds at a forage location - given by a poly ref.
int m_bag
The numbers of game items shot todate this year.
TypeOfHunterState st_Resting(void)
Finished hunting and waiting for the next opportunity.
double m_efficiency
Probability of 'hitting' a game item.
virtual void SaveMyData(ofstream *)
Each hunter needs to save different kinds of data, so we use a polymorphic method for this.
The class for goose hunters encompsassing all their specific behaviours.
bool AddHunterHunting(int a_polyref, Hunter *a_hunter)
Adds a hunter hunting, returns true if that hunter is the leader otherwise false.
virtual bool InSeason(int day)
Is it goose hunting season? - MUST be overridden in descendent class.
void OnShotABird(int a_birdtype, int a_poly)
Message received when a goose is successully shot.
virtual void Init(struct_Hunter *p_data)
Initiation of a basic hunter here.
void DistributeHuntersByRules(vector< HunterInfo > *a_hunterlist, int a_no_hunters, int a_ruleset)
Implements the rule sets to distributes hunters to hunting locations (farms).
CfgInt cfg_goose_pinkfootopenseasonstart
The start of the pinkfoot hunting season.
virtual bool InSeason(int)
Is it hunting season? - MUST be overridden in descendent class.