ALMaSS Vole ODDox  1.1
The vole model description following ODdox protocol
Vole_all.cpp
Go to the documentation of this file.
1 
13 /*
14 *******************************************************************************************************
15 Copyright (c) 2011, Christopher John Topping, Aarhus University
16 All rights reserved.
17 
18 Redistribution and use in source and binary forms, with or without modification, are permitted provided
19 that the following conditions are met:
20 
21 Redistributions of source code must retain the above copyright notice, this list of conditions and the
22 following disclaimer.
23 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
24 the following disclaimer in the documentation and/or other materials provided with the distribution.
25 
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
27 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
28 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
29 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 ********************************************************************************************************
35 */
36 
37 //---------------------------------------------------------------------------
38 //
39 #define _CRT_SECURE_NO_DEPRECATE
40 
41 #include <iostream>
42 #include <fstream>
43 #include "../Landscape/ls.h"
44 #include "../BatchALMaSS/PopulationManager.h"
45 #include "../BatchALMaSS/BinaryMapBase.h"
46 #include "../BatchALMaSS/MovementMap.h"
47 #include "../Vole/vole_all.h"
48 #include "../Vole/VolePopulationManager.h"
49 #include "../Vole/GeneticMaterial.h"
50 #include "../Vole/Predators.h"
51 #include "../BatchALMaSS/BoostRandomGenerators.h"
52 
53 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> > g_rand_uni;
54 extern CfgBool cfg_RecordVoleMort;
55 extern CfgFloat l_pest_daily_mort;
56 extern const int Vector_x[8];
57 extern const int Vector_y[8];
58 
59 
60 #ifdef __VOLEPESTICIDEON
61 int Vole_Female::m_EndoCrineDisruptionGestationLength = 5; // Default value - will be altered by Vole_Female constructor
62 #endif
63 
65 CfgFloat cfg_extradispmort("VOLEDISPMORT",CFG_CUSTOM,0.055);
67 CfgFloat cfg_VoleResourceRegrowth("VOLE_RESOURCEREGROWTH",CFG_CUSTOM, 0.5);
68 
69 static CfgFloat cfg_volepcidebiodegredrate("VOLE_PCIDE_BIODEGREDATIONRATE",CFG_CUSTOM, 0.0 ); // 1.0 = no degradation, 0 = 100%
70 static CfgFloat cfg_InfanticideRangeRelToTerRange("VOLE_IINFANTICIDERANGE_RELTO_TERRANGE",CFG_CUSTOM,0.5);
71 static CfgBool cfg_VoleMortalityDataUsed("VOLE_MORTALITY_DATA_USED",CFG_CUSTOM, false);
72 static CfgInt cfg_VoleEndoCrineDisruptionGestationLength("VOLE_ENDOCRINEDISPRUPTORGESTATION", CFG_CUSTOM,21);
73 static CfgFloat cfg_InfanticideProbability("INFANTI_PROBA",CFG_CUSTOM,0.01);
75 static CfgFloat cfg_vole_habqualscaler("VOLE_HABQUALSCALER",CFG_CUSTOM,2.1);
77 CfgInt cfg_MinFemaleTerritorySize("VOLE_MINFEMALETERRITORYSIZE",CFG_CUSTOM,8);
79 static CfgInt cfg_MaxFemaleTerrSize("VOLE_MAXFEMALETERRITORYSIZE",CFG_CUSTOM,8);
81 CfgInt cfg_MinMaleTerritorySize("VOLE_MINMALETERRITORYSIZE",CFG_CUSTOM,9);
83 static CfgInt cfg_MaxMaleTerrSize("VOLE_MAXMALETERRITORYSIZE",CFG_CUSTOM,23);
85 static CfgInt cfg_vole_LifeMonths("VOLE_LIFEMONTHS",CFG_CUSTOM,3);
86 
88 static CfgInt cfg_MaxStarvationDays("VOLE_MAXSTARVATIONDAYS",CFG_CUSTOM,29);
89 extern double MoveToLessFavourable;
91 extern double g_SpeedyDivides[2001];
93 extern CfgInt cfg_productapplicstartyear;
95 static CfgFloat cfg_PesticideAccumulationThreshold("VOLE_PESTICDEACCUMULATIONTHRESHOLD",CFG_CUSTOM,20.0); //mg/kg
96 static CfgFloat cfg_PesticideAccumulationThresholdModelink2("VOLE_PESTICDEACCUMULATIONTHRESHOLD_MODELINKTWO",CFG_CUSTOM,20.0); //mg/kg
97 static CfgFloat cfg_PesticideAccumulationThreshold2("VOLE_PESTICDEACCUMULATIONTHRESHOLDTWO",CFG_CUSTOM,44.1); //mg/kg
98 static CfgFloat cfg_PesticideFemaleMaturityDelay("VOLE_PCIDE_FEMALEMATURITYDELAY",CFG_CUSTOM,0.0192);
99 static CfgFloat cfg_PesticideLitterSizeReduction("VOLE_PCIDE_LITTERSIZEREDUCTION",CFG_CUSTOM,0.0038);
100 static CfgFloat cfg_PesticideWeaningReduction("VOLE_PCIDE_WEANINGREDUCTION",CFG_CUSTOM,0.0017);
101 CfgBool cfg_ResistanceDominant("VOLE_RESISTANCEDOMINANT",CFG_CUSTOM,false);
102 
103 
104 extern CfgInt cfg_productapplicendyear;
105 extern CfgBool cfg_ReallyBigOutputMonthly_used;
106 extern CfgBool cfg_RipleysOutput_used;
107 extern CfgBool cfg_AOROutput_used;
108 extern CfgBool l_pest_enable_pesticide_engine;
109 extern CfgBool cfg_pest_residue_or_rate; // true if residue, otherwise it is rate per m2
111 CfgInt cfg_VoleDDepConst("VOLE_DDEPCONST",CFG_CUSTOM,4);
112 CfgInt cfg_MinReproAgeM("VOLE_MINREPROAGEM",CFG_CUSTOM,30);
113 CfgInt cfg_MinReproAgeF("VOLE_MINREPROAGEF",CFG_CUSTOM,23);
114 
115 //---------------------------------------------------------------------------
116 
117 //---------------------------------------------------------------------------
118 // Constants
119 //---------------------------------------------------------------------------
120 
121 
123 const int FemNoMature = September;
125 //const double MaturationChance [5] = {0.020,0.100,0.200,0.500,1.000};
127 const unsigned TheGestationPeriod = 21;
129 const unsigned WeanedAge = 13;
130 // Growth curve data for weight of voles
131 const int WeanedWeight=5;
133 const double MaxWeightM=60; // is 'double' to make MaleTerritoryRangeSlope a double
135 const double MaxWeightF=55; // is 'double' to make FemaleTerritoryRangeSlope a double
137 const double DaysAtMaxGrowth=90.0;
143 const int GrowStopDate = August;
149 const unsigned MinReproWeightM=40; //The smallest a male can be reproductive at.
151 const int MinReproWeightF=20; //The smallest a female can be reproductive at.
153 int g_sigAgeDiff = 30;
156 const double FemaleResourceReq [13]=
157  {
158  0,
159  1.0,
160  1.0,
161  1.0,
162  1.0,
163  1.0,
164  1.0,
165  1.0,
166  1.0,
167  1.0,
168  1.0,
169  1.0,
170  1.0
171  };
172 
174 const unsigned FemaleMovement = 50; //50
176 const unsigned MinFemaleMovement = 5;
177 const unsigned VoleMoveInterval = 30; // will have max movement after 120 days
179 const unsigned MaleMovement [4] = {10,40,70,110};
181 const unsigned MinMaleMovement = 5;
185 const double InfanticideChanceByAge[9]= {0.97,0.86,0.75,0.64,0.54,0.43,0.32,0.21,0.11};
186 
187 // Mortality Data TODO - make these config variables
189 double g_DailyMortChance = 0.003;
192 const double VoleHarvestMort=0.20;
194 const double VoleStriglingMort=0.50;
196 const double VoleSoilCultivationMort=0.75;
198 const double VolePigGrazingMort=0.25;
200 const double VoleHerbicicideMort = 0.0;
202 const double VoleInsecticideMort = 0.0;
203 
205 double g_NoFemalesMove = 0.01;
206 //---------------------------------------------------------------------------
207 // Vole_Base
208 //---------------------------------------------------------------------------
209 
210  unsigned int Vole_Base::m_MaxMaleTerritorySize = 0;
211  unsigned int Vole_Base::m_MaxFemaleTerritorySize = 0;
212  unsigned int Vole_Base::m_MinMaleTerritorySize = 0;
213  unsigned int Vole_Base::m_MinFemaleTerritorySize = 0;
214  double Vole_Base::m_MinFVoleHabQual = 0;
216  double Vole_Base::m_MinMVoleHabQual = 0;
219  bool Vole_Base::m_BreedingSeason = false;
220 #ifdef __VoleStarvationDays
221  int Vole_Base::m_MaxStarvationDays = 21;
222 #endif
223 
228  Vole_Base::Vole_Base(struct_Vole_Adult * p_aVoleStruct) : TAnimal(p_aVoleStruct->x, p_aVoleStruct->y, p_aVoleStruct->L)
229  {
230  Init(p_aVoleStruct);
231  }
232  //---------------------------------------------------------------------------
233 
234 
235  void Vole_Base::ReInit(struct_Vole_Adult * p_aVoleStruct) {
236  Init(p_aVoleStruct);
237  }
238  //---------------------------------------------------------------------------
239 
240  void Vole_Base::Init(struct_Vole_Adult * p_aVoleStruct)
241  {
242  m_Location_x = p_aVoleStruct->x;
243  m_Location_y = p_aVoleStruct->y;
244  m_OurLandscape = p_aVoleStruct->L;
245  m_CurrentStateNo = 0;
246  m_OurPopulation = p_aVoleStruct->VPM;
247  m_Mature = false;
248  m_Age = 0;
249  m_Weight = 0.5;
250  m_NoOfYoungTotal = 0;
251  m_DispVector = -1;
252  m_Have_Territory = false;
253  m_TerrRange = 0; // The size of the territory
254  m_MinTerrRange = 0;
255  m_Reserves = 3;
256  m_LifeSpan = (365 + 60) + int(g_rand_uni()*(30 * cfg_vole_LifeMonths.value())); //
258  m_intrappos.m_inAtrap = false;
259  m_BornLastYear = false;
260 
261  m_MyGenes = p_aVoleStruct->Genes;
265 
266  unsigned FatherIdNo = p_aVoleStruct->FatherId;
267  Set_FatherId(FatherIdNo);
268  unsigned MotherIdNo = p_aVoleStruct->MotherId;
269  Set_MotherId(MotherIdNo);
275  Set_BirthYear(p_aVoleStruct->BirthYear);
276 
279  if (m_MaxMaleTerritorySize < m_MinMaleTerritorySize) m_MaxMaleTerritorySize = m_MinMaleTerritorySize; // Corrects a bug caused by incorrect input settings
282  if (m_MaxFemaleTerritorySize < m_MinFemaleTerritorySize) m_MaxFemaleTerritorySize = m_MinFemaleTerritorySize; // Corrects a bug caused by incorrect input settings
285  m_MinJMVoleHabQual = cfg_vole_habqualscaler.value() * (4 * m_MinFemaleTerritorySize * m_MinFemaleTerritorySize); // Yes this should be female
288 #ifdef __VoleStarvationDays
289  m_StarvationDays = 0;
290  m_MaxStarvationDays = cfg_MaxStarvationDays.value();
291 #endif
292 #ifdef __VOLEPESTICIDEON
293  ClearPesticidLoad();
294  m_pesticideBioDegradeRate = cfg_volepcidebiodegredrate.value();
295  SetPesticideInfluenced1(false);
296  SetPesticideInfluenced2(false);
297  m_pesticideInfluenced3 = 0.0;
298 #endif
299  m_fertile = true;
300  }
301 //---------------------------------------------------------------------------
302 
303 
305 {
306 }
307 //---------------------------------------------------------------------------
314  struct_Vole_Adult* av;
315  av = new struct_Vole_Adult;
316  av->VPM = m_OurPopulation;
317  av->L = m_OurLandscape;
318  av->m_flag=true; // Used to signal pesticide effect to CreateObjects
322  av->x = ((m_Location_x+1)%m_OurPopulation->SimW);
323  av->y = ((m_Location_y)%m_OurPopulation->SimH);
324  // Do the genetics
326  m_OurPopulation->CreateObjects(a_vtype,this,av,1);
327  // object will be destroyed by death state
328  // but must let Dad know anyway
329  delete av;
330 }
331 //-----------------------------------------------------------------------------
337 {
338  m_Age++; // Once a day increment m_Age
339 }
340 //---------------------------------------------------------------------------
349 {
350  FreeLocation();
351  m_CurrentStateNo=-1;
352 }
353 //---------------------------------------------------------------------------
354 
363 {
364  // returns true if the vole should die
365  if (g_rand_uni() < g_DailyMortChance) {
366  return true;
367  }
368  // returns true if the vole should die
369  return false;
370 }
371 //---------------------------------------------------------------------------
372 
384 double Vole_Base::CalculateCarryingCapacity (int p_x, int p_y, int a_ddep )
385 {
386  int NoPolygons = 0;
387  int PolyRefData[500][2];
388  // First convert centre co-rdinates to square co-ordinates
389  double quality = 0;
390  int x=p_x - m_MinTerrRange;
391  if (x<0) x+=SimW;
392  int y=p_y - m_MinTerrRange;
393  if (y<0) y+=SimH;
394  int range_x=m_MinTerrRange+m_MinTerrRange;
395  int range_y=m_MinTerrRange+m_MinTerrRange;
396  // Stage 1 make a list of polygons
397  // create the extent variables
398  int xextent0 = x+range_x;
399  int yextent0 = y+range_y;
400  int xextent1 = (x+range_x)-SimW;
401  int yextent1 = (y+range_y)-SimH;
402  // Create the looping variables needed
403  int Dfinx=xextent0;
404  int Dfiny=yextent0;
405  int Afinx=0; // unless the finx values for A-C are changed
406  int Bfinx=0; // the value of zero will stop the A-C loops from executing
407  int Cfinx=0;
408  int Afiny=0; // this one assigned 0 to stop compiler complaints
409  // Now create the loop values;
410  if (x+range_x<=SimW)
411  {
412  // Type B & D (overlap bottom, no overlap)
413  if (yextent0>SimH)
414  {
415  // Type B (overlap bottom only)
416  Dfiny=SimH;
417  Bfinx=x+range_x;
418  }
419  }
420  else
421  {
422  // Type A & C overlap left edge or bottom & left
423  if (yextent0>SimH)
424  {
425  // Type C overlap bottom and left
426  Afinx=xextent1;
427  Afiny=SimH;
428  Bfinx=SimW;
429  Cfinx=xextent1;
430  Dfinx=SimW;
431  Dfiny=SimH;
432  }
433  else
434  {
435  // Type A overlap left edge
436  Afinx=xextent1;
437  Afiny=yextent0;
438  Dfinx=SimW;
439  }
440  }
441  // the default is:
442  // Type D no overlap
443 
444 
445  // A Loop
446  for (int i=0; i<Afinx; i++)
447  {
448  for (int j=y; j<Afiny; j++)
449  {
450  // Get the polyref
451  int PRef = m_OurLandscape->SupplyPolyRefIndex(i,j);
452  // check if we have had this one already
454  bool found=false;
455  for (int k=0; k<NoPolygons; k++)
456  {
457  if (PolyRefData[k][0]==PRef)
458  {
459  PolyRefData[k][1]++;
460  found = true;
461  break;
462  }
463  }
464  if (!found)
465 //*/
466  {
467  // don't have this one so get the height & type to the PolyDatas arrays
468  PolyRefData[NoPolygons][0]=PRef;
469  PolyRefData[NoPolygons][1]=1;
470  NoPolygons++;
471  }
472  }
473  }
474  // B Loop
475  for (int i=x; i<Bfinx; i++)
476  {
477  for (int j=0; j<yextent1; j++)
478  {
479  // Get the polyref
480  int PRef = m_OurLandscape->SupplyPolyRefIndex(i,j);
481  // check if we have had this one already
482 /*
483  int index=-1;
484  for (int k=0; k<NoPolygons; k++)
485  {
486  if (PolyRefData[k][0]==PRef)
487  {
488  index=k;
489  break;
490  }
491  }
492  if (index!=-1)
493  {
494  PolyRefData[index][1]++;
495  }
496  else
497 */
499  bool found=false;
500  for (int k=0; k<NoPolygons; k++)
501  {
502  if (PolyRefData[k][0]==PRef)
503  {
504  PolyRefData[k][1]++;
505  found = true;
506  break;
507  }
508  }
509  if (!found)
510 //*/
511  {
512  // don't have this one so get the height & type to the PolyDatas arrays
513  PolyRefData[NoPolygons][0]=PRef;
514  PolyRefData[NoPolygons][1]=1;
515  NoPolygons++;
516  }
517  }
518  }
519  // C Loop
520  for (int i=0; i<Cfinx; i++)
521  {
522  for (int j=0; j<yextent1; j++)
523  {
524  // Get the polyref
525  int PRef = m_OurLandscape->SupplyPolyRefIndex(i,j);
526  // check if we have had this one already
527 /*
528  int index=-1;
529  for (int k=0; k<NoPolygons; k++)
530  {
531  if (PolyRefData[k][0]==PRef)
532  {
533  index=k;
534  break;
535  }
536  }
537  if (index!=-1)
538  {
539  PolyRefData[index][1]++;
540  }
541  else
542 */
544  bool found=false;
545  for (int k=0; k<NoPolygons; k++)
546  {
547  if (PolyRefData[k][0]==PRef)
548  {
549  PolyRefData[k][1]++;
550  found = true;
551  break;
552  }
553  }
554  if (!found)
555 //*/
556  {
557  // Don't have this one so get the height & type to the PolyDatas arrays
558  PolyRefData[NoPolygons][0]=PRef;
559  PolyRefData[NoPolygons][1]=1;
560  NoPolygons++;
561  }
562  }
563  }
564  // D Loop
565  int last=-99999;
566  int k_index=-1;
567  for (int i=x; i<Dfinx; i++)
568  {
569  for (int j=y; j<Dfiny; j++)
570  {
571  // Get the polyref
572  int PRef = m_OurLandscape->SupplyPolyRefIndex(i,j);
573  // check if we have had this one already
574  if (last==PRef)
575  {
576  PolyRefData[k_index][1]++;
577  }
578  else
579  {
580 
581  bool found=false;
582  for (int k=0; k<NoPolygons; k++)
583  {
584  if (PolyRefData[k][0]==PRef)
585  {
586  PolyRefData[k][1]++;
587  found = true;
588  last = PRef;
589  k_index = k;
590  break;
591  }
592  }
593  if (!found)
594  {
595  // don't have this one so get the height & type to the PolyDatas arrays
596  PolyRefData[NoPolygons][0]=PRef;
597  PolyRefData[NoPolygons][1]=1;
598  NoPolygons++;
599  }
600  }
601  }
602  }
603  // End of search algorithm
604  /* for each polygon get the quality and multiply by amount of that polygon in the territory sum this to get overall quality */
605  for ( int i=0; i<NoPolygons; i++)
606  {
607  quality+= PolyRefData[i][1]*m_OurPopulation->GetHabitatQuality(PolyRefData[i][0]);
608  }
609 // return quality;
610 
612  if (Voles > a_ddep) quality /= (Voles-a_ddep);
613  // return the total quality
614  return quality;
615 }
616 //---------------------------------------------------------------------------
617 
618 
638 //double Vole_Base::CalculateCarryingCapacity(int p_x, int p_y,
639 // int & p_stand_x, int & p_stand_y)
640 //{
641 // int NoPolygons = 0;
642 // int PolyRefData[200][2];
643 // // First convert centre co-rdinates to square co-ordinates
644 // double quality = 0;
645 // int x=p_x - m_MinTerrRange;
646 // if (x<0) x+=SimW;
647 // int y=p_y - m_MinTerrRange;
648 // if (y<0) y+=SimH;
649 // int range_x=m_MinTerrRange+m_MinTerrRange;
650 // int range_y=m_MinTerrRange+m_MinTerrRange;
651 // // Stage 1 make a list of polygons
652 // // create the extent variables
653 // int xextent0 = x+range_x;
654 // int yextent0 = y+range_y;
655 // int xextent1 = (x+range_x)-SimW;
656 // int yextent1 = (y+range_y)-SimH;
657 // // Create the looping variables needed
658 // int Dfinx=xextent0;
659 // int Dfiny=yextent0;
660 // int Afinx=0; // unless the finx values for A-C are changed
661 // int Bfinx=0; // the value of zero will stop the A-C loops from executing
662 // int Cfinx=0;
663 // int Afiny=0; // this one is only assigned as 0 to stop compiler complaints
664 // // Now create the loop values;
665 // if (x+range_x<=SimW)
666 // {
667 // // Type B & D (overlap bottom, no overlap)
668 // if (yextent0>SimH)
669 // {
670 // // Type B (overlap bottom only)
671 // Dfiny=SimH;
672 // Bfinx=x+range_x;
673 // }
674 // }
675 // else
676 // {
677 // // Type A & C overlap left edge or bottom & left
678 // if (yextent0>SimH)
679 // {
680 // // Type C overlap bottom and left
681 // Afinx=xextent1;
682 // Afiny=m_OurPopulation->SimH;
683 // Bfinx=m_OurPopulation->SimW;
684 // Cfinx=xextent1;
685 // Dfinx=m_OurPopulation->SimW;
686 // Dfiny=m_OurPopulation->SimH;
687 // }
688 // else
689 // {
690 // // Type A overlap left edge
691 // Afinx=xextent1;
692 // Afiny=yextent0;
693 // Dfinx=SimW;
694 // }
695 // }
696 // // the default is:
697 // // Type D no overlap
698 //
699 //
700 // // A Loop
701 // for (int i=0; i<Afinx; i++)
702 // {
703 // for (int j=y; j<Afiny; j++)
704 // {
705 // // Get the polyref
706 // int PRef = m_OurLandscape->SupplyPolyRefIndex(i,j);
707 // // check if we have had this one already
708 // int index=-1;
709 // for (int k=0; k<NoPolygons; k++)
710 // {
711 // if (PolyRefData[k][0]==PRef)
712 // {
713 // index=k;
714 // break;
715 // }
716 // }
717 // if (index!=-1)
718 // {
719 // PolyRefData[index][1]++;
720 // }
721 // else
722 // {
723 // // don't have this one so get the height & type to the PolyDatas arrays
724 // PolyRefData[NoPolygons][0]=PRef;
725 // PolyRefData[NoPolygons][1]=1;
726 // NoPolygons++;
727 // }
728 // }
729 // }
730 // // B Loop
731 // for (int i=x; i<Bfinx; i++)
732 // {
733 // for (int j=0; j<yextent1; j++)
734 // {
735 // // Get the polyref
736 // int PRef = m_OurLandscape->SupplyPolyRefIndex(i,j);
737 // // check if we have had this one already
738 // int index=-1;
739 // for (int k=0; k<NoPolygons; k++)
740 // {
741 // if (PolyRefData[k][0]==PRef)
742 // {
743 // index=k;
744 // break;
745 // }
746 // }
747 // if (index!=-1)
748 // {
749 // PolyRefData[index][1]++;
750 // }
751 // else
752 // {
753 // // don't have this one so get the height & type to the PolyDatas arrays
754 // PolyRefData[NoPolygons][0]=PRef;
755 // PolyRefData[NoPolygons][1]=1;
756 // NoPolygons++;
757 // }
758 // }
759 // }
760 // // C Loop
761 // for (int i=0; i<Cfinx; i++)
762 // {
763 // for (int j=0; j<yextent1; j++)
764 // {
765 // // Get the polyref
766 // int PRef = m_OurLandscape->SupplyPolyRefIndex(i,j);
767 // // check if we have had this one already
768 // int index=-1;
769 // for (int k=0; k<NoPolygons; k++)
770 // {
771 // if (PolyRefData[k][0]==PRef)
772 // {
773 // index=k;
774 // break;
775 // }
776 // }
777 // if (index!=-1)
778 // {
779 // PolyRefData[index][1]++;
780 // }
781 // else
782 // {
783 // // Don't have this one so get the height & type to the PolyDatas arrays
784 // PolyRefData[NoPolygons][0]=PRef;
785 // PolyRefData[NoPolygons][1]=1;
786 // NoPolygons++;
787 // }
788 // }
789 // }
790 // // D Loop
791 // for (int i=x; i<Dfinx; i++)
792 // {
793 // for (int j=y; j<Dfiny; j++)
794 // {
795 // // Get the polyref
796 // int PRef = m_OurLandscape->SupplyPolyRefIndex(i,j);
797 // // check if we have had this one already
798 // int index=-1;
799 // for (int k=0; k<NoPolygons; k++)
800 // {
801 // if (PolyRefData[k][0]==PRef)
802 // {
803 // index=k;
804 // break;
805 // }
806 // }
807 // if (index!=-1)
808 // {
809 // PolyRefData[index][1]++;
810 // }
811 // else
812 // {
813 // // don't have this one so get the height & type to the PolyDatas arrays
814 // PolyRefData[NoPolygons][0]=PRef;
815 // PolyRefData[NoPolygons][1]=1;
816 // NoPolygons++;
817 // }
818 // }
819 // }
820 // // End of search algorithm
821 // // for each polygon get the quality and multiply by amount of
822 // // that polygon in the territory
823 // // sum this to get overall quality
824 // double bestqual=-2;
825 // unsigned found=0;
826 // for ( int i=0; i<NoPolygons; i++)
827 // {
828 // double qual = m_OurPopulation->GetHabitatQuality(PolyRefData[i][0]);
829 // if (bestqual<qual)
830 // {
831 // bestqual=qual;
832 // found = i;
833 // }
834 // quality+=PolyRefData[i][1]*qual;
835 // }
836 // // now find a location in polygon i
837 // // D Loop
838 // for (int i=x; i<Dfinx; i++)
839 // {
840 // for (int j=y; j<Dfiny; j++)
841 // {
842 // // Get the polyref
843 // if (m_OurLandscape->SupplyPolyRefIndex(i,j)==PolyRefData[found][0])
844 // {
845 // p_stand_x = p_x;
846 // p_stand_y = p_y;
847 // return quality;
848 // }
849 // }
850 // }
851 // // A Loop
852 // for (int i=0; i<Afinx; i++)
853 // {
854 // for (int j=y; j<Afiny; j++)
855 // {
856 // // Get the polyref
857 // if (m_OurLandscape->SupplyPolyRefIndex(i,j)==PolyRefData[found][0])
858 // {
859 // p_stand_x = p_x;
860 // p_stand_y = p_y;
861 // return quality;
862 // }
863 // }
864 // }
865 // // B Loop
866 // for (int i=x; i<Bfinx; i++)
867 // {
868 // for (int j=0; j<yextent1; j++)
869 // {
870 // // Get the polyref
871 // if (m_OurLandscape->SupplyPolyRefIndex(i,j)==PolyRefData[found][0])
872 // {
873 // p_stand_x = p_x;
874 // p_stand_y = p_y;
875 // return quality;
876 // }
877 // }
878 // }
879 // // C Loop
880 // for (int i=0; i<Cfinx; i++)
881 // {
882 // for (int j=0; j<yextent1; j++)
883 // {
884 // if (m_OurLandscape->SupplyPolyRefIndex(i,j)==PolyRefData[found][0])
885 // {
886 // p_stand_x = p_x;
887 // p_stand_y = p_y;
888 // return quality;
889 // }
890 // }
891 // }
892 // m_OurLandscape->Warn("Vole_Base::CalculateCarryingCapacity - error",NULL);
893 // exit(1);
894 //}
895 //---------------------------------------------------------------------------
896 
907 void Vole_Base::MoveTo(int p_Vector,int p_Distance, int p_iterations)
908 {
909  int offset=p_Distance*p_iterations;
910  if ((m_Location_x-offset < 0) ||(m_Location_x+offset >= SimW) || (m_Location_y-offset < 0) ||(m_Location_y+offset >= SimH))
911  {
912  // Need correct coords
913  // Make sure that the coords can't become -ve
914  int vx = m_Location_x+SimW;
915  int vy = m_Location_y+SimH;
916  do
917  {
918  DoWalkingCorrect(p_Distance,p_Vector,vx,vy);
919  p_Distance=1;
920  } while ((GetLocation(vx%SimW,vy%SimH)) && (p_iterations-->0));
921  // alter the voles location (& correct coords)
922  FreeLocation();
923  m_Location_x=vx%SimW;
924  m_Location_y=vy%SimH;
925  SetLocation();
926  }
927  else
928  {
929  // Don't need correct coords
930  int vx = m_Location_x;
931  int vy = m_Location_y;
932  do
933  {
934  DoWalking(p_Distance,p_Vector,vx,vy);
935  p_Distance=1;
936  } while ((GetLocation(vx,vy)) && (p_iterations-->0));
937  // alter the voles location (& correct coords)
938  FreeLocation();
939  m_Location_x=vx;
940  m_Location_y=vy;
941  SetLocation();
942  }
943 }
944 //---------------------------------------------------------------------------
945 
953 void Vole_Base::DoWalking(int p_Distance,int &p_Vector, int &vx, int &vy)
954 {
955  int t[5], q[5];
957  t[0] = p_Vector;
958  t[1] = (p_Vector+1) & 0x07;
959  t[2] = (p_Vector+7) & 0x07;
960  t[3] = (p_Vector+2) & 0x07;
961  t[4] = (p_Vector+6) & 0x07;
962 //*/
963  for (int i=0; i<p_Distance; i++)
964  {
965  // test the squares at Vector, Vector+1+2, Vector-1-2
966  // They have either a quality or are inaccessible (water,buildings)
967  // if can go to one of these squares then pick the best one
968  // if all or some are equal then take a random pick.
969  // if all are 'bad' then add or subtract one from vector and try again
970 
971 /* t[0] = p_Vector;
972  t[1] = (p_Vector+1) & 0x07;
973  t[2] = (p_Vector+7) & 0x07;
974  t[3] = (p_Vector+2) & 0x07;
975  t[4] = (p_Vector+6) & 0x07; */
976 
977  q[0] = MoveQuality((vx+Vector_x[t[0]]),(vy+Vector_y[t[0]]));
978  q[1] = MoveQuality((vx+Vector_x[t[1]]),(vy+Vector_y[t[1]]));
979  q[2] = MoveQuality((vx+Vector_x[t[2]]),(vy+Vector_y[t[2]]));
980  q[3] = MoveQuality((vx+Vector_x[t[3]]),(vy+Vector_y[t[3]]));
981  q[4] = MoveQuality((vx+Vector_x[t[4]]),(vy+Vector_y[t[4]]));
983  {
984  // allow a mistake once in a while
985  for (int j=1; j<5; j++) q[j]=-1;
986  }
987  // Now pick the best of these
988  int best = q[0];
989  int score=1;
990  for (int ii=1; ii<5; ii++)
991  {
992  if (q[ii]>best)
993  {
994  best=q[ii];
995  score=1;
996  }
997  else if (q[ii]==best) score++;
998  }
999  if (best==-1)
1000  {
1001  // can't go anywhere so change the vector
1002  if (random(2)) ++p_Vector; else (--p_Vector);
1003  p_Vector&=0x07;
1005  t[0] = p_Vector;
1006  t[1] = (p_Vector+1) & 0x07;
1007  t[2] = (p_Vector+7) & 0x07;
1008  t[3] = (p_Vector+2) & 0x07;
1009  t[4] = (p_Vector+6) & 0x07;
1010 //*/
1011  }
1012  else
1013  {
1014  // Can go to one of score squares
1015  int scored=random(score); // pick one
1016  int loop=0;
1017  for (int ii=0; ii<5; ii++)
1018  {
1019  if (best==q[ii]) loop++; // count the squares with 'best' quality
1020  if (loop>scored)
1021  {
1022  loop=ii; // go to i-square
1023  break;
1024  }
1025  }
1026  // change co-ordinates
1027  vx+=Vector_x[t[loop]];
1028  vy+=Vector_y[t[loop]];
1029  }
1030  }
1031 }
1032 //------------------------------------------------------------------------------
1041 void Vole_Base::DoWalkingCorrect(int p_Distance,int &p_Vector, int &vx, int &vy)
1042 {
1043  int t[5], q[5];
1045  t[0] = p_Vector;
1046  t[1] = (p_Vector+1) & 0x07;
1047  t[2] = (p_Vector+7) & 0x07;
1048  t[3] = (p_Vector+2) & 0x07;
1049  t[4] = (p_Vector+6) & 0x07;
1050  //*/
1051  for (int i=0; i<p_Distance; i++)
1052  {
1053  // test the squares at Vector, Vector+1+2, Vector-1-2
1054  // They have either a quality or are inaccessible (water,buildings)
1055  // if can go to one of these squares then pick the best one
1056  // if all or some are equal then take a random pick.
1057  // if all are 'bad' then add or subtract one from vector and try again
1058  /* t[0] = p_Vector;
1059  t[1] = (p_Vector+1) & 0x07;
1060  t[2] = (p_Vector+7) & 0x07;
1061  t[3] = (p_Vector+2) & 0x07;
1062  t[4] = (p_Vector+6) & 0x07; */
1063  q[0] = MoveQuality((vx+Vector_x[t[0]])%SimW, (vy+Vector_y[t[0]])%SimH);
1064  q[1] = MoveQuality((vx+Vector_x[t[1]])%SimW,(vy+Vector_y[t[1]])%SimH);
1065  q[2] = MoveQuality((vx+Vector_x[t[2]])%SimW,(vy+Vector_y[t[2]])%SimH);
1066  q[3] = MoveQuality((vx+Vector_x[t[3]])%SimW,(vy+Vector_y[t[3]])%SimH);
1067  q[4] = MoveQuality((vx+Vector_x[t[4]])%SimW,(vy+Vector_y[t[4]])%SimH);
1069  {
1070  // allow a mistake once in a while
1071  for (int j=1; j<5; j++) q[j]=-1;
1072  }
1073  // Now pick the best of these
1074  int best = q[0];
1075  int score=1;
1076  for (int ii=1; ii<5; ii++)
1077  {
1078  if (q[ii]>best)
1079  {
1080  best=q[ii];
1081  score=1;
1082  }
1083  else
1084  if (q[ii]==best) score++;
1085  }
1086  if (best==-1)
1087  {
1088  // can't go anywhere so change the vector
1089  if (random(2)) ++p_Vector; else (--p_Vector);
1090  p_Vector&=0x07;
1091  // /*
1092  t[0] = p_Vector;
1093  t[1] = (p_Vector+1) & 0x07;
1094  t[2] = (p_Vector+7) & 0x07;
1095  t[3] = (p_Vector+2) & 0x07;
1096  t[4] = (p_Vector+6) & 0x07; //*/
1097  }
1098  else
1099  {
1100  // Can go to one of score squares
1101  int scored=random(score); // pick one
1102  int loop=0;
1103  for (int ii=0; ii<5; ii++)
1104  {
1105  if (best==q[ii]) loop++; // count the squares with 'best' quality
1106  if (loop>scored)
1107  {
1108  loop=ii; // go to i-square
1109  break;
1110  }
1111  }
1112  // change co-ordinates
1113  vx+=Vector_x[t[loop]];
1114  vy+=Vector_y[t[loop]];
1115  }
1116  }
1117 }
1118 //------------------------------------------------------------------------------
1119 
1127 void Vole_Base::Escape(int p_Vector,int p_Distance)
1128 {
1129  // This will alter m_Location_x & m_Location_y
1130  // it will give a very directed movement towards p_Vector
1131 
1132  // p_Vector gives the preferred direction (0-7)
1133  // p_Distance is the number of steps
1134  int vx = m_Location_x+SimW;
1135  int vy = m_Location_y+SimH;
1136 // int counter = 0;
1137  for (int i=0; i<p_Distance; i++)
1138  {
1139  // test the squares at Vector, Vector+1+2, Vector-1-2
1140  // They have either a quality or are inaccessible (water,buildings)
1141  // if can go to one of these squares then pick the best one
1142  // if all or some are equal then take a random pick.
1143  // if all are 'bad' then add or subtract one from p_Vector and try again
1144 // counter ++;
1145  int t[3], q[3];
1146  t[0] = p_Vector;
1147  t[1] = (p_Vector+1) & 0x07;
1148  t[2] = (p_Vector+7) & 0x07;
1149  q[0] = MoveQuality((vx+Vector_x[t[0]])%SimW,(vy+Vector_y[t[0]])%SimH);
1150  q[1] = MoveQuality((vx+Vector_x[t[1]])%SimW,(vy+Vector_y[t[1]])%SimH);
1151  q[2] = MoveQuality((vx+Vector_x[t[2]])%SimW,(vy+Vector_y[t[2]])%SimH);
1152  // Now pick the best of these
1153  int noscore=0;
1154  for (int ii=0; ii<3; ii++)
1155  {
1156  if (q[ii]==-1)
1157  {
1158  noscore++;
1159  }
1160  }
1161  if (noscore==3)
1162  {
1163  // can't go anywhere so change the vector
1164  if (random(2)) p_Vector++; else p_Vector--;
1165  }
1166  else
1167  {
1168  // Can go to at least one of score squares
1169  // try the middle first
1170  int loop=0;
1171  if (q[0]==-1)
1172  {
1173  // otherwise randomly try one side or other
1174  // it must be possible to go to one of these
1175  int which=random(2);
1176  if (which==1)
1177  {
1178  if (q[1]!=-1) loop=1; else loop=2;
1179  }
1180  else
1181  {
1182  if (q[2]!=-1) loop=2; else loop=1;
1183  }
1184  }
1185  // change co-ordinates
1186  vx+=Vector_x[t[loop]];
1187  vy+=Vector_y[t[loop]];
1188  }
1189  }
1190  // alter the voles location
1191  FreeLocation();
1192  m_Location_x=vx%SimW;
1193  m_Location_y=vy%SimH;
1194  SetLocation();
1195 }
1196 //---------------------------------------------------------------------------
1197 
1198 
1207 int Vole_Base::MoveQuality(int p_x, int p_y)
1208 {
1209  if (m_OurPopulation->m_VoleMap->GetMapValue(p_x,p_y)!=NULL) return -1;
1210  // Nobody there so carry on
1211  int poly_index=m_OurLandscape->SupplyPolyRefIndex(p_x,p_y);
1212  int score = -9999;
1214  switch (tole)
1215  {
1216  case tole_NaturalGrassDry: // 110
1217  case tole_NaturalGrassWet: // 110
1218  case tole_BeetleBank:
1219  score=4;
1220  break;
1221  case tole_PermPasture: // 35
1222  if (m_OurLandscape->SupplyGrazingPressureVector(poly_index) > 0 ) score=1; else score=4;
1223  break;
1224  case tole_PermPastureLowYield: // 35
1225  if (m_OurLandscape->SupplyGrazingPressureVector(poly_index) > 0 ) score = 1; else score = 4;
1226  break;
1228  if (m_OurLandscape->SupplyGrazingPressureVector(poly_index) > 0 ) score = 2; else score = 4;
1229  break;
1230  case tole_Orchard: // 56
1231  // Quality depends on when it was mown
1232  if (m_OurLandscape->SupplyJustMownVector(poly_index)) score=0; else
1233  {
1234  if (m_OurLandscape->SupplyVegCoverVector(poly_index)<0.8) score = 4;
1235  else if (m_OurLandscape->SupplyVegHeightVector(poly_index)<=40) score = 4;
1236  else score = 4;
1237  }
1238 
1239  break;
1240  case tole_MownGrass: // 58
1241  // Quality depends on when it was mown
1242  if (m_OurLandscape->SupplyJustMownVector(poly_index)) score=1; else score=4;
1243  break;
1244  case tole_OrchardBand: // 57
1245  score = 4 - (int) (0.6*m_OurLandscape->SupplyJustSprayedVector(poly_index));
1246  break;
1247  case tole_RoadsideSlope:
1248  case tole_Railway: // 118
1249  case tole_FieldBoundary: // 160
1250  case tole_RoadsideVerge: // 13
1251  case tole_HedgeBank:
1253  case tole_YoungForest: // 60
1254  case tole_Vildtager:
1255  case tole_Wasteland:
1256  score = 4;
1257  break;
1258  case tole_Saltmarsh: // 95
1259  case tole_Marsh: // 95
1260  case tole_Scrub: // 70
1261  case tole_Heath:
1262  case tole_Hedges: // 130 (internal ALMaSS representation for Hedges)
1263  case tole_RiversidePlants: // 98
1264  case tole_PitDisused: // 75
1265  case tole_MixedForest: // 60
1266  case tole_DeciduousForest: // 40
1267  case tole_Copse:
1268  score=3;
1269  break;
1270  case tole_RiversideTrees: // 97
1271  case tole_ConiferousForest: // 50
1273  case tole_Parkland:
1274  case tole_AmenityGrass:
1275  case tole_WoodyEnergyCrop:
1276  case tole_IndividualTree:
1277  score=2;
1278  break;
1279  case tole_Garden: //11
1280  case tole_Track: // 123
1281  case tole_SmallRoad: // 122
1282  case tole_LargeRoad: // 121
1283  case tole_BareRock:
1284  case tole_UrbanNoVeg:
1285  case tole_UrbanPark:
1286  case tole_SandDune:
1287  case tole_Churchyard: //204
1288  score=1;
1289  break;
1290  case tole_MetalledPath:
1291  case tole_Carpark:
1292  case tole_Stream:
1293  case tole_HeritageSite:
1294  case tole_Building: // 5
1295  case tole_ActivePit: // 115
1296  case tole_Freshwater: // 90
1297  case tole_FishFarm:
1298  case tole_Pond:
1299  case tole_River: // 96
1300  case tole_Saltwater: // 80
1301  case tole_Coast: // 100
1302  case tole_StoneWall: // 15
1303  case tole_Fence: //225
1304  case tole_WindTurbine:
1305  case tole_Pylon:
1306  score=-1;
1307  break;
1308  case tole_Field: // 20 & 30
1310  {
1312  switch (VType) {
1320  score = 3 - m_OurLandscape->SupplyGrazingPressureVector(poly_index);
1321  break;
1322  default:
1323  double cover = m_OurLandscape->SupplyVegCoverVector(poly_index);
1324  double height = m_OurLandscape->SupplyVegHeightVector(poly_index);
1325  if ((cover>0.80) && (height>40)) score = 3;
1326  if ((cover<0.50) || (height<10)) score = 0;
1327  else score = 2;
1328  }
1329  }
1330  break;
1331  case tole_Foobar: // 999 !! type unknown - should not happen
1332  default:
1333  static char errornum[20];
1334  sprintf(errornum, "%d", m_OurLandscape->SupplyElementTypeFromVector(poly_index));
1335  m_OurLandscape->Warn("Vole_Base:MoveQuality: Unknown tole_type",
1336  errornum);
1337  exit(1);
1338  }
1339  return score;
1340 }
1341 //---------------------------------------------------------------------------
1342 // Vole_JuvenileFemale
1343 //---------------------------------------------------------------------------
1344 
1350 {
1351  m_Sex=false;
1354  m_BornLastYear= false;
1356  m_Age=14;
1357 #ifdef __VOLEPESTICIDEON
1358  m_maturitydelay = 0.0;
1359 #endif
1360 }
1361 //---------------------------------------------------------------------------
1362 
1364  Init(p_aVoleStruct);
1365  m_Sex = false;
1368  m_BornLastYear = false;
1370  m_Age = 14;
1371 #ifdef __VOLEPESTICIDEON
1372  m_maturitydelay = 0.0;
1373 #endif
1374 }
1375 //---------------------------------------------------------------------------
1376 
1377 
1379 {
1380  // Nothing to do
1381 }
1382 //---------------------------------------------------------------------------
1383 
1394 {
1395  if (MortalityTest())
1396  {
1398  m_StepDone=true;
1400  }
1401  else
1402  {
1403  if (--m_LifeSpan<1)
1404  {
1407  m_StepDone=true;
1408  }
1409  }
1410 #ifdef __VOLEPESTICIDEON
1411  PesticideIngestion();
1412  ActOnPesticideDose();
1413 #endif
1414  }
1415 //---------------------------------------------------------------------------
1416 
1427 {
1428  if (m_StepDone) return;
1429  switch (CurrentVState)
1430  {
1431  case 0: // Initial state
1433  break;
1434  case tovs_FEvaluateExplore: // Evaluate & Explore
1435  switch(st_Evaluate_n_Explore())
1436  {
1437  case 1: // Dead from dispersal mortality
1438  CurrentVState=tovs_FDying; // Die
1439  break;
1440  case 2: // Starved
1442  CurrentVState=tovs_FDying; // Die
1443  break;
1444  default:
1445  ; // Do nothing
1446  }
1447 #ifdef __VOLEPESTICIDEON
1448  if (m_Age >= MinReproAgeF+ m_maturitydelay ) st_BecomeSubAdult();
1449 #else
1451 #endif
1452  m_StepDone=true;
1453  break;
1454  case tovs_FDying: // Die
1455  FreeLocation();
1456  m_StepDone=true;
1457  break;
1458  default:
1459  m_OurLandscape->Warn("Vole_Female::Step - unknown state",NULL);
1460  exit(9);
1461  }
1462 }
1463 //---------------------------------------------------------------------------
1464 
1475 {
1476 #ifdef __VoleStarvationDays
1477  if ( m_StarvationDays > m_MaxStarvationDays)
1478  {
1479  st_Dying();
1481  }
1482 #endif
1483  CheckManagement();
1484  if (CurrentVState==tovs_FDying) {
1485  st_Dying();
1486  }
1487 
1488  else
1489  {
1490  m_Age++;
1491  /* FEMALE GROWTH NOTES
1492 
1493  Female vole grows until 20g.
1494  After that she will only grow if he has matured
1495  Growth continues up to 55g.
1496 
1497  Reproduction cannot occur below 20g or 20 days
1498 
1499  Growth only occurs between 1 March and 1st August
1500 
1501  taken from Hanson L, 1977, Oikos 29.
1502  */
1503  int today=m_OurLandscape->SupplyDayInYear();
1504  if ((today<GrowStopDate) && (today>
1506  {
1507  if (m_Weight<20)
1508  {
1510  }
1511  else if ((m_Mature==true) && (m_Weight<MaxWeightF))
1512  {
1515  }
1516  }
1517  else if (today==1) m_BornLastYear=true; // must be true if alive on 1st Jan.
1518  }
1519 }
1520 //---------------------------------------------------------------------------
1521 
1530 {
1531  switch(event)
1532  {
1533 case sleep_all_day:
1534  break;
1535 case autumn_plough:
1538  break;
1539 case autumn_harrow:
1542  break;
1543 case autumn_roll:
1546  break;
1547 case autumn_sow:
1550  break;
1551 case winter_plough:
1554  break;
1555 case deep_ploughing:
1558  break;
1559 case spring_plough:
1562  break;
1563 case spring_harrow:
1566  break;
1567 case spring_roll:
1570  break;
1571 case spring_sow:
1574  break;
1575 case fp_npks:
1576  break;
1577 case fp_npk:
1578  break;
1579 case fp_pk:
1580  break;
1581 case fp_liquidNH3:
1582  break;
1583 case fp_slurry:
1584  break;
1586  break;
1587 case fp_manure:
1588  break;
1589 case fp_greenmanure:
1590  break;
1591 case fp_sludge:
1592  break;
1593 case fa_npk:
1594  break;
1595 case fa_pk:
1596  break;
1597 case fa_slurry:
1598  break;
1599 case fa_ammoniumsulphate:
1600  break;
1601 case fa_manure:
1602  break;
1603 case fa_greenmanure:
1604  break;
1605 case fa_sludge:
1606  break;
1607 case herbicide_treat:
1608  break;
1609 case growth_regulator:
1610  break;
1611 case fungicide_treat:
1612  break;
1613 case insecticide_treat:
1614  break;
1615 case molluscicide:
1616  break;
1617 case glyphosate:
1618  break;
1619 case row_cultivation:
1622  break;
1623 case strigling:
1626  break;
1627 case hilling_up:
1630  break;
1631 case water:
1632  break;
1633 case swathing:
1636  break;
1637 case harvest:
1640  break;
1641 case cattle_out:
1642 case cattle_out_low:
1643  break;
1644 case cut_to_hay:
1647  break;
1648 case cut_to_silage:
1651  break;
1652 case straw_chopping:
1655  break;
1656 case hay_turning:
1659  break;
1660 case hay_bailing:
1663  break;
1664 case stubble_harrowing:
1667  break;
1671  break;
1672 case burn_straw_stubble:
1675  break;
1676 case mow:
1679  break;
1680 case cut_weeds:
1683  break;
1684 case pigs_out:
1687  break;
1688 case strigling_sow:
1691  break;
1693 case trial_toxiccontrol:
1694 case trial_control:
1695  break;
1696 default:
1697  g_msg->Warn( WARN_FILE, "Vole_Female::OnFarmEvent(): Unknown event type:",
1699  exit( 1 );
1700  }
1702  {
1704  return true;
1705  }
1706  else
1707  return false;
1708 }
1709 //----------------------------------------------------------------------------
1710 
1719 {
1722 }
1723 //---------------------------------------------------------------------------
1724 
1726 {
1727  struct_Vole_Adult* av;
1728  av = new struct_Vole_Adult;
1729  av->VPM = m_OurPopulation;
1730  av->L = m_OurLandscape;
1731  av->m_flag=true; // Used to signal pesticide effect to CreateObjects
1732  // Create the new voles (50% chance of male/female)
1736  av->FatherId = m_FatherId;
1737  av->MotherId = m_MotherId;
1738  av->x = m_Location_x;
1739  av->y = m_Location_y;
1740  av->weight = m_Weight;
1741  // Do the genetics
1742  av->Genes = m_MyGenes;
1743  av->age = m_Age;
1745  // Remove the current object
1747  FreeLocation();
1748  m_CurrentStateNo = -1;
1749  m_StepDone = true;
1750 }
1751 //---------------------------------------------------------------------------
1752 
1761 {
1762 #ifdef __USINGTRAPLINES
1763  CheckTraps();
1764 #endif
1766  // This function determines whether he must leave and whether he does
1767  // an explore. He will do this if he is not in optimal conditions
1768 
1769  if (Qual < m_MinFVoleHabQual)
1770  {
1771  // check an area MinFemaleMovement to FemaleMovement metres away
1772  m_DispVector = random(8);
1773  // Not quality dependent dispersal, very directed
1774  return Dispersal(-1, random(FemaleMovement) + 1);
1775  }
1776  else return (Dispersal(Qual, 1 + random(FemaleMovement) + 1)); // returns 1 if it has died of extra dispersal mortality or starvation
1777 }
1778 //---------------------------------------------------------------------------
1779 
1780 
1786  m_OurPopulation->m_VoleMap->SetMapValue(m_Location_x,m_Location_y,this);
1787  };
1794  };
1799 inline bool Vole_JuvenileFemale::GetLocation(int px, int py) {
1800  if( m_OurPopulation->m_VoleMap->GetMapValue(px,py)!=NULL) return true;
1801  return false;
1802  };
1803 //---------------------------------------------------------------------------
1804 
1805 
1806 //---------------------------------------------------------------------------
1807 // Vole_Female
1808 //---------------------------------------------------------------------------
1817 int Vole_JuvenileFemale::Dispersal(double p_OldQual, int p_Distance)
1818 {
1819  // Returns 1 for die, 0 for carry on
1820  if (m_DispVector == -1) m_DispVector = random(8); // Choose direction 0-7
1821  // Go that far in that direction (assuming it is possible to do that)
1822  int oldx = m_Location_x;
1823  int oldy = m_Location_y;
1824  MoveTo(m_DispVector, p_Distance,10);
1825  // Now we are there so what is the new quality
1826  // 1. Get the carrying capacity
1828  if ( CC <= p_OldQual )
1829  {
1830  // Don't want to move
1831  FreeLocation();
1832  m_Location_x=oldx;
1833  m_Location_y=oldy;
1834  SetLocation();
1835  }
1836  else
1837  {
1838  if (g_rand_uni() < g_extradispmort )
1839  {
1841  return 1;
1842  }
1843  }
1844  return 0;
1845 }
1846 //---------------------------------------------------------------------------
1847 
1853 {
1854  m_NoOfYoung = 0;
1855  m_Pregnant = false;
1858  m_MatesIdNo = -1;
1860  m_Age = MinReproAgeF + 1;
1861  m_DaysUntilBirth = 0;
1862 #ifdef __VOLEPESTICIDEON
1863  Vole_Female::m_EndoCrineDisruptionGestationLength = cfg_VoleEndoCrineDisruptionGestationLength.value();
1864  m_pesticideloadindex = 0;
1865  for (int i = 0; i<21; i++) m_pesticideloadarray[i] = 0;
1866 #endif
1867 
1868 }
1869 //---------------------------------------------------------------------------
1871 {
1872  Init(p_aVoleStruct);
1873  m_NoOfYoung = 0;
1874  m_Pregnant = false;
1877  m_MatesIdNo = -1;
1879  m_Age = MinReproAgeF + 1;
1880  m_DaysUntilBirth = 0;
1881 #ifdef __VOLEPESTICIDEON
1882  Vole_Female::m_EndoCrineDisruptionGestationLength = cfg_VoleEndoCrineDisruptionGestationLength.value();
1883  m_pesticideloadindex = 0;
1884  for (int i = 0; i<21; i++) m_pesticideloadarray[i] = 0;
1885 #endif
1886 
1887 }
1888 //---------------------------------------------------------------------------
1889 
1890 
1892 {
1893  // Nothing to do
1894 }
1895 //---------------------------------------------------------------------------
1896 
1907 {
1908  if (m_StepDone) return;
1909  switch (CurrentVState)
1910  {
1911  case 0: // Initial state
1913  break;
1914  case tovs_FEvaluateExplore: // Evaluate & Explore
1915  switch(st_Evaluate_n_Explore())
1916  {
1917  case 1:
1918  CurrentVState=tovs_FDying; // Die
1919  break;
1920  case 2:
1922  CurrentVState=tovs_FDying; // Die
1923  break;
1924  default:
1925  CurrentVState=tovs_ReproBehaviour; // repro behaviour
1926  }
1927  m_StepDone=true;
1928  break;
1929  case tovs_ReproBehaviour: // ReproBehaviour
1931  break;
1932  case tovs_Lactating: // Lactating
1934  m_StepDone=true;
1935  break;
1936  case tovs_GiveBirth:
1938  m_StepDone=true; // wait until next day
1939  break;
1940  case tovs_FMaturation: // Maturation
1941  CurrentVState = st_BecomeReproductive(); // only returns Eval n Explore
1942  break;
1943  case tovs_Mating: // Mating
1944  CurrentVState = st_Mating(); // only returns Eval n Explore
1945  break;
1946  case tovs_UpdateGestation: // Update Gestation
1948  break;
1949  case tovs_SpecialExplore: // Special Explore
1951  CurrentVState = tovs_ReproBehaviour; // Repro behaviour
1952  m_StepDone=true;
1953  break;
1954  case tovs_FDying: // Die
1955  FreeLocation();
1956  m_StepDone=true;
1957  break;
1958  default:
1959  m_OurLandscape->Warn("Vole_Female::Step - unknown state",NULL);
1960  exit(9);
1961  }
1962 }
1963 //---------------------------------------------------------------------------
1964 
1975 {
1976  if (!m_Mature) return tovs_FMaturation; // Go to BecomeReproductive;
1977  else if (m_NoOfYoung>0) return tovs_Lactating; //Go to lactating
1978  else if ((!m_Pregnant) && (m_DaysUntilBirth==0)) return tovs_Mating; // Go to Mating;
1979  else return tovs_UpdateGestation; // Go to UpdateGestation;
1980 }
1981 //---------------------------------------------------------------------------
1982 
1983 
1992 {
1993  m_DaysUntilBirth--;
1994  if (m_DaysUntilBirth == 0) return tovs_GiveBirth; else return tovs_FEvaluateExplore;
1995 }
1996 //---------------------------------------------------------------------------
1997 
2006 {
2008  {
2009  if ( m_Age>= MinReproAgeF) {
2010  Setm_Mature();
2011  }
2012  }
2013  return tovs_FEvaluateExplore;
2014 }
2015 //---------------------------------------------------------------------------
2016 
2025 {
2026  // TODO must locate the nest position if this is considered important - currently it is set as the centre of the territory
2028  {
2029  // Must produce young
2030  int yr = 0;
2031  if (m_BornLastYear) yr = 1;
2033  m_Pregnant = false;
2034 #ifdef __VOLEPESTICIDEON
2036  {
2037  double dose = 0.0;
2038  double survive = 1.0;
2040  {
2041  for (int i = 0; i < 21; i++) dose += m_pesticideloadarray[i];
2042  dose /= 21;
2044  }
2045  else
2046  {
2047  dose = m_pesticideInfluenced3 - cfg_PesticideAccumulationThreshold.value();
2048  m_pesticideInfluenced3 = 0;
2049  }
2050  if (dose > 0) // this has the maximum dose received
2051  {
2052  // Calc dose response in terms of chance of death for individual offspring
2053  survive = 1 - (cfg_PesticideLitterSizeReduction.value() * dose);
2054  }
2055  // This applies the survival probability to each individual - why do we not do this to the litter as a whole
2056  // - this is because the probability may be too small to get a % response from e.g. 4 young
2057  int ny = 0;
2058  for (int y = 0; y < m_NoOfYoung; y++) if (g_rand_uni() < survive)
2059  {
2060  ny++;
2061  m_OurPopulation->AddToNotImpacted();
2062  }
2063  else m_OurPopulation->AddToImpacted();
2064  m_NoOfYoung = ny;
2065  }
2066  if (m_NoOfYoung > 0) m_OurPopulation->incLittersProduced(); else m_OurPopulation->incLittersLost();
2067 #endif
2068  // Must age young
2069  m_YoungAge = 0;
2070  // Update the YoungProduced Today Counter
2073  return tovs_ReproBehaviour; //NB if m_NoOfYoung is zero due to pesticide effects this will quietly be dealt with by the repro switch
2074  }
2075  else
2076  {
2077  m_NoOfYoung = 0;
2078  }
2079  m_Pregnant = false;
2080  return tovs_FEvaluateExplore;
2081 }
2082 //---------------------------------------------------------------------------
2091 {
2092  if( m_YoungAge++ >= WeanedAge )
2093  {
2094  struct_Vole_Adult* av;
2095  av = new struct_Vole_Adult;
2096  av->VPM = m_OurPopulation;
2097  av->L = m_OurLandscape;
2098  av->m_flag = true; // Used to signal pesticide effect to CreateObjects
2099 #ifdef __VOLEPESTICIDEON
2100  double mdelay = 0;
2102  {
2103  double dose = 0.0;
2104  double survive = 1.0;
2106  {
2107  for (int i=0; i<21; i++) dose+=m_pesticideloadarray[i];
2108  dose /=21;
2110  } else
2111  {
2112  dose = m_pesticideInfluenced3-cfg_PesticideAccumulationThreshold.value();
2113  m_pesticideInfluenced3=0;
2114  }
2115  if ( dose > 0 ) // this has the maximum dose received
2116  {
2117  // Calc dose response in terms of chance of death for individual offspring
2118  survive = 1-(cfg_PesticideWeaningReduction.value() * dose);
2119  mdelay = cfg_PesticideFemaleMaturityDelay.value() * dose;
2120  }
2121  // This applies the survival probability to each individual - why do we not do this to the litter as a whole
2122  // - this is because the probability may be too small to get a % response from e.g. 4 young
2123  int ny=0;
2124  for (int y=0; y<m_NoOfYoung; y++) if (g_rand_uni()<survive) ny++;
2125  m_NoOfYoung = ny;
2126  }
2127 #endif
2128  unsigned MotherIdNo = SupplyIDNo();
2129  unsigned FatherIdNo = SupplyMateId();
2130 
2131  // Create the new voles (50% chance of male/female)
2132  for (int i=0; i<m_NoOfYoung; i++)
2133  {
2137  av->FatherId = FatherIdNo;
2138  av->MotherId = MotherIdNo;
2139  av->x = ((m_Location_x+random(10))%m_OurPopulation->SimW);
2140  av->y = ((m_Location_y+random(10))%m_OurPopulation->SimH);
2141  // Do the genetics
2143  av->Genes.Mutation_4();
2144 #ifdef __Mutation
2145  //av->Genes256_16.Mutation_3(); // This is only one of a number of mutation types we can use
2146 #endif
2147  if (random(2)==1) // Even sex ratio
2148  {
2149  // Males
2150 #ifdef __VOLEPESTICIDEON
2152  {
2153  // If her mate was pesticide influenced then ensure all male offspring are also
2154  // by setting the gene on if we are useing Vinclozolin
2155  // If either the male was directly affected, or the female directly during gestation
2156  if ( m_pesticideInfluenced1 )
2157  {
2158  av->m_dflag = true;
2159  av->m_gflag = true;
2160  m_OurPopulation->AddToImpacted();
2161  }
2162  // Otherwise if the male was genetically affected
2163  else if (MatesGenes.GetGeneticFlag())
2164  {
2165  av->m_gflag = true;
2166  av->m_dflag=false;
2167  m_OurPopulation->AddToGeneticImpacted();
2168  }
2169  else
2170  {
2171  av->m_gflag=false;
2172  av->m_dflag=false;
2173  m_OurPopulation->AddToNotImpacted();
2174  }
2175  }
2177  {
2178  // If either the male was directly affected, or the female directly during gestation
2179  if ( m_pesticideInfluenced1 )
2180  {
2181  av->m_dflag = true;
2182  av->m_gflag = false;
2183  m_OurPopulation->AddToImpacted();
2184  }
2185  else
2186  {
2187  av->m_gflag=false;
2188  av->m_dflag=false;
2189  m_OurPopulation->AddToNotImpacted();
2190  }
2191  }
2192  else
2193  {
2194  av->m_gflag=false;
2195  av->m_dflag=false;
2196  }
2197 #endif
2199  }
2200  else {
2201 #ifdef __VOLEPESTICIDEON
2203  {
2204  av->misc_use = mdelay;
2205  }
2206  else av->misc_use = 0.0;
2207 #endif
2209  }
2210  }
2212  m_Reserves=0; // all reserves used up
2213  m_NoOfYoung=0; // No more young to feed
2214  delete av; // clean up
2215  return tovs_SpecialExplore; // CurrentVState=14 Special Explore
2216  }
2217  else return tovs_Lactating; // carry on feeding young
2218 }
2219 //---------------------------------------------------------------------------
2220 
2229 {
2230 #ifdef __USINGTRAPLINES
2231  CheckTraps();
2232 #endif
2233 /*
2234  unsigned MovementIndex;
2235  if (m_Age>90) MovementIndex=3;
2236  else if (m_Age>60) MovementIndex=2;
2237  else if (m_Age>30) MovementIndex=1;
2238  else MovementIndex=0;
2239 */
2241  // This function determines whether he must leave and whether he does
2242  // an explore. Will do this if he is not in optimal conditions
2243  if ( Qual <= m_MinFVoleHabQual )
2244  {
2245 
2246 #ifdef __VoleStarvationDays
2247  ++m_StarvationDays;
2248 #endif
2249  m_Have_Territory = false;
2250  // check an area MinFemaleMovement to FemaleMovement metres away
2251  m_DispVector = random(8);
2252  // Not quality dependent dispersal, very directed
2253  return Dispersal(-1,random(FemaleMovement)+ MinFemaleMovement);
2254  }
2255  else
2256  {
2257  m_Have_Territory = true;
2258 #ifdef __VoleStarvationDays
2259  m_StarvationDays = 0;
2260 #endif
2261  return (Dispersal(Qual,random(FemaleMovement)+ MinFemaleMovement)); // returns 1 if it has died of extra dispersal mortality or starvation
2262  }
2263 }
2264 //---------------------------------------------------------------------------
2265 
2274 {
2275  //The vole must now find a good territory
2276  // She will explore in all 8 directions from the nest and pick the best
2277  // from these and here present position
2278  unsigned coords[9][2];
2279  double qualities[9];
2280  // Check the quality here
2281  coords[8][0]=m_Location_x;
2282  coords[8][1]=m_Location_y;
2284  qualities[8]=-1;
2285  else
2286  {
2288  }
2289  // Now check the quality in all 8 directions
2290  unsigned steps = 2 * FemaleMovement+MinFemaleMovement;
2291  for (unsigned i=0; i<8; i++)
2292  {
2293  MoveTo(i,steps,10); // changes m_Location_x & y
2294  coords[i][0]=m_Location_x;
2295  coords[i][1]=m_Location_y;
2297  m_TerrRange))
2298  qualities[i]=-1;
2299  else
2300  {
2302  }
2303  }
2304  // find the best out of the nine qualities
2305  double best =qualities[8]; // here
2306  unsigned found=8; // default stay here
2307  for (unsigned i=0; i<8; i++)
2308  {
2309  if (qualities[i]>best)
2310  {
2311  best=qualities[i];
2312  found=i;
2313  }
2314  if (best>1)
2315  {
2316  if (m_Mature)
2317  {
2318  m_Have_Territory=true;
2319  }
2320  }
2321  else
2322  {
2323  m_Have_Territory=false;
2324  }
2325  FreeLocation();
2326  m_Location_x=coords[found][0];
2327  m_Location_y=coords[found][1];
2328  SetLocation();
2329  }
2330  return 0;
2331 }
2332 //---------------------------------------------------------------------------
2333 
2342 {
2343  //if it is the breeding season
2344  if ( m_BreedingSeason )
2345  {
2346  // Find a male if there is one
2347 
2348  Vole_Male* Mate=m_OurPopulation->FindClosestMale(m_Location_x, m_Location_y, m_MaxMaleTerritorySize); // Changed from a constant of 20 to her Territory range **//TD 090519
2349  // Get his genes if we found a mate
2350  if (Mate)
2351  {
2352  m_MatesGenes=Mate->SupplyGenes();
2353  m_MatesIdNo=Mate->SupplyIDNo();
2354 #ifdef __VOLEPESTICIDEON
2355  if (!Mate->GetFertile())
2356  {
2357  m_Pregnant = false;
2358  }
2359  else m_Pregnant = true;
2360 #else
2361  m_Pregnant = true;
2362 #endif
2364  }
2365  }
2366  return tovs_FEvaluateExplore;
2367 }
2368 //---------------------------------------------------------------------------
2369 
2381 {
2382  //try this if she has kids
2383  if (m_NoOfYoung)
2384  {
2385  if (m_YoungAge<9)
2386  {
2387  double mortchance=g_rand_uni();
2388  if (mortchance<=InfanticideChanceByAge[m_YoungAge])
2389  {
2391 
2392  // Young are killed
2393  m_NoOfYoung=0; // will cause the vole to be mated
2394  m_Pregnant=false;
2395  }
2396  }
2397  }
2398 }
2399 //---------------------------------------------------------------------------
2400 
2401 
2402 //---------------------------------------------------------------------------
2403 // Vole_Male
2404 //---------------------------------------------------------------------------
2405 
2414 {
2415  m_Age = p_aVoleStruct->age;
2416  m_Weight = p_aVoleStruct->weight;
2417  m_BirthYear = p_aVoleStruct->BirthYear;
2418  m_Sex = true;
2421 }
2422 //---------------------------------------------------------------------------
2423 
2424 void Vole_Male::ReInit(struct_Vole_Adult * p_aVoleStruct) {
2425  Init(p_aVoleStruct);
2426  m_Age = p_aVoleStruct->age;
2427  m_Weight = p_aVoleStruct->weight;
2428  m_BirthYear = p_aVoleStruct->BirthYear;
2429  m_Sex = true;
2432 }
2433 //---------------------------------------------------------------------------
2434 
2436 {
2437  // Nothing to do
2438 }
2439 //---------------------------------------------------------------------------
2440 
2451 {
2452  if (m_StepDone || m_CurrentStateNo == -1) return;
2453  switch (CurrentVState)
2454  {
2455  case tovs_InitialState: //initial state
2457  break;
2458  case tovs_MMaturation: // Maturation
2459  if (st_Maturation()) Setm_Mature();
2460  CurrentVState=tovs_MEvaluateExplore; // Eval and Explore
2461  break;
2462  case tovs_MEvaluateExplore: // Eval&Explore
2464  m_StepDone = true;
2465  break;
2466  case tovs_Infanticide: // Infanticide
2467  st_Infanticide();
2469  break;
2470  case tovs_MDying:
2471  FreeLocation();
2472  m_StepDone=true;
2473  break;
2474  default:
2475  m_OurLandscape->Warn("Vole_Male::Step - unknown return error",NULL);
2476  exit(1);
2477  }
2478 }
2479 //---------------------------------------------------------------------------
2480 
2491 {
2492 #ifdef __VoleStarvationDays
2493  if (m_Have_Territory) m_StarvationDays = 0;
2494  if ( m_StarvationDays > m_MaxStarvationDays)
2495  {
2496  st_Dying();
2498  }
2499  else
2500 #endif
2501  {
2502  CheckManagement();
2504  {
2505  st_Dying();
2506  }
2507  else
2508  {
2509  m_Age++;
2510  /* MALE GROWTH NOTES
2511 
2512  Male vole grows until 20g. After that he will only grow if he has matured
2513  Growth continues up to 60g.
2514 
2515  Reproduction cannot occur below 40g or 40 days
2516 
2517  Growth only occurs between 1 March and 1st August
2518  taken from Hanson L, 1977, Oikos 29.
2519  */
2520  int today = m_OurLandscape->SupplyDayInYear();
2521  if ((today < GrowStopDate) && (today > m_OurPopulation->SupplyGrowthStartDate()))
2522  {
2523  if (m_Weight<20)
2524  {
2526  }
2527  else if ((m_Mature==true) && (m_Weight<MaxWeightM))
2528  {
2530  }
2531  }
2532  else if ((today == 1)) {
2533  m_BornLastYear = true;
2534  m_Mature = true;
2535  }// must be true if alive on 1st Jan.
2537  }
2538  }
2539 }
2540 //---------------------------------------------------------------------------
2541 
2550 {
2552  m_OurPopulation->SupplyGrowthStartDate()) return 0;// don't mature
2553  else return 1; // matures
2554 }
2555 //---------------------------------------------------------------------------
2556 
2569 {
2570  if (g_rand_uni() < cfg_InfanticideProbability.value() ) {
2571  // int SearchInf =(int) m_TerrRange*cfg_InfanticideRangeRelToTerRange.value();
2573  }
2574 }
2575 //---------------------------------------------------------------------------
2576 
2585 {
2587 
2588  unsigned MovementIndex;
2589  if (m_Age>90) MovementIndex=3;
2590  else if (m_Age>60) MovementIndex=2;
2591  else if (m_Age>30) MovementIndex=1;
2592  else MovementIndex=0;
2593  int OldMales = m_OurPopulation->SupplyInOlderTerr(m_Location_x,m_Location_y,m_Age,m_TerrRange); // returns -1 if a male has p_x,p_y in his territory and is older than p_Age else returns the number of females present
2594  int NoFemales = OldMales;
2595  double Qual = CalculateCarryingCapacity(m_Location_x, m_Location_y,10000);
2596  //if (OldMales>1) Qual/=OldMales; // Share resources with the females, but no-one else
2597  if ( m_BreedingSeason )
2598  {
2599  if( m_Have_Territory ) // Must be mature
2600  {
2601  #ifdef __USINGTRAPLINES
2602  CheckTraps();
2603  #endif
2604  if (!m_Mature)
2605  {
2606  return tovs_MMaturation; // Special case, immature male in breeding season with territory will mature
2607  }
2608  // If he his mature then he must move if in an older males territory
2609  bool NoMates = false;
2610  if (NoFemales<1)
2611  {
2612  if ((g_rand_uni() < g_NoFemalesMove))
2613  {
2615  if (af!=NULL)
2616  {
2617  AnimalPosition ap = af->SupplyPosition();
2618  int tx=(SimW+ap.m_x+(random(2)-1))%SimW;
2619  int ty=(SimH+ap.m_y+(random(2)-1))%SimH;
2620  while ((GetLocation(tx,ty)) && (MoveQuality(tx,ty)<1))
2621  {
2622  tx=(SimW+tx+(random(2)-1))%SimW;
2623  ty=(SimH+ty+(random(2)-1))%SimH;
2624  }
2625  FreeLocation();
2626  m_Location_x=tx;
2627  m_Location_y=ty;
2628  SetLocation();
2629  } else NoMates = true;
2630  }
2631  } else
2632  if (((OldMales<1)|| (Qual<m_MinFVoleHabQual) || (NoMates)) && !m_BornLastYear) // In larger males territory, must move or are no females
2633  {
2634  m_Have_Territory = false;
2635  m_DispVector = random(8);
2636  retval = (Dispersal(Qual,MaleMovement[MovementIndex]));
2637  }
2638  }
2639  else
2640  {
2641  // No territory & Breeding season
2642  #ifdef __USINGTRAPLINES
2643  CheckTraps();
2644  #endif
2645  // Not quality dependent dispersal, very directed
2646  retval = (Dispersal(-1, MaleMovement[MovementIndex]));
2647  }
2648  }
2649  else // Not breeding season
2650  {
2651  #ifdef __USINGTRAPLINES
2652  CheckTraps();
2653  #endif
2654  if ( (OldMales<1) || (Qual < m_MinFVoleHabQual ))
2655  {
2656  #ifdef __VoleStarvationDays
2657  m_StarvationDays++;
2658  #endif
2659  retval = (Dispersal(-1,1+random(MaleMovement[MovementIndex])));
2660  }
2661  }
2662  // retval now holds the answer to the returning state
2663  switch (retval)
2664  {
2665  case vdisp_Mature:
2666  Setm_Mature();
2667  return tovs_Infanticide;
2668  case vdisp_Infanticide:
2669  return tovs_Infanticide;
2670  case vdisp_Die:
2671  return tovs_MDying;
2672  case vdisp_CarryOn:
2673  default:
2674  return CurrentVState;
2675  }
2676 }
2677 //---------------------------------------------------------------------------
2678 
2689 VoleDispersalReturns Vole_Male::Dispersal(double p_OldQual, int p_Distance)
2690 {
2691 
2692  // int retval = 0;
2693  // p_OldQuatells whether dispersal is conditional on quality or not
2694  // p_OldQual is set to old habitat quality or -1
2695  // p_Distance is the p_Distance used by the move function
2696  // aim is to move in a directed way traversing the landscape using the best
2697  // habitats
2698  // remember the old co-ordinates in case infanticide needs to be triggered
2699  int oldx = m_Location_x;
2700  int oldy = m_Location_y;
2701 #ifdef __VOLE_SMALL_LANDSCAPE
2702  m_DispVector = random(8); // Choose direction 0-7
2703 #else
2704  if (m_DispVector == -1) m_DispVector = random(8); // Choose direction 0-7
2705 #endif
2706  // Go that far in that direction (assuming it is possible to do that)
2707  MoveTo(m_DispVector, p_Distance, 10);
2708  // Now we are there so what is the new quality
2709  // 1. Get the carrying capacity
2710  int OldMales = 1;
2711  int NoFemales = 1;
2712  if (m_BreedingSeason)
2713  {
2715  NoFemales = OldMales; // If can be 0 or >0 if OldMales does not return 1
2716  }
2718  if (p_OldQual == -1)
2719  {
2720  // Do an extra mortality test if we are forced to disperse
2721  if (g_rand_uni() < g_extradispmort)
2722  {
2724  return vdisp_Die;
2725  }
2726  }
2727 
2728  if ((CC < p_OldQual) || (OldMales < 1) || (NoFemales < 1))
2729  {
2730  // Don't want to move
2731  FreeLocation();
2732  m_Location_x = oldx;
2733  m_Location_y = oldy;
2734  SetLocation();
2735  return vdisp_CarryOn;
2736  }
2737  else if (CC > m_MinMVoleHabQual)
2738  {
2739  m_Have_Territory = true;
2740  if (m_BreedingSeason)
2741  {
2742  if (!m_Mature)
2743  {
2744  return vdisp_Mature; // Will also trigger infanticde
2745  }
2746  if ((abs(oldx - m_Location_x) > (2 * m_TerrRange)) || (abs(oldy - m_Location_y) > (2 * m_TerrRange)))
2747  {
2748  // Have we moved more than _TerrRange from old home
2749  return vdisp_Infanticide; // This will result in an infanticide attempt if females in the new territory have young and the male has moved outside his old terr range.
2750  }
2751  }
2752  }
2753  return vdisp_CarryOn;
2754 }
2755 //---------------------------------------------------------------------------
2764 {
2765  // returns true if the vole should die
2766  if ( m_Have_Territory )
2767  {
2768  if (g_rand_uni() < g_DailyMortChanceMaleTerr) return true;
2769  }
2770  else if (g_rand_uni() < g_DailyMortChance) return true;
2771  return false;
2772 }
2773 //---------------------------------------------------------------------------
2779 {
2780  if (m_Weight < MinReproWeightM) return;
2782 }
2783 //---------------------------------------------------------------------------
2784 
2793 inline bool Vole_Male::CanFeed()
2794 {
2796  else return false;
2797 }
2798 //---------------------------------------------------------------------------
2799 
2801 {
2802  if (m_OurLandscape->SupplyYearNumber() < 10 ) return; // Don't sample until the population has stabilised
2803  int r = m_TerrRange;
2804  int vx = m_Location_x;
2805  int vy = m_Location_y;
2806  for (int rad = 0; rad <r; rad++) {
2807  // Two Loops
2808  for (int x = vx-rad; x<=vx+rad; x++) {
2809  int y = vy + rad;
2810  if (m_OurPopulation->IsTrap( x, y ) ) {
2811  if (random(1) == 0) {
2812  m_intrappos.m_x = x;
2813  m_intrappos.m_y = y;
2816  m_intrappos.m_inAtrap = true;
2817  return;
2818  }
2819  }
2820  y = vy - rad;
2821  if (m_OurPopulation->IsTrap( x, y ) ) {
2822  if (random(1) == 0) {
2823  m_intrappos.m_x = x;
2824  m_intrappos.m_y = y;
2827  m_intrappos.m_inAtrap = true;
2828  return;
2829  }
2830  }
2831  }
2832  for (int y = vy-(rad-1); y<=vy+(rad-1); y++) {
2833  int x = vx + rad;
2834  if (m_OurPopulation->IsTrap( x, y ) ) {
2835  if (random(1) == 0) {
2836  m_intrappos.m_x = x;
2837  m_intrappos.m_y = y;
2840  m_intrappos.m_inAtrap = true;
2841  return;
2842  }
2843  }
2844  x = vx - rad;
2845  if (m_OurPopulation->IsTrap( x, y ) ) {
2846  if (random(1) == 0) {
2847  m_intrappos.m_x = x;
2848  m_intrappos.m_y = y;
2851  m_intrappos.m_inAtrap = true;
2852  return;
2853  }
2854  }
2855  }
2856  }
2857 }
2858 
2859 /*
2860 *****************************************************************************************
2861 ******************************** Juvenile Male Code *************************************
2862 *****************************************************************************************
2863 */
2864 
2874 {
2875  // Just do some movement at first
2876  MoveTo(random(8),MinMaleMovement,20);
2877 }
2878 //---------------------------------------------------------------------------
2888 {
2889  switch(event)
2890  {
2891 case sleep_all_day:
2892  break;
2893 case autumn_plough:
2896  break;
2897 case autumn_harrow:
2900  break;
2901 case autumn_roll:
2904  break;
2905 case autumn_sow:
2908  break;
2909 case winter_plough:
2912  break;
2913 case deep_ploughing:
2916  break;
2917 case spring_plough:
2920  break;
2921 case spring_harrow:
2924  break;
2925 case spring_roll:
2928  break;
2929 case spring_sow:
2932  break;
2933 case fp_npks:
2934  break;
2935 case fp_npk:
2936  break;
2937 case fp_pk:
2938  break;
2939 case fp_liquidNH3:
2940  break;
2941 case fp_slurry:
2942  break;
2944  break;
2945 case fp_manure:
2946  break;
2947 case fp_greenmanure:
2948  break;
2949 case fp_sludge:
2950  break;
2951 case fa_npk:
2952  break;
2953 case fa_pk:
2954  break;
2955 case fa_slurry:
2956  break;
2957 case fa_ammoniumsulphate:
2958  break;
2959 case fa_manure:
2960  break;
2961 case fa_greenmanure:
2962  break;
2963 case fa_sludge:
2964  break;
2965 case glyphosate:
2966  break;
2967 case herbicide_treat:
2970  break;
2971 case growth_regulator:
2972  break;
2973 case fungicide_treat:
2974  break;
2975 case insecticide_treat:
2978  break;
2979 case molluscicide:
2980  break;
2981 case row_cultivation:
2984  break;
2985 case strigling:
2988  break;
2989 case hilling_up:
2992  break;
2993 case water:
2994  break;
2995 case swathing:
2998  break;
2999 case harvest:
3002  break;
3003 case cattle_out:
3004 case cattle_out_low:
3005  break;
3006 case cut_to_hay:
3009  break;
3010 case cut_to_silage:
3013  break;
3014 case straw_chopping:
3017  break;
3018 case hay_turning:
3021  break;
3022 case hay_bailing:
3025  break;
3026 case stubble_harrowing:
3029  break;
3033  break;
3034 case burn_straw_stubble:
3037  break;
3038 case mow:
3041  break;
3042 case cut_weeds:
3045  break;
3046 case pigs_out:
3049  break;
3050 case strigling_sow:
3053  break;
3055 case trial_toxiccontrol:
3056 case trial_control:
3057  break;
3058 default:
3059  g_msg->Warn( WARN_FILE, "Vole_JuvenileMale::OnFarmEvent(): Unknown event type:",
3061  exit( 1 );
3062  }
3063  if (CurrentVState==tovs_MDying) {
3065  return true;
3066  }
3067  else
3068  return false;
3069 }
3070 //----------------------------------------------------------------------------
3071 
3077  m_OurPopulation->m_VoleMap->SetMapValue(m_Location_x,m_Location_y,this);
3078  };
3079 //----------------------------------------------------------------------------
3080 
3087  };
3088 //----------------------------------------------------------------------------
3089 
3094 inline bool Vole_JuvenileMale::GetLocation(int px, int py) {
3095  if( m_OurPopulation->m_VoleMap->GetMapValue(px,py)!=NULL) return true;
3096  return false;
3097  };
3098 //---------------------------------------------------------------------------
3099 
3109 {
3110  if (MortalityTest())
3111  {
3114  m_StepDone=true;
3115  }
3116  else
3117  {
3118  if (--m_LifeSpan<1)
3119  {
3122  m_StepDone=true;
3123  }
3124  }
3125 #ifdef __VOLEPESTICIDEON
3126  PesticideIngestion();
3127  ActOnPesticideDose();
3128 #endif
3129 }
3130 //---------------------------------------------------------------------------
3131 
3142 {
3143  if (m_StepDone || m_CurrentStateNo == -1) return;
3144  switch (CurrentVState)
3145  {
3146  case tovs_InitialState: //initial state
3148  break;
3149  case tovs_JuvenileExploration: // Juvenile Exploration
3152  m_StepDone=true;
3153  break;
3154  case tovs_MEvaluateExplore: // Eval&Explore
3156  m_StepDone=true;
3157  break;
3158  case tovs_MMaturation:
3160  break;
3161  case tovs_MDying:
3162  FreeLocation();
3163  m_StepDone=true;
3164  break;
3165  default:
3166  m_OurLandscape->Warn("Vole_JuvenileMale::Step - unknown return error",NULL);
3167  exit(1);
3168  }
3169 }
3170 //---------------------------------------------------------------------------
3171 
3182 {
3183  CheckManagement();
3185  {
3186  st_Dying();
3187  }
3188  else
3189  {
3190  m_Age++;
3193  if (m_OurLandscape->SupplyDayInYear() == 1) {
3194  m_BornLastYear = true; // must be true if alive on 1st Jan.
3195  }
3196  }
3197 }
3198 //---------------------------------------------------------------------------
3199 
3210 {
3211 #ifdef __USINGTRAPLINES
3212  CheckTraps();
3213 #endif
3216  bool NoMates = false;
3217  if (NoFemales<1) if ((g_rand_uni() < g_NoFemalesMove)) NoMates = true;
3218  //if (NoFemales<1) NoMates = true;
3219  int OldMales = 1;
3220  OldMales = m_OurPopulation->SupplyInOlderTerr(m_Location_x, m_Location_y, m_Age, m_TerrRange); // returns -1 if a male has p_x,p_y in his territory and is older than p_Age else returns the number of females present
3221  if ((Qual < m_MinJMVoleHabQual) || (OldMales<1) || NoMates)
3222  //if ((Qual < m_MinJMVoleHabQual) || (OldMales < 1))
3223  {
3224  m_DispVector = random(8);
3225  // Not quality dependent dispersal, very directed
3226  return Dispersal(-1, random(MaleMovement[0]) + 1);
3227  }
3228  else return (Dispersal(Qual, 1 + random(MaleMovement[0]) + 1));
3229 }
3230 
3231 //---------------------------------------------------------------------------
3232 
3237 TTypeOfVoleState Vole_JuvenileMale::Dispersal(double p_OldQual, int p_Distance)
3238 {
3239  if (g_rand_uni() < g_extradispmort )
3240  {
3242  return tovs_MDying;
3243  }
3244  // Returns 1 for die, 0 for carry on
3245  if (m_DispVector == -1) m_DispVector = random(8); // Choose direction 0-7
3246  // Go that far in that direction (assuming it is possible to do that)
3247  int oldx = m_Location_x;
3248  int oldy = m_Location_y;
3249  MoveTo(m_DispVector, p_Distance,10);
3250  // Now we are there so what is the new quality
3251  // 1. Get the carrying capacity
3253  if ( CC <= p_OldQual )
3254  {
3255  // Don't want to move
3256  FreeLocation();
3257  m_Location_x=oldx;
3258  m_Location_y=oldy;
3259  SetLocation();
3260  }
3261  return tovs_MEvaluateExplore;
3262 }
3263 //---------------------------------------------------------------------------
3265 {
3266  struct_Vole_Adult* av;
3267  av = new struct_Vole_Adult;
3268  av->VPM = m_OurPopulation;
3269  av->L = m_OurLandscape;
3270  if (m_MyGenes.GetDirectFlag() == 0) av->m_dflag = false; else av->m_flag = true;
3271  if (m_MyGenes.GetGeneticFlag() == 0) av->m_gflag = false; else av->m_gflag = true;
3272  av->m_flag=true; // Used to signal pesticide effect to CreateObjects
3273  // Create the new voles (50% chance of male/female)
3277  av->FatherId = m_FatherId;
3278  av->MotherId = m_MotherId;
3279  av->x = m_Location_x;
3280  av->y = m_Location_y;
3281  av->weight = m_Weight;
3282  // Do the genetics
3283  av->Genes = m_MyGenes;
3284  av->age = m_Age;
3286  // Remove the current object
3288  FreeLocation();
3289  m_CurrentStateNo = -1;
3290  m_StepDone = true;
3291 
3292 }
3293 //---------------------------------------------------------------------------
3294 
3303 {
3306 }
3307 //---------------------------------------------------------------------------
3308 
3314 {
3315  m_Age = 14;
3317  m_Sex=true;
3320 }
3321 //---------------------------------------------------------------------------
3322 
3324  Init(p_aVoleStruct);
3325  m_Age = 14;
3327  m_Sex = true;
3330 }
3331 //---------------------------------------------------------------------------
3332 
3334 {
3335  // Nothing to do
3336 }
3337 //---------------------------------------------------------------------------
3338 #ifdef __VOLERODENTICIDEON
3339 //#####################################################################################
3340 //############################# RODENTICIDE HANDLING CODE ###############################
3341 //#####################################################################################
3342 
3344 {
3346  if (rodenticide>0) {
3347 
3348  // Todo effects
3349  }
3350  else return;
3351 }
3352 #endif
3353 
3354 #ifdef __VOLEPESTICIDEON
3355 //#####################################################################################
3356 //############################# PESTICIDE HANDLING CODE ###############################
3357 //#####################################################################################
3358 
3359 void Vole_Base::PesticideIngestion( void )
3360 {
3361  // If we are not running the pesticide module, then do nothing
3362  if ( !l_pest_enable_pesticide_engine.value()) return;
3363  BioDegradePesticide();
3374  double pest=0;
3375  pest =m_OurLandscape->SupplyPesticide( m_Location_x,m_Location_y, ppp_1); // ppp_1 is assumed. Units are mg/kg vegetation or mg/m2
3376  if (!cfg_pest_residue_or_rate.value())
3377  {
3378  /*
3379  // pest is is mg/m2 (corrected for wetweight)
3380  // veg is in g/m2
3381  // we need this in mg/kg body weight
3382  // mg/g veg = pest/veg
3383  // ingested mg (X) = pest/veg * 0.010425 * 1000
3384  // mg/kg = X/0.025 (vole weight in kg)
3385  pest*=g_SpeedyDivides[veg]; // assuming 70% is water
3386  */
3387  double veg= 1 + m_OurLandscape->SupplyVegBiomass( m_Location_x,m_Location_y ); // Units are g dw/m2, 1 added to avoid divide by zero
3388  veg *= 3.33333; // assuming 70% water
3389  pest *= g_SpeedyDivides[(int)veg]; // mg/kg ww
3390  }
3391  //pest *= 0.010425; // mg ingested
3392  //pest *= 40; // = 1/0.025 // mg/kg bw ingested
3393  m_pesticideload += pest; // add this to the current body burden
3394 }
3395 
3396 void Vole_Base::ActOnPesticideDose()
3397 {
3399  if ( tp == ttop_ModelinkPesticide21TWA ) ModelinkPesticide21TWA(m_pesticideload);
3400  else if (m_pesticideload > cfg_PesticideAccumulationThreshold.value())
3401  {
3402  switch (tp)
3403  {
3404  case ttop_NoPesticide:
3405  break;
3407  GeneralEndocrineDisruptor(m_pesticideload);
3408  break;
3409  case ttop_AcuteEffects:
3410  GeneralOrganophosphate(m_pesticideload);
3411  break;
3412  case ttop_Vinclozolin:
3413  Vinclozolin(m_pesticideload);
3414  break;
3416  ModelinkPesticide();
3417  break;
3418  case ttop_GeneticDemo:
3419  GeneticDemoPesticide(m_pesticideload);
3420  break;
3421  default:
3422  exit(47);
3423  }
3424  }
3425 }
3426 
3427 //*************************************************************************************
3428 //************************** PESTICIDE SPECIFIC EFFECT CODE ***************************
3429 //*************************************************************************************
3430 
3431 //-------------------------------------------------------------------------------------
3432 //------------------------------ MODELINKPESTICIDE EFFECT CODE ------------------------
3433 //-------------------------------------------------------------------------------------
3434 void Vole_JuvenileMale::ModelinkPesticide()
3435 {
3436  ; // No impact
3437 }
3438 
3439 void Vole_JuvenileMale::ModelinkPesticide21TWA(double /* a_dose */)
3440 {
3441  ; // No impact
3442 }
3443 
3444 void Vole_JuvenileFemale::ModelinkPesticide()
3445 {
3446  ; // No impact
3447 }
3448 
3449 void Vole_JuvenileFemale::ModelinkPesticide21TWA(double /* a_dose */)
3450 {
3451  ; // No impact
3452 }
3453 
3454 void Vole_Male::ModelinkPesticide()
3455 {
3456  ; // No impact
3457 }
3458 
3459 void Vole_Male::ModelinkPesticide21TWA(double /* a_dose */)
3460 {
3461  ; // No impact
3462 }
3463 
3464 void Vole_Female::ModelinkPesticide()
3465 {
3466  // Specify certain gestation days for the effects here
3467  if (((m_DaysUntilBirth>0) && (m_DaysUntilBirth<m_EndoCrineDisruptionGestationLength)) || (CurrentVState==tovs_Lactating) )
3468  {
3469  if (m_pesticideload > m_pesticideInfluenced3)
3470  {
3471  m_pesticideInfluenced3=m_pesticideload;
3472  }
3473  }
3474 }
3475 
3476 void Vole_Female::ModelinkPesticide21TWA(double /* a_dose */)
3477 {
3478  m_pesticideloadarray[m_pesticideloadindex++]=m_pesticideload;
3479  if (m_pesticideloadindex==21) m_pesticideloadindex=0;
3480 }
3481 
3482 //-------------------------------------------------------------------------------------
3483 //------------------------------ VINCLOZALIN EFFECT CODE ------------------------------
3484 //-------------------------------------------------------------------------------------
3485 void Vole_JuvenileMale::Vinclozolin(double /* a_dose */ )
3486 {
3487  ; // No impact
3488 }
3489 
3490 void Vole_JuvenileFemale::Vinclozolin(double /* a_dose */ )
3491 {
3492  ; // No impact
3493 }
3494 
3495 void Vole_Male::Vinclozolin(double /* a_dose */ )
3496 {
3497  ; // No impact
3498 }
3499 
3500 void Vole_Female::Vinclozolin(double /* a_dose */ )
3501 {
3502  // May also wish to specify certain gestation days for the effects here
3503  if ((m_DaysUntilBirth>0) && (m_DaysUntilBirth<m_EndoCrineDisruptionGestationLength))
3504  {
3505  m_pesticideInfluenced1 = true;
3506  }
3507 }
3508 
3509 //-------------------------------------------------------------------------------------
3510 //-------------------- GENERAL ENDOCRINE DISRUPTOR EFFECT CODE ------------------------
3511 //-------------------------------------------------------------------------------------
3512 
3513 void Vole_Female::GeneralEndocrineDisruptor(double /* a_dose */ )
3514 {
3515  // May also wish to specify certain gestation days for the effects here
3516  if ((m_DaysUntilBirth>0) && (m_DaysUntilBirth< m_EndoCrineDisruptionGestationLength))
3517  {
3518  m_pesticideInfluenced1 = true;
3519  }
3520 }
3521 
3522 void Vole_Male::GeneralEndocrineDisruptor(double /* a_dose */ )
3523 {
3524  ; // No effect
3525 }
3526 
3527 void Vole_JuvenileMale::GeneralEndocrineDisruptor(double /* a_dose */ )
3528 {
3529  ; // No effect
3530 }
3531 
3532 void Vole_JuvenileFemale::GeneralEndocrineDisruptor(double /* a_dose */ )
3533 {
3534  ; // No effect
3535 }
3536 
3537 
3538 
3539 //-------------------------------------------------------------------------------------
3540 //------------------------ GENERAL ORGANOPHOSPHATE EFFECT CODE ------------------------
3541 //-------------------------------------------------------------------------------------
3542 void Vole_JuvenileMale::GeneralOrganophosphate(double /* a_dose */)
3543 {
3544  if ( g_rand_uni() > l_pest_daily_mort.value() ) return;
3546  m_StepDone=true;
3548  return;
3549 }
3550 
3551 void Vole_JuvenileFemale::GeneralOrganophosphate(double /* a_dose */)
3552 {
3553  if ( g_rand_uni() > l_pest_daily_mort.value() ) return;
3555  m_StepDone=true;
3557  return;
3558 }
3559 
3560 void Vole_Male::GeneralOrganophosphate(double /* a_dose */)
3561 {
3562  if ( g_rand_uni() > l_pest_daily_mort.value() ) return;
3564  m_StepDone=true;
3566  return;
3567 }
3568 
3569 void Vole_Female::GeneralOrganophosphate(double /* a_dose */)
3570 {
3571  if ( g_rand_uni() > l_pest_daily_mort.value() ) return;
3573  m_StepDone=true;
3575  return;
3576 }
3577 
3578 void Vole_JuvenileMale::GeneticDemoPesticide(double /* a_dose */)
3579 {
3580  if ( g_rand_uni() > l_pest_daily_mort.value() ) return;
3581  if ( cfg_ResistanceDominant.value()){ if ((SupplyMyAllele(3,0) == 1) || (SupplyMyAllele(3,1) == 1)) return; }
3582  else
3583 
3584  {
3585  if ((SupplyMyAllele(3,0) == 1) && (SupplyMyAllele(3,1) == 1))
3586  {
3587  return;
3588  }
3589  }
3591  m_StepDone=true;
3593  return;
3594 }
3595 
3596 void Vole_JuvenileFemale::GeneticDemoPesticide(double /* a_dose */)
3597 {
3598  if ( g_rand_uni() > l_pest_daily_mort.value() ) return;
3599  if ( cfg_ResistanceDominant.value()) { if ((SupplyMyAllele(3,0) == 1) || (SupplyMyAllele(3,1) == 1)) return; }
3600  else if ((SupplyMyAllele(3,0) == 1) && (SupplyMyAllele(3,1) == 1))
3601  {
3602  return;
3603  }
3605  m_StepDone=true;
3607  return;
3608 }
3609 
3610 void Vole_Male::GeneticDemoPesticide(double /* a_dose */)
3611 {
3612  if ( g_rand_uni() > l_pest_daily_mort.value() ) return; // No effect triggered due probability
3613  if ( cfg_ResistanceDominant.value()) { if ((SupplyMyAllele(3,0) == 1) || (SupplyMyAllele(3,1) == 1)) return; } // If we assume a dominant resistant allele then if either are set there is no effect
3614  else if ((SupplyMyAllele(3,0) == 1) && (SupplyMyAllele(3,1) == 1))
3615  {
3616  return;
3617  }
3618  CurrentVState=tovs_MDying; // No save due to resistance so the vole dies
3619  m_StepDone=true;
3621  return;
3622 }
3623 
3624 void Vole_Female::GeneticDemoPesticide(double /* a_dose */)
3625 {
3626  if ( g_rand_uni() > l_pest_daily_mort.value() ) return; // No effect triggered due probability
3627  if ( cfg_ResistanceDominant.value()) { if ((SupplyMyAllele(3,0) == 1) || (SupplyMyAllele(3,1) == 1)) return; } // If we assume a dominant resistant allele then if either are set there is no effect
3628  else if ((SupplyMyAllele(3,0) == 1) && (SupplyMyAllele(3,1) == 1))
3629  {
3630  return;
3631  }
3632  CurrentVState=tovs_FDying; // No save due to resistance so the vole dies
3633  m_StepDone=true;
3635  return;
3636 }
3637 
3638 //#####################################################################################
3639 //########################### END PESTICIDE HANDLING CODE #############################
3640 //#####################################################################################
3641 
3642 #endif
Landscape::SupplyVegCoverVector
double SupplyVegCoverVector(unsigned int a_index)
Definition: Landscape.h:1053
TTypesOfPesticide
TTypesOfPesticide
Definition: Landscape.h:65
insecticide_treat
Definition: treatment.h:74
growthperdayM
const double growthperdayM
Definition: Vole_all.cpp:139
Vole_Base::m_LifeSpan
int m_LifeSpan
Definition: vole_all.h:190
Vole_Base::Set_ElemBorn
void Set_ElemBorn(int a_Location_x, int a_Location_y)
Definition: vole_all.h:315
cfg_RipleysOutput_used
CfgBool cfg_RipleysOutput_used
tole_HedgeBank
Definition: tole_declaration.h:68
tole_UrbanNoVeg
Definition: tole_declaration.h:78
vob_JuvenileFemale
Definition: vole_all.h:101
Vole_Base::RodenticideIngestion
virtual void RodenticideIngestion(void)
Definition: Vole_all.cpp:3343
tole_Saltwater
Definition: tole_declaration.h:66
tovmort_MPest
Definition: VolePopulationManager.h:85
g_rand_uni
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
Vole_Base::m_MotherId
unsigned m_MotherId
Definition: vole_all.h:166
TTypeOfVoleState
TTypeOfVoleState
Vole behavioural states.
Definition: vole_all.h:55
Vole_Base::~Vole_Base
virtual ~Vole_Base()
Definition: Vole_all.cpp:304
tole_UnsprayedFieldMargin
Definition: tole_declaration.h:72
Vole_Population_Manager::IsTrap
bool IsTrap(int p_x, int p_y)
Definition: VolePopulationManager.h:207
MinReproAgeM
int MinReproAgeM
Definition: Vole_all.cpp:145
strigling
Definition: treatment.h:77
cfg_PesticideAccumulationThreshold2
static CfgFloat cfg_PesticideAccumulationThreshold2("VOLE_PESTICDEACCUMULATIONTHRESHOLDTWO", CFG_CUSTOM, 44.1)
cfg_PesticideLitterSizeReduction
static CfgFloat cfg_PesticideLitterSizeReduction("VOLE_PCIDE_LITTERSIZEREDUCTION", CFG_CUSTOM, 0.0038)
hay_bailing
Definition: treatment.h:89
ttop_ReproductiveEffects
Definition: Landscape.h:69
ttop_GeneticDemo
Definition: Landscape.h:73
MinReproAgeF
int MinReproAgeF
Definition: Vole_all.cpp:147
autumn_roll
Definition: treatment.h:38
Vector_y
const int Vector_y[8]
tole_Building
Definition: tole_declaration.h:62
Vole_Population_Manager::SupplyCountFemales
int SupplyCountFemales(unsigned p_x, unsigned p_y, unsigned p_TerrRange)
Definition: VolePopulationManager.cpp:2897
tovmort_MPred
Definition: VolePopulationManager.h:81
tole_Freshwater
Definition: tole_declaration.h:64
Vole_Base::CurrentVState
TTypeOfVoleState CurrentVState
Definition: vole_all.h:407
tov_OPermanentGrassGrazed
Definition: tov_declaration.h:44
Landscape::SupplyVegType
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: Landscape.h:1321
tovs_MDying
Definition: vole_all.h:63
Landscape::SupplyElementType
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: Landscape.h:1110
tole_Parkland
Definition: tole_declaration.h:77
Vole_Base::m_MinTerrRange
unsigned int m_MinTerrRange
Definition: vole_all.h:164
tole_StoneWall
Definition: tole_declaration.h:56
Vole_Female::SupplyMateId
int SupplyMateId()
Definition: vole_all.h:579
Vole_Population_Manager::FindClosestFemale
Vole_Female * FindClosestFemale(int p_x, int p_y, int p_steps)
Definition: VolePopulationManager.cpp:2227
cfg_productapplicendyear
CfgInt cfg_productapplicendyear
MinReproWeightF
const int MinReproWeightF
Definition: Vole_all.cpp:151
FemNoMature
const int FemNoMature
Definition: Vole_all.cpp:123
tole_RiversidePlants
Definition: tole_declaration.h:49
tole_FishFarm
Definition: tole_declaration.h:102
Vole_Base::MoveTo
void MoveTo(int p_Vector, int p_Distance, int iterations)
Movement.
Definition: Vole_all.cpp:907
tole_Garden
Definition: tole_declaration.h:58
ttop_NoPesticide
Definition: Landscape.h:67
tole_Churchyard
Definition: tole_declaration.h:86
Landscape::SupplyVegHeightVector
double SupplyVegHeightVector(unsigned int a_index)
Definition: Landscape.h:931
TheGestationPeriod
const unsigned TheGestationPeriod
Definition: Vole_all.cpp:127
tovs_GiveBirth
Definition: vole_all.h:68
Vole_Base
Base class for voles - all vole objects are descended from this class.
Definition: vole_all.h:152
fa_ammoniumsulphate
Definition: treatment.h:65
tole_RoadsideSlope
Definition: tole_declaration.h:83
vob_Female
Definition: vole_all.h:103
Vole_Base::m_BirthYear
int m_BirthYear
Definition: vole_all.h:157
autumn_harrow
Definition: treatment.h:37
Vole_Base::CheckTraps
void CheckTraps()
Definition: Vole_all.cpp:2800
Vole_JuvenileMale::SetLocation
virtual void SetLocation()
Map location function.
Definition: Vole_all.cpp:3076
tole_MixedForest
Definition: tole_declaration.h:53
cfg_vole_habqualscaler
static CfgFloat cfg_vole_habqualscaler("VOLE_HABQUALSCALER", CFG_CUSTOM, 2.1)
cfg_ResistanceDominant
CfgBool cfg_ResistanceDominant("VOLE_RESISTANCEDOMINANT", CFG_CUSTOM, false)
tovs_ReproBehaviour
Definition: vole_all.h:66
Vole_JuvenileMale::st_Eval_n_Explore
TTypeOfVoleState st_Eval_n_Explore(void)
JuvenileMale vole main territory assessment behaviour.
Definition: Vole_all.cpp:3209
tovs_FEvaluateExplore
Definition: vole_all.h:65
Vole_Female::m_MatesGenes
GeneticMaterial m_MatesGenes
The DNA passed from the male on mating.
Definition: vole_all.h:616
Vole_Population_Manager::SupplyGrowthStartDate
int SupplyGrowthStartDate()
Definition: VolePopulationManager.h:237
Vole_Base::m_Mature
bool m_Mature
Definition: vole_all.h:176
tovm_Infanticide
Definition: VolePopulationManager.h:65
autumn_sow
Definition: treatment.h:41
tole_Copse
Definition: tole_declaration.h:82
Vole_JuvenileMale::Dispersal
TTypeOfVoleState Dispersal(double p_OldQual, int p_Distance)
JuvenileMale vole dispersal behaviour.
Definition: Vole_all.cpp:3237
glyphosate
Definition: treatment.h:102
MinReproWeightM
const unsigned MinReproWeightM
Definition: Vole_all.cpp:149
tovmort_MLife
Definition: VolePopulationManager.h:83
vob_JuvenileMale
Definition: vole_all.h:100
harvest
Definition: treatment.h:82
l_pest_enable_pesticide_engine
CfgBool l_pest_enable_pesticide_engine
tole_BareRock
Definition: tole_declaration.h:75
Vole_JuvenileFemale::EndStep
virtual void EndStep()
Female vole EndStep.
Definition: Vole_all.cpp:1474
VoleSoilCultivationMort
const double VoleSoilCultivationMort
Definition: Vole_all.cpp:196
tole_Saltmarsh
Definition: tole_declaration.h:88
Landscape::SupplyJustMownVector
bool SupplyJustMownVector(unsigned int a_index)
Definition: Landscape.h:1258
cfg_VoleDDepConst
CfgInt cfg_VoleDDepConst("VOLE_DDEPCONST", CFG_CUSTOM, 4)
Vole_Base::Setm_Mature
void Setm_Mature()
Definition: vole_all.h:300
tovmort_MFarm
Definition: VolePopulationManager.h:77
Vole_Population_Manager::SupplyInOlderTerr
int SupplyInOlderTerr(unsigned p_x, unsigned p_y, unsigned p_Age, unsigned p_Range)
Definition: VolePopulationManager.cpp:3043
Vole_Base::ReInit
virtual void ReInit(struct_Vole_Adult *p_aVoleStruct)
Definition: Vole_all.cpp:235
vob_Male
Definition: vole_all.h:102
VoleSummaryOutput::ChangeData
void ChangeData(int a_data, int a_value)
Definition: VolePopulationManager.cpp:4048
TAnimal::m_OurLandscape
Landscape * m_OurLandscape
Definition: PopulationManager.h:229
cfg_InfanticideRangeRelToTerRange
static CfgFloat cfg_InfanticideRangeRelToTerRange("VOLE_IINFANTICIDERANGE_RELTO_TERRANGE", CFG_CUSTOM, 0.5)
fp_slurry
Definition: treatment.h:52
Vole_Population_Manager::GetHabitatQuality
double GetHabitatQuality(int a_index)
Definition: VolePopulationManager.h:233
tov_OCloverGrassSilage1
Definition: tov_declaration.h:43
Vole_Base::m_MinJMVoleHabQual
static double m_MinJMVoleHabQual
Definition: vole_all.h:226
Vole_JuvenileFemale::ReInit
virtual void ReInit(struct_Vole_Adult *p_aVoleStruct)
Definition: Vole_all.cpp:1363
Vole_Female::st_Evaluate_n_Explore
int st_Evaluate_n_Explore()
Main territory evaluation behaviour.
Definition: Vole_all.cpp:2228
tovs_UpdateGestation
Definition: vole_all.h:71
tole_Railway
Definition: tole_declaration.h:39
Vole_JuvenileFemale::GetLocation
virtual bool GetLocation(int px, int py)
Location map function.
Definition: Vole_all.cpp:1799
WeanedWeight
const int WeanedWeight
Definition: Vole_all.cpp:131
tole_RoadsideVerge
Definition: tole_declaration.h:38
MaleMovement
const unsigned MaleMovement[4]
Definition: Vole_all.cpp:179
g_extradispmort
double g_extradispmort
Definition: Vole_all.cpp:204
tole_Pylon
Definition: tole_declaration.h:96
Vole_Population_Manager::AddToNoYoungInfanticideCount
void AddToNoYoungInfanticideCount(int m_NoOfYoung, int m_YoungAge)
Definition: VolePopulationManager.h:256
Vole_Base::GetFertile
bool GetFertile()
Get the male vole fertility.
Definition: vole_all.h:424
fa_sludge
Definition: treatment.h:68
tov_OCloverGrassGrazed2
Definition: tov_declaration.h:43
struct_Vole_Adult
A struct for passing data to create a new vole.
Definition: vole_all.h:122
fp_greenmanure
Definition: treatment.h:56
AnimalPosition::m_x
unsigned m_x
Definition: PopulationManager.h:172
VoleMoveInterval
const unsigned VoleMoveInterval
Definition: Vole_all.cpp:177
Vole_Base::m_MyGenes
GeneticMaterial m_MyGenes
Definition: vole_all.h:213
tole_WindTurbine
Definition: tole_declaration.h:97
tole_ActivePit
Definition: tole_declaration.h:63
tovs_Infanticide
Definition: vole_all.h:62
Vole_Female::m_YoungAge
unsigned m_YoungAge
The age of current litter in days.
Definition: vole_all.h:611
hay_turning
Definition: treatment.h:88
Vole_JuvenileMale::GetLocation
virtual bool GetLocation(int px, int py)
Map location function.
Definition: Vole_all.cpp:3094
Vole_Base::SupplyIDNo
int SupplyIDNo()
Definition: vole_all.h:364
g_NoFemalesMove
double g_NoFemalesMove
Definition: Vole_all.cpp:205
VoleHarvestMort
const double VoleHarvestMort
Definition: Vole_all.cpp:192
GrowStopDate
const int GrowStopDate
Definition: Vole_all.cpp:143
Vole_Male::ReInit
virtual void ReInit(struct_Vole_Adult *p_aVoleStruct)
Definition: Vole_all.cpp:2424
g_SpeedyDivides
double g_SpeedyDivides[2001]
A generally useful array of fast divide calculators by multiplication.
Definition: Landscape.cpp:250
Vole_Population_Manager::SendMessage
void SendMessage(TTypeOfVoleMessage p_message, unsigned p_x, unsigned p_y, unsigned p_range, bool p_sex, double p_Weight)
Definition: VolePopulationManager.cpp:3404
struct_Vole_Adult::weight
double weight
Definition: vole_all.h:128
tovmort_FDisp
Definition: VolePopulationManager.h:80
water
Definition: treatment.h:80
Landscape::SupplyJustSprayedVector
int SupplyJustSprayedVector(unsigned int a_index)
Definition: Landscape.h:1270
Vole_Base::Set_MotherId
void Set_MotherId(unsigned MotherIdNo)
Definition: vole_all.h:305
Vole_JuvenileFemale
The class for female voles.
Definition: vole_all.h:528
tovs_SpecialExplore
Definition: vole_all.h:72
fp_liquidNH3
Definition: treatment.h:51
tovs_InitialState
Definition: vole_all.h:57
GeneticMaterial::GetDirectFlag
uint32 GetDirectFlag()
Definition: GeneticMaterial.cpp:191
tole_MownGrass
Definition: tole_declaration.h:74
Vole_Base::Set_XBorn
void Set_XBorn(int a_Location_x)
Definition: vole_all.h:311
Vole_Base::GetLocation
virtual bool GetLocation(int, int)
Definition: vole_all.h:441
molluscicide
Definition: treatment.h:75
Vole_Base::m_Have_Territory
bool m_Have_Territory
Definition: vole_all.h:204
Vole_Female::~Vole_Female
virtual ~Vole_Female()
Definition: Vole_all.cpp:1891
Vole_Base::EndStep
virtual void EndStep()
All voles age at the end of the day.
Definition: Vole_all.cpp:336
Vole_Base::m_Weight
double m_Weight
Definition: vole_all.h:192
g_MaleReproductFinish
int g_MaleReproductFinish
Definition: Vole_all.cpp:183
burn_straw_stubble
Definition: treatment.h:92
cfg_PesticideAccumulationThreshold
static CfgFloat cfg_PesticideAccumulationThreshold("VOLE_PESTICDEACCUMULATIONTHRESHOLD", CFG_CUSTOM, 20.0)
tole_YoungForest
Definition: tole_declaration.h:55
Population_Manager::SimW
int SimW
Definition: PopulationManager.h:511
tole_Stream
Definition: tole_declaration.h:89
tovs_JuvenileExploration
Definition: vole_all.h:59
Vole_Population_Manager::AddToYoung
void AddToYoung(int young)
Definition: VolePopulationManager.h:250
Vole_Population_Manager::CreateObjects
void CreateObjects(VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult *as, int number)
Definition: VolePopulationManager.cpp:3455
tole_Foobar
Definition: tole_declaration.h:111
Vole_Base::Set_YBorn
void Set_YBorn(int a_Location_y)
Definition: vole_all.h:313
tole_ConiferousForest
Definition: tole_declaration.h:54
Vole_Base::m_MaxFemaleTerritorySize
static unsigned int m_MaxFemaleTerritorySize
Definition: vole_all.h:218
Vole_Base::Set_VegBorn
void Set_VegBorn(int a_Location_x, int a_Location_y)
Definition: vole_all.h:321
Vole_JuvenileFemale::st_Evaluate_n_Explore
int st_Evaluate_n_Explore()
Main territory evaluation behaviour.
Definition: Vole_all.cpp:1760
Vole_Female::m_NoOfYoung
int m_NoOfYoung
The number of young in the current litter (if one).
Definition: vole_all.h:596
MaxWeightM
const double MaxWeightM
Definition: Vole_all.cpp:133
Vole_Female
The class for female voles.
Definition: vole_all.h:570
cattle_out_low
Definition: treatment.h:100
Vole_Male::st_Maturation
int st_Maturation(void)
Male vole maturation control.
Definition: Vole_all.cpp:2549
tole_LargeRoad
Definition: tole_declaration.h:61
Landscape::SupplyVegTypeVector
TTypesOfVegetation SupplyVegTypeVector(unsigned int a_index)
Definition: Landscape.h:1220
Vole_JuvenileFemale::Dispersal
int Dispersal(double p_OldQual, int p_Distance)
Female dispersal.
Definition: Vole_all.cpp:1817
Vole_JuvenileMale::~Vole_JuvenileMale
virtual ~Vole_JuvenileMale()
Definition: Vole_all.cpp:3333
Vole_Female::st_Lactating
TTypeOfVoleState st_Lactating()
Lactation.
Definition: Vole_all.cpp:2090
cfg_VoleResourceRegrowth
CfgFloat cfg_VoleResourceRegrowth("VOLE_RESOURCEREGROWTH", CFG_CUSTOM, 0.5)
A parameter determining the density dependence effect. Zero will have no density dependence effect,...
InfanticideChanceByAge
const double InfanticideChanceByAge[9]
Definition: Vole_all.cpp:185
tovs_Mating
Definition: vole_all.h:70
fp_pk
Definition: treatment.h:50
fa_npk
Definition: treatment.h:61
cattle_out
Definition: treatment.h:83
Vole_Male::CanFeed
bool CanFeed()
Currently not used.
Definition: Vole_all.cpp:2793
VoleDispersalReturns
VoleDispersalReturns
Definition: vole_all.h:78
Vole_Female::m_MatesIdNo
int m_MatesIdNo
Definition: vole_all.h:591
Vole_Base::FreeLocation
virtual void FreeLocation()
Definition: vole_all.h:440
VoleStriglingMort
const double VoleStriglingMort
Definition: Vole_all.cpp:194
MaxWeightF
const double MaxWeightF
Definition: Vole_all.cpp:135
Vole_Base::MoveQuality
int MoveQuality(int p_x, int p_y)
Test a location for quality while moving.
Definition: Vole_all.cpp:1207
Vole_Base::m_MaleTerritoryRangeSlope
static double m_MaleTerritoryRangeSlope
Definition: vole_all.h:230
Landscape::SupplyGrazingPressureVector
int SupplyGrazingPressureVector(unsigned int a_index)
Definition: Landscape.h:1232
ttop_ModelinkPesticide21TWA
Definition: Landscape.h:72
Vole_JuvenileFemale::st_BecomeSubAdult
void st_BecomeSubAdult(void)
Definition: Vole_all.cpp:1725
fp_npk
Definition: treatment.h:49
struct_Vole_Adult::m_gflag
bool m_gflag
Definition: vole_all.h:143
cfg_extradispmort
CfgFloat cfg_extradispmort("VOLEDISPMORT", CFG_CUSTOM, 0.055)
Input parameter for daily extra mortality chance while dispersing.
Vole_Female::st_Special_Explore
int st_Special_Explore()
Post weaning territory expansion.
Definition: Vole_all.cpp:2273
stubble_harrowing
Definition: treatment.h:90
struct_Vole_Adult::misc_use
double misc_use
Definition: vole_all.h:145
Vole_Base::SupplyMyAllele
uint32 SupplyMyAllele(int i, int j)
Definition: vole_all.h:387
tole_Marsh
Definition: tole_declaration.h:41
Landscape::SupplyPesticide
double SupplyPesticide(int a_x, int a_y, PlantProtectionProducts a_ppp)
Gets total pesticide for a location.
Definition: Landscape.cpp:586
TTypesOfVegetation
TTypesOfVegetation
Definition: tov_declaration.h:30
tole_OrchardBand
Definition: tole_declaration.h:73
struct_Vole_Adult::Genes
GeneticMaterial Genes
Definition: vole_all.h:141
autumn_plough
Definition: treatment.h:34
tole_Pond
Definition: tole_declaration.h:101
cfg_RecordVoleMort
CfgBool cfg_RecordVoleMort
fp_manure
Definition: treatment.h:55
TAnimal::m_Location_y
int m_Location_y
Definition: PopulationManager.h:228
l_pest_daily_mort
CfgFloat l_pest_daily_mort
strigling_sow
Definition: treatment.h:95
g_DailyMortChance
double g_DailyMortChance
Definition: Vole_all.cpp:189
tovmort_FPest
Definition: VolePopulationManager.h:86
tovs_FDying
Definition: vole_all.h:73
Vole_Female::st_ReproBehaviour
TTypeOfVoleState st_ReproBehaviour()
Reproductive switch.
Definition: Vole_all.cpp:1974
VoleHerbicicideMort
const double VoleHerbicicideMort
Definition: Vole_all.cpp:200
vdisp_CarryOn
Definition: vole_all.h:79
tole_PermPasture
Definition: tole_declaration.h:47
cfg_VoleEndoCrineDisruptionGestationLength
static CfgInt cfg_VoleEndoCrineDisruptionGestationLength("VOLE_ENDOCRINEDISPRUPTORGESTATION", CFG_CUSTOM, 21)
WeanedAge
const unsigned WeanedAge
Definition: Vole_all.cpp:129
cfg_vole_LifeMonths
static CfgInt cfg_vole_LifeMonths("VOLE_LIFEMONTHS", CFG_CUSTOM, 3)
Vole_Base::m_MinMaleTerritorySize
static unsigned int m_MinMaleTerritorySize
Definition: vole_all.h:220
struct_Vole_Adult::FatherId
int FatherId
Definition: vole_all.h:135
TAnimal
The base class for all ALMaSS animal classes.
Definition: PopulationManager.h:205
Vole_Base::SupplyGenes
GeneticMaterial SupplyGenes()
Definition: vole_all.h:402
cfg_productapplicstartyear
CfgInt cfg_productapplicstartyear
Vole_Male::EndStep
virtual void EndStep()
Male vole EndStep.
Definition: Vole_all.cpp:2490
MinMaleMovement
const unsigned MinMaleMovement
Definition: Vole_all.cpp:181
winter_plough
Definition: treatment.h:42
tovs_FMaturation
Definition: vole_all.h:69
cfg_MaxMaleTerrSize
static CfgInt cfg_MaxMaleTerrSize("VOLE_MAXMALETERRITORYSIZE", CFG_CUSTOM, 23)
vdisp_Die
Definition: vole_all.h:80
struct_Vole_Adult::VPM
Vole_Population_Manager * VPM
Definition: vole_all.h:139
AnimalPosition
A class defining an animals position.
Definition: PopulationManager.h:168
Vole_JuvenileFemale::~Vole_JuvenileFemale
virtual ~Vole_JuvenileFemale()
Definition: Vole_all.cpp:1378
Vole_Base::m_DispVector
int m_DispVector
Definition: vole_all.h:202
tovmort_FBck
Definition: VolePopulationManager.h:76
tole_PermanentSetaside
Definition: tole_declaration.h:46
cfg_PesticideFemaleMaturityDelay
static CfgFloat cfg_PesticideFemaleMaturityDelay("VOLE_PCIDE_FEMALEMATURITYDELAY", CFG_CUSTOM, 0.0192)
GeneticMaterial::GetGeneticFlag
uint32 GetGeneticFlag()
Definition: GeneticMaterial.cpp:187
tov_PermanentGrassGrazed
Definition: tov_declaration.h:49
tole_UrbanPark
Definition: tole_declaration.h:79
tov_CloverGrassGrazed2
Definition: tov_declaration.h:33
tole_Track
Definition: tole_declaration.h:59
tovmort_MDisp
Definition: VolePopulationManager.h:79
struct_Vole_Adult::BirthYear
int BirthYear
Definition: vole_all.h:134
Vole_Base::DoWalking
void DoWalking(int p_Distance, int &p_Vector, int &vx, int &vy)
Walking.
Definition: Vole_all.cpp:953
Vole_Population_Manager::ReproTable
int ReproTable[4][12]
Definition: VolePopulationManager.h:221
Vole_Population_Manager::SupplyOlderFemales
bool SupplyOlderFemales(unsigned p_x, unsigned p_y, unsigned p_Age, unsigned p_range)
Definition: VolePopulationManager.cpp:1015
Landscape::SupplyRodenticide
double SupplyRodenticide(int a_x, int a_y)
Gets total rodenticide for a location.
Definition: Landscape.cpp:492
tovmort_FLife
Definition: VolePopulationManager.h:84
fp_sludge
Definition: treatment.h:57
ttop_Vinclozolin
Definition: Landscape.h:70
straw_chopping
Definition: treatment.h:87
Vole_Base::m_MinFVoleHabQual
static double m_MinFVoleHabQual
Definition: vole_all.h:224
fungicide_treat
Definition: treatment.h:73
deep_ploughing
Definition: treatment.h:43
Landscape::SupplyDayInYear
int SupplyDayInYear(void)
Definition: Landscape.h:1596
Landscape::SupplyVegBiomass
double SupplyVegBiomass(int a_polyref)
Definition: Landscape.h:953
Vole_JuvenileFemale::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
External event handler.
Definition: Vole_all.cpp:1529
cfg_MaxStarvationDays
static CfgInt cfg_MaxStarvationDays("VOLE_MAXSTARVATIONDAYS", CFG_CUSTOM, 29)
mow
Definition: treatment.h:93
fa_pk
Definition: treatment.h:62
Vole_Base::st_Dying
void st_Dying()
All voles end here on death.
Definition: Vole_all.cpp:348
Vole_Population_Manager::FindClosestMale
Vole_Male * FindClosestMale(int p_x, int p_y, int p_steps)
Definition: VolePopulationManager.cpp:2686
TALMaSSObject::m_StepDone
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: PopulationManager.h:118
Landscape::SupplyPesticideType
TTypesOfPesticide SupplyPesticideType(void)
Definition: Landscape.h:433
Vole_Population_Manager::IDNumber
unsigned IDNumber
Definition: VolePopulationManager.h:222
TAnimal::SupplyPosition
AnimalPosition SupplyPosition()
Definition: PopulationManager.cpp:1345
Vole_Base::m_Sex
bool m_Sex
Definition: vole_all.h:174
spring_harrow
Definition: treatment.h:45
Vole_JuvenileFemale::OnKilled
virtual void OnKilled()
Death from external entity.
Definition: Vole_all.cpp:1718
Vole_JuvenileMale::OnKilled
virtual void OnKilled()
JuvenileMale vole death by external entity.
Definition: Vole_all.cpp:3302
Landscape::SupplyYearNumber
int SupplyYearNumber(void)
Definition: Landscape.h:1616
VoleInsecticideMort
const double VoleInsecticideMort
Definition: Vole_all.cpp:202
Vole_Male::~Vole_Male
virtual ~Vole_Male()
Definition: Vole_all.cpp:2435
tole_NaturalGrassWet
Definition: tole_declaration.h:87
Vole_Base::Vole_Base
Vole_Base(struct_Vole_Adult *p_aVoleStruct)
Constructor for Vole_Base.
Definition: Vole_all.cpp:228
Vole_Male::st_Infanticide
void st_Infanticide(void)
Male vole infanticide behaviour.
Definition: Vole_all.cpp:2568
tole_Orchard
Definition: tole_declaration.h:71
Vole_JuvenileMale::Step
virtual void Step()
Juvenile Male vole Step.
Definition: Vole_all.cpp:3141
Vole_Base::m_MaxMaleTerritorySize
static unsigned int m_MaxMaleTerritorySize
Definition: vole_all.h:216
tole_MetalledPath
Definition: tole_declaration.h:84
Vole_Female::m_Pregnant
bool m_Pregnant
A flag indicating whether pregnant or not.
Definition: vole_all.h:601
AnimalPosition::m_EleType
TTypesOfLandscapeElement m_EleType
Definition: PopulationManager.h:174
Vole_Base::IDNo
unsigned IDNo
Definition: vole_all.h:208
Vole_Base::CalculateCarryingCapacity
double CalculateCarryingCapacity(int x, int y, int a_ddep)
Definition: Vole_all.cpp:384
cfg_volepcidebiodegredrate
static CfgFloat cfg_volepcidebiodegredrate("VOLE_PCIDE_BIODEGREDATIONRATE", CFG_CUSTOM, 0.0)
tole_SandDune
Definition: tole_declaration.h:81
struct_Vole_Adult::y
int y
Definition: vole_all.h:126
Vole_JuvenileFemale::Step
virtual void Step()
JuvenileFemale vole Step.
Definition: Vole_all.cpp:1426
tole_WoodyEnergyCrop
Definition: tole_declaration.h:94
AnimalPosition::m_y
unsigned m_y
Definition: PopulationManager.h:173
Vole_Female::st_BecomeReproductive
TTypeOfVoleState st_BecomeReproductive()
Female vole maturation control.
Definition: Vole_all.cpp:2005
Vole_JuvenileMale::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
JuvenileMale vole exernal event handler.
Definition: Vole_all.cpp:2887
Vole_Base::DoWalkingCorrect
void DoWalkingCorrect(int p_Distance, int &p_Vector, int &vx, int &vy)
Walking where there is a danger of stepping off the world.
Definition: Vole_all.cpp:1041
struct_Vole_Adult::L
Landscape * L
Definition: vole_all.h:138
hilling_up
Definition: treatment.h:79
Landscape::SupplyElementTypeFromVector
TTypesOfLandscapeElement SupplyElementTypeFromVector(unsigned int a_index)
Definition: Landscape.h:1104
Landscape::EventtypeToString
std::string EventtypeToString(int a_event)
Definition: Landscape.cpp:3918
TAnimal::CopyMyself
virtual void CopyMyself()
Definition: PopulationManager.h:224
tole_River
Definition: tole_declaration.h:65
cfg_InfanticideProbability
static CfgFloat cfg_InfanticideProbability("INFANTI_PROBA", CFG_CUSTOM, 0.01)
Vole_Base::SimW
int SimW
Definition: vole_all.h:210
cfg_MinReproAgeM
CfgInt cfg_MinReproAgeM("VOLE_MINREPROAGEM", CFG_CUSTOM, 30)
ppp_1
Definition: farm.h:422
tole_Scrub
Definition: tole_declaration.h:42
Vole_Male::Vole_Male
Vole_Male(struct_Vole_Adult *p_aVoleStruct)
Vole_Male constructor.
Definition: Vole_all.cpp:2413
tov_OCloverGrassGrazed1
Definition: tov_declaration.h:43
fa_manure
Definition: treatment.h:66
tole_PermPastureTussocky
Definition: tole_declaration.h:45
Vole_JuvenileMale::FreeLocation
virtual void FreeLocation()
Map location function.
Definition: Vole_all.cpp:3085
Vole_JuvenileFemale::FreeLocation
virtual void FreeLocation()
Location map function.
Definition: Vole_all.cpp:1792
fp_npks
Definition: treatment.h:48
Vole_Male::DetermineTerritorySize
void DetermineTerritorySize()
Calculates the territory size needed for a vole of his weight.
Definition: Vole_all.cpp:2778
row_cultivation
Definition: treatment.h:76
Vole_Base::Set_PolyRefBorn
void Set_PolyRefBorn(int a_Location_x, int a_Location_y)
Definition: vole_all.h:327
cfg_VoleMortalityDataUsed
static CfgBool cfg_VoleMortalityDataUsed("VOLE_MORTALITY_DATA_USED", CFG_CUSTOM, false)
growthperdayF
const double growthperdayF
Definition: Vole_all.cpp:141
Vole_JuvenileMale
The class for juvenile male voles.
Definition: vole_all.h:452
Vole_Base::SimH
int SimH
Definition: vole_all.h:210
trial_insecticidetreat
Definition: treatment.h:96
Vole_JuvenileMale::st_BecomeSubAdult
void st_BecomeSubAdult(void)
Definition: Vole_all.cpp:3264
vdisp_Infanticide
Definition: vole_all.h:82
Vole_JuvenileMale::Vole_JuvenileMale
Vole_JuvenileMale(struct_Vole_Adult *p_aVoleStruct)
Vole_JuvenileMale constructor.
Definition: Vole_all.cpp:3313
tole_Field
Definition: tole_declaration.h:43
Vole_Base::m_intrappos
InTrapPosition m_intrappos
Definition: vole_all.h:214
tole_FieldBoundary
Definition: tole_declaration.h:40
Vole_JuvenileMale::ReInit
virtual void ReInit(struct_Vole_Adult *p_aVoleStruct)
Definition: Vole_all.cpp:3323
Vole_JuvenileMale::EndStep
virtual void EndStep()
Juvenile Male vole EndStep.
Definition: Vole_all.cpp:3181
tovmort_FStarve
Definition: VolePopulationManager.h:74
Vole_Base::Escape
void Escape(int p_Vector, int p_Distance)
Dispersal - directed movement.
Definition: Vole_all.cpp:1127
Vole_Base::Set_BirthYear
void Set_BirthYear(int BirthYear)
Definition: vole_all.h:302
tole_PermPastureLowYield
Definition: tole_declaration.h:44
Population_Manager::SimH
int SimH
Definition: PopulationManager.h:511
tole_RiversideTrees
Definition: tole_declaration.h:51
Vole_Population_Manager::AddToJuvs
void AddToJuvs(int juvs)
Definition: VolePopulationManager.h:255
cfg_ReallyBigOutputMonthly_used
CfgBool cfg_ReallyBigOutputMonthly_used
Vole_Base::m_OurPopulation
Vole_Population_Manager * m_OurPopulation
Definition: vole_all.h:408
struct_Vole_Adult::MotherId
int MotherId
Definition: vole_all.h:136
spring_plough
Definition: treatment.h:44
Vole_Male
The class for male voles.
Definition: vole_all.h:492
fa_greenmanure
Definition: treatment.h:67
VoleObject
VoleObject
Definition: vole_all.h:98
Vole_Base::m_Age
int m_Age
Definition: vole_all.h:178
TTypesOfLandscapeElement
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
tole_IndividualTree
Definition: tole_declaration.h:93
Vole_JuvenileFemale::Vole_JuvenileFemale
Vole_JuvenileFemale(struct_Vole_Adult *p_aVoleStruct)
Vole_JuvenileFemale constructor.
Definition: Vole_all.cpp:1349
VolePigGrazingMort
const double VolePigGrazingMort
Definition: Vole_all.cpp:198
September
const int September
Definition: Landscape.h:44
Vole_Female::Step
virtual void Step()
Female vole Step.
Definition: Vole_all.cpp:1906
TAnimal::CheckManagement
void CheckManagement(void)
Definition: PopulationManager.cpp:1404
GeneticMaterial::Mutation_4
void Mutation_4()
Definition: GeneticMaterial.cpp:538
Vole_Base::m_MinMVoleHabQual
static double m_MinMVoleHabQual
Definition: vole_all.h:228
DaysAtMaxGrowth
const double DaysAtMaxGrowth
Definition: Vole_all.cpp:137
Vole_Base::Set_FatherId
void Set_FatherId(unsigned FatherIdNo)
Definition: vole_all.h:307
cfg_AOROutput_used
CfgBool cfg_AOROutput_used
struct_Vole_Adult::VegBorn
int VegBorn
Definition: vole_all.h:133
tole_PitDisused
Definition: tole_declaration.h:50
trial_toxiccontrol
Definition: treatment.h:97
spring_roll
Definition: treatment.h:46
tole_Wasteland
Definition: tole_declaration.h:92
FemaleResourceReq
const double FemaleResourceReq[13]
Definition: Vole_all.cpp:156
tole_HeritageSite
Definition: tole_declaration.h:90
Vole_Female::Vole_Female
Vole_Female(struct_Vole_Adult *p_aVoleStruct)
Vole_Female constructor.
Definition: Vole_all.cpp:1852
cut_weeds
Definition: treatment.h:94
g_sigAgeDiff
int g_sigAgeDiff
Definition: Vole_all.cpp:153
Vole_Male::Step
virtual void Step()
Male vole Step.
Definition: Vole_all.cpp:2450
Vole_Population_Manager::m_VoleRecordMort
VoleSummaryOutput * m_VoleRecordMort
Definition: VolePopulationManager.h:197
Vole_Base::m_BornLastYear
bool m_BornLastYear
A flag set if the female was born the year before.
Definition: vole_all.h:162
Vole_Base::Init
virtual void Init(struct_Vole_Adult *p_aVoleStruct)
Definition: Vole_all.cpp:240
MoveToLessFavourable
double MoveToLessFavourable
Definition: VolePopulationManager.cpp:157
fp_manganesesulphate
Definition: treatment.h:53
Vole_Female::st_UpdateGestation
TTypeOfVoleState st_UpdateGestation()
Gestation control.
Definition: Vole_all.cpp:1991
cfg_PesticideWeaningReduction
static CfgFloat cfg_PesticideWeaningReduction("VOLE_PCIDE_WEANINGREDUCTION", CFG_CUSTOM, 0.0017)
August
const int August
Definition: Landscape.h:43
Vole_Female::m_DaysUntilBirth
int m_DaysUntilBirth
A counter counting down gestation days.
Definition: vole_all.h:606
herbicide_treat
Definition: treatment.h:71
tovmort_MBck
Definition: VolePopulationManager.h:75
InTrapPosition::m_inAtrap
bool m_inAtrap
Definition: vole_all.h:115
Vole_Female::st_Mating
TTypeOfVoleState st_Mating()
Female mating.
Definition: Vole_all.cpp:2341
Vole_Base::m_FemaleTerritoryRangeSlope
static double m_FemaleTerritoryRangeSlope
Definition: vole_all.h:232
Vole_Female::st_GiveBirth
TTypeOfVoleState st_GiveBirth()
Litter production.
Definition: Vole_all.cpp:2024
Vole_JuvenileMale::BeginStep
virtual void BeginStep()
Juvenile Male vole BeginStep.
Definition: Vole_all.cpp:3108
cfg_MinFemaleTerritorySize
CfgInt cfg_MinFemaleTerritorySize("VOLE_MINFEMALETERRITORYSIZE", CFG_CUSTOM, 8)
struct_Vole_Adult::m_flag
bool m_flag
Definition: vole_all.h:142
growth_regulator
Definition: treatment.h:72
tovs_Lactating
Definition: vole_all.h:67
cut_to_silage
Definition: treatment.h:86
MinFemaleMovement
const unsigned MinFemaleMovement
Definition: Vole_all.cpp:176
Vole_Base::m_FatherId
unsigned m_FatherId
Definition: vole_all.h:168
struct_Vole_Adult::x
int x
Definition: vole_all.h:125
ttop_ModelinkPesticide
Definition: Landscape.h:71
FarmToDo
FarmToDo
Definition: treatment.h:31
tole_Carpark
Definition: tole_declaration.h:85
cfg_PesticideAccumulationThresholdModelink2
static CfgFloat cfg_PesticideAccumulationThresholdModelink2("VOLE_PESTICDEACCUMULATIONTHRESHOLD_MODELINKTWO", CFG_CUSTOM, 20.0)
ttop_AcuteEffects
Definition: Landscape.h:68
tole_DeciduousForest
Definition: tole_declaration.h:52
TALMaSSObject::m_CurrentStateNo
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: PopulationManager.h:116
tov_CloverGrassGrazed1
Definition: tov_declaration.h:32
tole_Hedges
Definition: tole_declaration.h:37
pigs_out
Definition: treatment.h:84
cfg_pest_residue_or_rate
CfgBool cfg_pest_residue_or_rate
Vole_Female::ReInit
void ReInit(struct_Vole_Adult *p_aVoleStruct)
Definition: Vole_all.cpp:1870
tovs_MMaturation
Definition: vole_all.h:60
trial_control
Definition: treatment.h:98
tovmort_MStarve
Definition: VolePopulationManager.h:73
Vole_Female::OnInfanticideAttempt
void OnInfanticideAttempt()
Determines whether an infanticide attempt will succeed.
Definition: Vole_all.cpp:2380
Landscape::SupplyPolyRefIndex
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: Landscape.h:1493
g_DailyMortChanceMaleTerr
double g_DailyMortChanceMaleTerr
Definition: Vole_all.cpp:190
Vole_JuvenileFemale::SetLocation
virtual void SetLocation()
Location map function.
Definition: Vole_all.cpp:1785
tole_Vildtager
Definition: tole_declaration.h:99
cut_to_hay
Definition: treatment.h:85
Vole_JuvenileFemale::BeginStep
virtual void BeginStep()
Female vole BeginStep.
Definition: Vole_all.cpp:1393
vdisp_Mature
Definition: vole_all.h:81
Vole_Population_Manager::SupplyHowManyVoles
int SupplyHowManyVoles(unsigned p_x, unsigned p_y, unsigned p_size)
Definition: VolePopulationManager.cpp:1162
tovmort_FPred
Definition: VolePopulationManager.h:82
spring_sow
Definition: treatment.h:47
cfg_MinReproAgeF
CfgInt cfg_MinReproAgeF("VOLE_MINREPROAGEF", CFG_CUSTOM, 23)
Landscape::Warn
void Warn(std::string a_msg1, std::string a_msg2)
Definition: Landscape.h:1579
struct_Vole_Adult::ElemBorn
int ElemBorn
Definition: vole_all.h:132
struct_Vole_Adult::age
int age
Definition: vole_all.h:127
sleep_all_day
Definition: treatment.h:33
Vole_Base::m_MinFemaleTerritorySize
static unsigned int m_MinFemaleTerritorySize
Definition: vole_all.h:222
Vole_Male::st_Eval_n_Explore
TTypeOfVoleState st_Eval_n_Explore(void)
Male vole main territory assessment behaviour.
Definition: Vole_all.cpp:2584
GeneticMaterial::Recombine
void Recombine(GeneticMaterial *Gen21, GeneticMaterial *Gene2)
Definition: GeneticMaterial.cpp:338
Vole_Male::MortalityTest
virtual bool MortalityTest()
Do a mortality test.
Definition: Vole_all.cpp:2763
Vole_Base::MortalityTest
virtual bool MortalityTest()
Do a mortality test.
Definition: Vole_all.cpp:362
Vole_Base::m_fertile
bool m_fertile
Flag indicating the fertility state (true means fertile)
Definition: vole_all.h:194
tole_AmenityGrass
Definition: tole_declaration.h:76
Vole_Base::m_TerrRange
int m_TerrRange
Definition: vole_all.h:172
Vole_Base::m_Reserves
int m_Reserves
Definition: vole_all.h:206
TAnimal::m_Location_x
int m_Location_x
Definition: PopulationManager.h:225
tole_NaturalGrassDry
Definition: tole_declaration.h:48
autumn_or_spring_plough
Definition: treatment.h:91
tole_BeetleBank
Definition: tole_declaration.h:69
Landscape::SupplyPolyRef
int SupplyPolyRef(int a_x, int a_y)
Definition: Landscape.h:1488
Vole_Male::Dispersal
VoleDispersalReturns Dispersal(double p_OldQual, int p_Distance)
Male vole dispersal behaviour.
Definition: Vole_all.cpp:2689
Vole_Base::m_BreedingSeason
static bool m_BreedingSeason
Definition: vole_all.h:247
struct_Vole_Adult::m_dflag
bool m_dflag
Definition: vole_all.h:144
tovmort_FFarm
Definition: VolePopulationManager.h:78
tole_Coast
Definition: tole_declaration.h:67
tole_BuiltUpWithParkland
Definition: tole_declaration.h:80
fa_slurry
Definition: treatment.h:63
Vector_x
const int Vector_x[8]
swathing
Definition: treatment.h:81
tole_SmallRoad
Definition: tole_declaration.h:60
Vole_Base::SetLocation
virtual void SetLocation()
Definition: vole_all.h:439
tovs_MEvaluateExplore
Definition: vole_all.h:61
tole_Fence
Definition: tole_declaration.h:57
Vole_JuvenileMale::st_JuvenileExplore
void st_JuvenileExplore(void)
Extra movement on weaning.
Definition: Vole_all.cpp:2873
Vole_Population_Manager::m_VoleMap
IDMap< TAnimal * > * m_VoleMap
Definition: VolePopulationManager.h:284
Vole_Base::m_NoOfYoungTotal
int m_NoOfYoungTotal
Definition: vole_all.h:200
FemaleMovement
const unsigned FemaleMovement
Definition: Vole_all.cpp:174
cfg_MinMaleTerritorySize
CfgInt cfg_MinMaleTerritorySize("VOLE_MINMALETERRITORYSIZE", CFG_CUSTOM, 9)
AnimalPosition::m_VegType
TTypesOfVegetation m_VegType
Definition: PopulationManager.h:175
tole_Heath
Definition: tole_declaration.h:70
struct_Vole_Adult::PolyRefBorn
int PolyRefBorn
Definition: vole_all.h:131
cfg_MaxFemaleTerrSize
static CfgInt cfg_MaxFemaleTerrSize("VOLE_MAXFEMALETERRITORYSIZE", CFG_CUSTOM, 8)