ALMaSS Partridge ODdox  1.1
The partridge model description following ODdox protocol
Partridge_All.cpp
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
36 //---------------------------------------------------------------------------
37 
38 // Includes from ALMaSS
39 
40 #include <iostream>
41 #include <fstream>
42 #include "../Landscape/ls.h"
43 #include "../BatchALMaSS/PopulationManager.h"
44 #include "../Partridge/Partridge_Communication.h"
45 #include "../Partridge/Partridge_All.h"
46 #include "../Partridge/Partridge_Population_Manager.h"
47 #include "../Partridge/Partridge_Covey.h"
48 #include "../BatchALMaSS/BoostRandomGenerators.h"
49 
50 //---------------------------------------------------------------------------
51 
52 
53 //
54 // partridge_all.cpp
55 //
56 
57 extern double g_FoodNeed[200];
58 extern int g_MaxWalk[200];
59 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> > g_rand_uni;
60 extern double g_par_rainfactor;
61 
63 static CfgInt cfg_par_triggerlayingvar( "PAR_TRIGGERLAYINGVAR", CFG_CUSTOM, 48 );
66 static CfgFloat cfg_par_extraction_rate( "PAR_EXTRACTION_RATE", CFG_CUSTOM, 0.0085 );
68 CfgInt cfg_par_max_lifespan( "PAR_MAX_LIFESPAN", CFG_CUSTOM, 3650 );
70 CfgInt cfg_par_min_lifespan( "PAR_MIN_LIFESPAN", CFG_CUSTOM, 1825 );
72 CfgInt cfg_par_start_dissolve( "PAR_START_DISSOLVE", CFG_CUSTOM, 30 );
74 static CfgInt cfg_par_triggerlaying( "PAR_TRIGGERLAYING", CFG_CUSTOM, 850 );
76 static CfgInt cfg_buildupwait("PAR_BUILDUP_WAIT",CFG_CUSTOM,130); // Fitted 1/02/2008
78 static CfgInt cfg_par_days_to_make_nest( "PAR_DAYS_TO_MAKE_NEST", CFG_CUSTOM, 5 );
80 static CfgInt cfg_par_incubation_period( "PAR_INCUBATION_PERIOD", CFG_CUSTOM, 24 );
82 CfgInt cfg_par_mature_threshold( "PAR_MATURE_THRESHOLD", CFG_CUSTOM, 84 );
84 CfgInt cfg_par_last_brood_date( "PAR_LAST_BROOD_DATE", CFG_CUSTOM, 180 );
86 CfgInt cfg_par_male_gives_up( "PAR_MALE_GIVES_UP", CFG_CUSTOM, 170 );
88 CfgInt cfg_par_max_terr_qual( "PAR_MAX_TERR_QUAL", CFG_CUSTOM, 13000 );//Added on March12th 2007.
90 CfgInt cfg_par_min_terr_qual( "PAR_MIN_TERR_QUAL", CFG_CUSTOM, 6900 );
92 static CfgInt cfg_par_MaleFlyingDistance( "PAR_MALEFLYINGDISTANCE", CFG_CUSTOM, 2000 );
94 static CfgInt cfg_par_MaleMateSearchArea( "PAR_MALEMATESEARCHAREA", CFG_CUSTOM, 500 );
97 static CfgInt cfg_par_female_movement_max( "PAR_FEMALE_MOVEMENT_MAX", CFG_CUSTOM, 100 );
99 static CfgInt cfg_par_min_no_eggs( "PAR_MIN_NO_EGGS", CFG_CUSTOM, 7 );
101 static CfgFloat cfg_par_days_per_egg( "PAR_DAY_PER_EGG", CFG_CUSTOM, 1.5 );
102 
103 // Density-depende mortality
105 static CfgFloat cfg_par_female_incubation_mortality_slope( "PAR_FEMALE_INCUBATION_MORTALITY_SLOPE", CFG_CUSTOM, -0.00122 );
107 static CfgFloat cfg_par_female_incubation_mortality_const( "PAR_FEMALE_INCUBATION_MORTALITY_CONST", CFG_CUSTOM, 1.00192 );
108 
109 // Start background mortality
111 static CfgInt cfg_par_base_mortality( "PAR_BASE_MORTALITY", CFG_CUSTOM, 0 );
113 static CfgFloat cfg_par_clutch_mortality( "PAR_CLUTCH_MORTALITY", CFG_CUSTOM, 0.00135 );
115 static CfgFloat cfg_par_chick_mortality( "PAR_CHICK_MORTALITY", CFG_CUSTOM, 0.02043 );
118 static CfgFloat cfg_par_chick2_mortality( "PAR_CHICK_TWO_MORTALITY", CFG_CUSTOM, 1.0 );
120 static CfgFloat cfg_par_adult_mortalitySummer( "PAR_ADULT_MORTALITYSUMMER", CFG_CUSTOM, 0.0001 );
122 static CfgFloat cfg_par_adult_mortalitySpring( "PAR_ADULT_MORTALITYSPRING", CFG_CUSTOM, 0.0096 );
124 static CfgFloat cfg_par_adult_mortalityWinter( "PAR_ADULT_MORTALITYWINTER", CFG_CUSTOM, 0.0217 );
126 static CfgFloat cfg_par_adult_mortality_alone( "PAR_ADULT_MORTALITY_ALONE", CFG_CUSTOM, 1.4 );
127 // End background mortality
128 
130 static CfgInt cfg_par_starve_threshold( "PAR_STARVE_THRESHOLD", CFG_CUSTOM, 4 );
132 static CfgFloat cfg_par_infertile_eggs( "PAR_INFERTILE_EGGS", CFG_CUSTOM, 0.08 );
133 // Farm mortality factors
135 static CfgFloat cfg_par_ad_cut( "PAR_AD_CUT_MORT", CFG_CUSTOM, 0.01 );
137 static CfgFloat cfg_par_ch_cut( "PAR_CH_CUT_MORT", CFG_CUSTOM, 0.05 );
139 static CfgFloat cfg_par_cl_cut( "PAR_CL_CUT_MORT", CFG_CUSTOM, 0.29 );
141 static CfgFloat cfg_female_mowing_chance( "PAR_FEMALEMOWNMORTALITY", CFG_CUSTOM, 1 );
142 
144 //static CfgFloat cfg_par_soil_cultivation_cl( "PAR_SOILCULTIVATIONMORT_CL", CFG_CUSTOM, 1.0 );
146 //static CfgFloat cfg_par_soil_cultivation_ch( "PAR_SOILCULTIVATIONMORT_CH", CFG_CUSTOM, 0.01 );
148 //static CfgFloat cfg_par_soil_cultivation_a( "PAR_SOILCULTIVATIONMORT_A", CFG_CUSTOM, 0.001 );
149 
151 static long g_partridge_id = 0;
152 
156 Partridge_Base::Partridge_Base( int a_born_x, int a_born_y, int a_x, int a_y, int a_family_counter, Partridge_Covey * a_covey,
157  Landscape * a_map, Partridge_Population_Manager * a_manager ) : TAnimal( a_x, a_y, a_map )
158  {
159  m_age = 0;
160  m_born_x = a_born_x;
161  m_born_y = a_born_y;
162  m_UncleStatus = false;
163  m_family_counter = a_family_counter;
164  m_id = g_partridge_id++;
165  m_covey = a_covey;
166  // **CJT** NB it is the responsibility of the calling method
167  // to ensure that if a_covey is NULL, then the bird is added later
168  if ( m_covey ) m_covey->AddMember( this );
170  m_OurPopulationManager = a_manager;
171  m_signal = -9999; // used to trap non-set signal output
172 }
173 
174 //------------------------------------------------------------------------------
175 
180 {
181  if ( ( a_partridge->GetFamily() < m_family_counter - 1 || a_partridge->GetFamily() > m_family_counter + 1 )
182  // Possible age check?
183  )
184  {
185  return true;
186  }
187  return false;
188 }
189 
190 //------------------------------------------------------------------------------
191 
193 {
194  // Line removed because it causes all kinds of concurrency problems
195  // removal from covey must occur when the bird is killed, not later in the day
196  // m_covey->RemoveMember( this );
197 }
198 
199 //------------------------------------------------------------------------------
200 
201 
207 {
209 }
210 
211 //------------------------------------------------------------------------------
212 
217 {
218  m_covey->RemoveMember( this );
219  m_covey = a_covey;
220  m_covey->AddMember( this );
221 }
222 
223 //------------------------------------------------------------------------------
224 
229 {
230  int chance = random( 100000 );
231  if ( chance < cfg_par_base_mortality.value() ) return true;
232  return false;
233 }
234 
235 //------------------------------------------------------------------------------
239 void Partridge_Base::CopyMyself(int a_Ptype) {
240  AdultPartridge_struct * aps;
241  aps = new AdultPartridge_struct;
242  aps->bx = m_born_x;
243  aps->by = m_born_y;
244  aps->x = m_Location_x;
245  aps->y = m_Location_y;
246  aps->L = m_OurLandscape;
247  aps->family_counter = random(1000000);
248  aps->age = m_age;
249  if (a_Ptype==pob_Male) {
250  aps->sex=true;
251  } else {
252  aps->sex=false;
253  }
255  delete aps;
256 }
257 //-----------------------------------------------------------------------------
261 Partridge_Clutch::Partridge_Clutch( int a_born_x, int a_born_y, Partridge_Female * a_mother, Partridge_Covey * a_covey,
262  Landscape * a_map, int a_num_eggs, int a_family_counter, Partridge_Population_Manager * a_manager ) :
263  Partridge_Base( a_born_x, a_born_y, a_born_x, a_born_y, a_family_counter, a_covey, a_map, a_manager )
264  {
265  m_mother = a_mother;
266  m_clutch_size = a_num_eggs;
268  m_underincubation = false;
269 }
270 
271 //------------------------------------------------------------------------------
272 
274 {
276 }
277 //------------------------------------------------------------------------------
278 
283 {
284 
285  if ( !DailyMortality() ) CheckManagement();
286  else
287  {
288  ClDying();
289  }
290 }
291 
292 //------------------------------------------------------------------------------
293 
298 {
299  if ( m_CurrentStateNo == -1 || m_StepDone )
300  return;
301 
302 #ifdef __PAR_DEBUG
304 #endif
305 
306  switch ( m_state )
307  {
308  case pars_Initiation:
310  case pars_ClDeveloping:
311  case pars_ClHatching:
312  case pars_Destroy:
313  case pars_ClDying:
314  m_StepDone = true;
315  break;
316  default:
317  m_OurLandscape->Warn( "Partridge_Clutch::Step - unknown pars type", NULL );
318  exit( 1 );
319  }
320 }
321 
322 //------------------------------------------------------------------------------
323 
328 {
329  if ( m_CurrentStateNo == -1 )
330  return;
331 
332  switch ( m_state )
333  {
334  case pars_ClDeveloping:
335  m_state = ClDeveloping();
336  break;
337  case pars_ClHatching:
338  break;
339  case pars_ClDying:
340  break;
341  case pars_Destroy:
342  // Destroy is only called if all housekeeping wrt to removal of the object
343  // is done - object will be destroyed by PopulationManager
344  break;
345  default:
346  m_OurLandscape->Warn( "Partridge_Clutch::EndStep - unknown pars type", NULL );
347  exit( 1 );
348  }
349 }
350 
351 //------------------------------------------------------------------------------
352 
355 {
356  return false;
357 }
358 
359 //------------------------------------------------------------------------------
365 {
366 
369  // The line below is really debug information, this identifies the caller
373  ClDying();
374 }
375 //------------------------------------------------------------------------------
376 
381 {
382  switch ( event )
383  {
384  case sleep_all_day:
385  break;
386  case autumn_plough:
387  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
388  break;
389  case autumn_harrow:
390  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
391  break;
392  case autumn_roll:
393  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
394  break;
395  case autumn_sow:
396  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
397  break;
398  case winter_plough:
399  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
400  break;
401  case deep_ploughing:
402  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
403  break;
404  case spring_plough:
405  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
406  break;
407  case spring_harrow:
408  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
409  break;
410  case spring_roll:
411  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
412  break;
413  case spring_sow:
414  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
415  break;
416  case fp_npks:
417  break;
418  case fp_npk:
419  break;
420  case fp_pk:
421  break;
422  case fp_liquidNH3:
423  if ( g_rand_uni() < 80 ) AgDying();
424  break;
425  case fp_slurry:
426  if ( g_rand_uni() < 50 ) AgDying();
427  break;
429  break;
430  case fp_manure:
431  if ( g_rand_uni() < 0.20 ) AgDying();
432  break;
433  case fp_greenmanure:
434  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
435  break;
436  case fp_sludge:
437  break;
438  case fa_npk:
439  break;
440  case fa_pk:
441  break;
442  case fa_slurry:
443  if ( g_rand_uni() < 0.50 ) AgDying();
444  break;
445  case fa_ammoniumsulphate:
446  break;
447  case fa_manure:
448  if ( g_rand_uni() < 0.20 ) AgDying();
449  break;
450  case fa_greenmanure:
451  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
452  break;
453  case fa_sludge:
454  break;
455  case herbicide_treat:
456  break;
457  case growth_regulator:
458  break;
459  case fungicide_treat:
460  break;
462  case insecticide_treat:
463  case product_treat:
464  case glyphosate:
465  break;
466  case molluscicide:
467  break;
468  case row_cultivation:
469  if ( g_rand_uni() < 0.50 ) AgDying();
470  break;
471  case strigling:
472  break;
473  case hilling_up:
474  if ( g_rand_uni() < 0.50 ) AgDying();
475  break;
476  case water:
477  if ( g_rand_uni() < 0.01 ) AgDying();
478  break;
479  case swathing:
480  break;
481  case harvest:
482  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
483  break;
484  case cattle_out:
485  break;
486  case cattle_out_low:
487  break;
488  case cut_to_hay:
489  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
490  break;
491  case cut_to_silage:
492  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
493  break;
494  case straw_chopping:
495  break;
496  case hay_turning:
497  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
498  break;
499  case hay_bailing:
500  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
501  break;
502 
503  case stubble_harrowing:
504  break;
506  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
507  break;
508  case burn_straw_stubble:
509  break;
510  case mow:
511  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
512  break;
513  case cut_weeds:
514  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
515  break;
516  case pigs_out:
517  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
518  break;
519  case strigling_sow:
520  if ( g_rand_uni() < cfg_par_cl_cut.value() ) AgDying();
521  break;
522  default:
523  m_OurLandscape->Warn( "Skylark_Clutch::OnFarmEvent(): Unknown event type:", m_OurLandscape->EventtypeToString( event ) );
524  exit( 1 );
525  }
526  if ( m_state == pars_Destroy ) return true;
527  else
528  return false;
529 }
530 
531 //------------------------------------------------------------------------------
532 
539 {
541  if ( ++m_age < cfg_par_incubation_period.value() ) {
542  return pars_ClDeveloping;
543  }
544  //The line below is really debug information, this identifies the caller
546  // Call the mother via the message centre
549  // Remove the infertile eggs
550  int clutchsize = 0;
551  // correct for infertile eggs:
552  for ( int u = 0; u < m_clutch_size; u++ ) {
553  if ( g_rand_uni() >= cfg_par_infertile_eggs.value() ) clutchsize++;
554  }
555  if ( clutchsize == 0 ) // all infertile
556  {
558  m_StepDone = true; // Note this does more than stop the Step code executing
559  m_covey->NestLeave(); // indicate that we are finished with the nest
560  m_covey->RemoveMember( this );
561  m_mother = NULL; // just in case they get some other weird message
562  m_CurrentStateNo = -1;
563  return pars_Destroy;
564  }
565  // Call the mother via the message centre
567  // Do what is needed to create the new chick objects
568  // m_OurPopulationManager->AddMaturedE();
569  Chick_struct * Ch;
570  Ch = new Chick_struct;
571  Ch->x = m_Location_x;
572  Ch->y = m_Location_y;
573  Ch->bx = m_Location_x;
574  Ch->by = m_Location_y;
575  Ch->Mum = m_mother;
576  Ch->m_covey = m_covey;
578  m_OurPopulationManager->CreateObjects( pob_Chick, Ch, clutchsize );
579  delete Ch;
580  m_CurrentStateNo = -1;
582  m_StepDone = true; // Note this does more than stop the Step code executing
583  m_covey->NestLeave(); // indicate that we are finished with the nest
584  m_covey->RemoveMember( this );
585  m_mother = NULL; // just in case they get some other weird message and try
586  // to do something with the mother pointer
587  //m_covey->SanityCheck2(m_covey->GetOurChicks() );
588  return pars_Destroy;
589 }
590 
591 //------------------------------------------------------------------------------
592 
597 {
598  // Before this method is called all necessary communications need to be carried
599  // out
600  // All the housekeeping necessary to die
601  if ( m_CurrentStateNo == -1 ) return; // already killed by something else
602  m_CurrentStateNo = -1;
603  m_StepDone = true;
604  // Do any statistics recording
606  // Now tidy up before vanishing totally
607  m_mother = NULL;
608  m_covey->RemoveMember( this );
610 }
611 
612 //------------------------------------------------------------------------------
613 
618 {
619  if ( m_mother ) // if this is NULL the clutch is already dying
620  {
621  m_mother = NULL;
622  }
623  ClDying();
624 }
625 
626 //------------------------------------------------------------------------------
627 
632 {
633  if ( m_mother ) // if this is NULL the clutch is alread dying
634  {
635  m_mother = NULL;
636  ClDying();
637  }
638 }
639 
640 //------------------------------------------------------------------------------
641 
646 {
647  if ( m_mother ) // if this is NULL the clutch is alread dying
648  {
649  ClDying();
650  }
651 }
652 
653 //------------------------------------------------------------------------------
654 
655 
656 //------------------------------------------------------------------------------
657 // Partridge_Chick
658 //------------------------------------------------------------------------------
659 
663 Partridge_Chick::Partridge_Chick( int a_born_x, int a_born_y, Partridge_Female * a_mother, Partridge_Covey * a_covey,
664  Landscape * a_map, bool a_sex, int a_family_counter, Partridge_Population_Manager * a_manager ) :
665  Partridge_Base( a_born_x, a_born_y, a_born_x, a_born_y, a_family_counter, a_covey, a_map, a_manager )
666  {
667  m_age = 0;
668  m_starve = 0;
669  m_sex = a_sex;
671  m_covey->OnAddChick( a_mother );
672 
673 }
674 
675 //------------------------------------------------------------------------------
676 
681 {
682  if ( m_CurrentStateNo == -1 )
683  {
684  return;
685  }
686  if ( !DailyMortality() )
687  {
688  CheckManagement();
689  //m_covey->SanityCheck2(m_covey->GetOurChicks() );
691  // This call is because it is OK to get multiple calls to this function
692  // but it is not OK if no-one calls it!
693  m_covey->MoveDistance( g_MaxWalk[m_age], 10, 10000 );
694  }
695  else
696  {
697  m_signal = 1;
698  ChDying();
699  // The death of this chick will impact on the others, so that their deaths are more likely
701  }
702 }
703 
704 //------------------------------------------------------------------------------
705 
710 {
711  if ( m_CurrentStateNo == -1 || m_StepDone )
712  return;
713 
714  switch ( m_state )
715  {
716  case pars_Initiation:
718  case pars_ChDeveloping:
719  case pars_ChDying:
720  m_StepDone = true;
721  break;
722  case pars_ChMaturing:
723  ChMaturing();
724  m_StepDone = true;
725  break;
726 
727  default:
728  m_OurLandscape->Warn( "Partridge_Chick::Step - unknown pars type", NULL );
729  exit( 1 );
730  }
731 }
732 
733 //------------------------------------------------------------------------------
734 
739 {
740  if ( m_CurrentStateNo == -1 )
741  return;
742 
743  switch ( m_state )
744  {
745  case pars_Initiation:
746  case pars_ChMaturing:
747  break;
748  case pars_ChDying:
749  ChDying();
750  break;
751  case pars_ChDeveloping:
752  m_state = ChDeveloping();
753  break;
754  default:
755  m_OurLandscape->Warn( "Partridge_Chick::EndStep - unknown pars type", NULL );
756  exit( 1 );
757  }
758 }
759 
760 //------------------------------------------------------------------------------
761 
766 {
767  switch ( event )
768  {
769  case sleep_all_day:
770  break;
771  case autumn_plough:
772  break;
773  case autumn_harrow:
774  break;
775  case autumn_roll:
776  break;
777  case autumn_sow:
778  break;
779  case winter_plough:
780  break;
781  case deep_ploughing:
782  break;
783  case spring_plough:
784  break;
785  case spring_harrow:
786  break;
787  case spring_roll:
788  break;
789  case spring_sow:
790  break;
791  case fp_npks:
792  break;
793  case fp_npk:
794  break;
795  case fp_pk:
796  break;
797  case fp_liquidNH3:
798  break;
799  case fp_slurry:
800  if ( g_rand_uni() < 0.01 ) ChDying();
801  break;
802 
803 
805  break;
806  case fp_manure:
807  break;
808  case fp_greenmanure:
809  break;
810  case fp_sludge:
811  break;
812  case fa_npk:
813  break;
814  case fa_pk:
815  break;
816  case fa_slurry:
817  if ( g_rand_uni() < 0.01 ) ChDying();
818  break;
819  case fa_ammoniumsulphate:
820  break;
821  case fa_manure:
822  break;
823  case fa_greenmanure:
824  break;
825  case fa_sludge:
826  break;
827  case herbicide_treat:
828  case glyphosate:
829  break;
830  case growth_regulator:
831  break;
832  case fungicide_treat:
833  break;
835  case insecticide_treat:
836  case product_treat:
837  break;
838  case molluscicide:
839  break;
840  case row_cultivation:
841  break;
842  case strigling:
843  if ( g_rand_uni() < 0.10 ) ChDying();
844  break;
845  case hilling_up:
846  break;
847  case water:
848  if ( g_rand_uni() < 0.01 ) ChDying();
849  break;
850  case swathing:
851  break;
852  case harvest:
853  if ( g_rand_uni() < cfg_par_ch_cut.value() ) ChDying();
854  break;
855  case cattle_out:
856  break;
857  case cattle_out_low:
858  break;
859  case cut_to_hay:
860  if ( g_rand_uni() < cfg_par_ch_cut.value() ) ChDying();
861  break;
862  case cut_to_silage:
863  if ( g_rand_uni() < cfg_par_ch_cut.value() ) ChDying();
864  break;
865  case straw_chopping:
866  break;
867  case hay_turning:
868  break;
869  case hay_bailing:
870  if ( g_rand_uni() < cfg_par_ch_cut.value() ) ChDying();
871  break;
872  case stubble_harrowing:
873  break;
875  break;
876  case burn_straw_stubble:
877  break;
878  case mow:
879  if ( g_rand_uni() < cfg_par_ch_cut.value() ) ChDying();
880  break;
881  case cut_weeds:
882  if ( g_rand_uni() < cfg_par_ch_cut.value() ) ChDying();
883  break;
884  case pigs_out:
885  break;
886  case strigling_sow:
887  if ( g_rand_uni() < 10 ) ChDying();
888  break;
889  default:
890  m_OurLandscape->Warn( "Skylark_Clutch::OnFarmEvent(): Unknown event type:", m_OurLandscape->EventtypeToString( event ) );
891  exit( 1 );
892  }
893  // Must incorporate a test here in case the animal is dead - killing it twice
894  // can be a bad idea
895  if ( m_state == pars_Destroy ) return true;
896  else
897  return false;
898 }
899 
900 //------------------------------------------------------------------------------
901 
906 {
908  {
909  // Optional output
910  // m_OurPopulationManager->AddEaten();
911  return true;
912  }
913  return false;
914 }
915 
916 //------------------------------------------------------------------------------
917 
923 {
924  m_age++;
925  // have we eaten enough to survive?
926  double food = m_covey->SupplyFoodToday();
927  double ex = cfg_par_extraction_rate.value();
928  food *= ex;
929 #ifdef __RAIN_HURTS
930  if ( food > ( g_FoodNeed[m_age] * (1+( g_par_rainfactor * m_OurLandscape->SupplyRain()) ) ))
931  {
932  m_starve = 0;
933  }
934 #else
935  if ( food > g_FoodNeed[m_age] )
936  {
937  m_starve = 0;
938  }
939 #endif
940  else if ( ++m_starve > cfg_par_starve_threshold.value() )
941  {
942  m_signal = 4;
943  ChDying(); // Kill it now
944  //m_OurPopulationManager->WriteParJuvMort(m_OurLandscape->SupplyYearNumber(),m_OurLandscape->SupplyDayInYear(),m_age,m_signal);
946  return pars_ChDying;
947  }
948  if ( m_age < 42 )
949  {
950  return pars_ChDeveloping;
951  }
952  else
953  return pars_ChMaturing;
954 }
955 
956 //------------------------------------------------------------------------------
957 
962 {
963  //m_covey->SanityCheck2(m_covey->GetOurChicks() );
964  Chick_struct * Ch;
965  Ch = new Chick_struct;
966  Ch->x = m_Location_x;
967  Ch->y = m_Location_y;
968  Ch->bx = m_Location_x;
969  Ch->by = m_Location_y;
970  Ch->Mum = NULL;
971  Ch->m_covey = m_covey;
972  Ch->sex = m_sex;
974  // Create objects will result in the object being added to the covey
976  // object will be destroyed by death state
977  // but must let Dad know anyway
978  delete Ch;
979  // Set up the flags to destroy this object
980  m_CurrentStateNo = -1;
981  m_StepDone = true;
982  m_covey->RemoveMember( this );
983  //m_covey->SanityCheck2(m_covey->GetOurChicks() );
984  return pars_Destroy;
985 }
986 
987 //------------------------------------------------------------------------------
988 
990 {
993  m_covey->RemoveMember( this );
995  m_CurrentStateNo = -1;
996  m_StepDone = true;
997  // Keep the k_factor analysis happy and uptodate
998  if ( m_age > 42 )
999  {
1000  if ( m_sex == false )
1001  {
1003  }
1004  else
1006  }
1008 
1009 }
1010 
1011 //------------------------------------------------------------------------------
1012 
1017 {
1018  ChDying();
1019 }
1020 
1021 //------------------------------------------------------------------------------
1022 // Partridge_Chick2
1023 //------------------------------------------------------------------------------
1024 
1028 Partridge_Chick2::Partridge_Chick2( int a_born_x, int a_born_y, Partridge_Female * a_mother, Partridge_Covey * a_covey,
1029  Landscape * a_map, bool a_sex, int a_family_counter, Partridge_Population_Manager * a_manager ) :
1030  Partridge_Chick( a_born_x, a_born_y, a_mother, a_covey, a_map, a_sex, a_family_counter, a_manager )
1031  {
1032  // Need to correct two naughtly little details that were messed up by the chick constructor
1033  // First we are not a chick any longer
1035  // Second The covey now thinks it has an extra chick
1037 }
1038 
1039 //------------------------------------------------------------------------------
1040 
1045 {
1046  switch ( event )
1047  {
1048  case sleep_all_day:
1049  break;
1050  case autumn_plough:
1051  break;
1052  case autumn_harrow:
1053  break;
1054  case autumn_roll:
1055  break;
1056  case autumn_sow:
1057  break;
1058  case winter_plough:
1059  break;
1060  case deep_ploughing:
1061  break;
1062  case spring_plough:
1063  break;
1064  case spring_harrow:
1065  break;
1066  case spring_roll:
1067  break;
1068  case spring_sow:
1069  break;
1070  case fp_npks:
1071  break;
1072  case fp_npk:
1073  break;
1074  case fp_pk:
1075  break;
1076  case fp_liquidNH3:
1077  break;
1078  case fp_slurry:
1079  break;
1080  case fp_manganesesulphate:
1081  break;
1082  case fp_manure:
1083  break;
1084  case fp_greenmanure:
1085  break;
1086  case fp_sludge:
1087  break;
1088  case fa_npk:
1089  break;
1090  case fa_pk:
1091  break;
1092  case fa_slurry:
1093  break;
1094  case fa_ammoniumsulphate:
1095  break;
1096  case fa_manure:
1097  break;
1098  case fa_greenmanure:
1099  break;
1100  case fa_sludge:
1101  break;
1102  case glyphosate:
1103  case herbicide_treat:
1104  break;
1105  case growth_regulator:
1106  break;
1107  case fungicide_treat:
1108  break;
1109  case syninsecticide_treat:
1110  case insecticide_treat:
1111  case product_treat:
1112  break;
1113  case molluscicide:
1114  break;
1115  case row_cultivation:
1116  break;
1117  case strigling:
1118  if ( g_rand_uni() < cfg_par_ad_cut.value() ) Dying();
1119  break;
1120  case hilling_up:
1121  break;
1122  case water:
1123  break;
1124  case swathing:
1125  break;
1126  case harvest:
1127  if ( g_rand_uni() < cfg_par_ad_cut.value() ) Dying();
1128  break;
1129  case cattle_out:
1130  break;
1131  case cattle_out_low:
1132  break;
1133  case cut_to_hay:
1134  if ( g_rand_uni() < cfg_par_ad_cut.value() ) Dying();
1135  break;
1136  case cut_to_silage:
1137  if ( g_rand_uni() < cfg_par_ad_cut.value() ) Dying();
1138  break;
1139  case straw_chopping:
1140  break;
1141  case hay_turning:
1142  break;
1143  case hay_bailing:
1144  if ( g_rand_uni() < cfg_par_ad_cut.value() ) Dying();
1145  break;
1146  case stubble_harrowing:
1147  break;
1149  break;
1150  case burn_straw_stubble:
1151  break;
1152  case mow:
1153  if ( g_rand_uni() < cfg_par_ad_cut.value() ) Dying();
1154  break;
1155  case cut_weeds:
1156  if ( g_rand_uni() < cfg_par_ad_cut.value() ) Dying();
1157  break;
1158  case pigs_out:
1159  break;
1160  case strigling_sow:
1161  if ( g_rand_uni() < 0.01 ) Dying();
1162  break;
1163  default:
1164  m_OurLandscape->Warn( "Skylark_Clutch::OnFarmEvent(): Unknown event type:", m_OurLandscape->EventtypeToString( event ) );
1165  exit( 1 );
1166  }
1167  // Must incorporate a test here in case the animal is dead - killing it twice
1168  // can be a bad idea
1169  if ( m_state == pars_Destroy ) return true;
1170  else
1171  return false;
1172 }
1173 
1174 //------------------------------------------------------------------------------
1175 
1180 {
1181  double extramort=cfg_par_chick2_mortality.value();
1182  int today = m_OurLandscape->SupplyDayInYear();
1183  // Is it winter?
1184  if (( ( today >= October ) || ( today < April )) ) {
1185  if (m_OurPopulationManager->SupplyShouldFlock()) { // We are in the "Winter Period"
1186  if ( (g_rand_uni()) < (cfg_par_adult_mortalityWinter.value()*extramort) ) {
1187  return true;
1188  }
1189  } else {
1190  // Must test summer mort instead;
1191  if ( g_rand_uni() < (cfg_par_adult_mortalitySummer.value()*extramort )) {
1192  return true;
1193  }
1194  }
1195  }
1196  return false;
1197 }
1198 //------------------------------------------------------------------------------
1199 
1200 //------------------------------------------------------------------------------
1201 
1206 {
1207  m_age++;
1209  {
1210  return pars_ChDeveloping;
1211  }
1212  else
1213  return pars_ChMaturing;
1214 }
1215 
1216 //------------------------------------------------------------------------------
1217 
1222 {
1223  AdultPartridge_struct * aps;
1224  aps = new AdultPartridge_struct;
1225  aps->bx = m_born_x;
1226  aps->by = m_born_y;
1227  aps->x = m_Location_x;
1228  aps->y = m_Location_y;
1230  aps->m_covey = m_covey;
1231  if ( m_sex == true ) m_OurPopulationManager->CreateObjects( pob_Male, aps, 1 );
1232  else
1234  // object will be destroyed by death state
1235  // but must let Dad know anyway
1236  delete aps;
1237  // Set up the flags to destroy this object
1238  m_CurrentStateNo = -1;
1239  m_StepDone = true;
1240  m_covey->RemoveMember( this );
1242  // m_OurPopulationManager->AddMatured();
1243  return pars_Destroy;
1244 }
1245 
1246 //------------------------------------------------------------------------------
1247 
1252 {
1253  if ( !DailyMortality() )
1254  {
1255  CheckManagement();
1257  // This call is because it is OK to get multiple calls to this function
1258  // but it is not OK if no-one calls it!
1259  m_covey->MoveDistance( g_MaxWalk[m_age], 10, 10000 );
1260  }
1261  else
1262  {
1263  m_signal = 1;
1264  ChDying();
1265  }
1266 }
1267 
1268 //------------------------------------------------------------------------------
1269 
1274 {
1275  if ( m_CurrentStateNo == -1 || m_StepDone )
1276  return;
1277 
1278  switch ( m_state )
1279  {
1280  case pars_Initiation:
1282  case pars_ChDeveloping:
1283  case pars_ChDying:
1284  m_StepDone = true;
1285  break;
1286  case pars_ChMaturing:
1287  ChMaturing();
1288  m_StepDone = true;
1289  break;
1290 
1291  default:
1292  m_OurLandscape->Warn( "Partridge_Chick2::Step - unknown pars type", NULL );
1293  exit( 1 );
1294  }
1295 }
1296 
1297 //------------------------------------------------------------------------------
1298 
1303 {
1304  if ( m_CurrentStateNo == -1 )
1305  return;
1306 
1307  switch ( m_state )
1308  {
1309  case pars_Initiation:
1310  case pars_ChMaturing:
1311  break;
1312  case pars_ChDying:
1313  ChDying();
1314  break;
1315  case pars_ChDeveloping:
1316  m_state = ChDeveloping();
1317  break;
1318  default:
1319  m_OurLandscape->Warn( "Partridge_Chick::EndStep - unknown pars type", NULL );
1320  exit( 1 );
1321  }
1322 }
1323 
1324 //------------------------------------------------------------------------------
1325 
1326 
1327 //------------------------------------------------------------------------------
1328 // Partridge_Female
1329 //------------------------------------------------------------------------------
1330 
1334 Partridge_Female::Partridge_Female( int a_born_x, int a_born_y, int a_x, int a_y, Partridge_Covey * a_covey, Landscape * a_map,
1335  int a_family_counter, Partridge_Population_Manager * a_manager ) :
1336  Partridge_Base( a_born_x, a_born_y, a_x, a_y, a_family_counter, a_covey, a_map, a_manager )
1337  {
1338  m_MyMate = NULL;
1339  m_HaveTerritory = false;
1341  m_MyOldHusband=NULL;
1342  m_MyClutch = NULL;
1343  m_clutch_size = 0;
1346 }
1347 
1348 //------------------------------------------------------------------------------
1349 
1355 {
1356  m_age++; // Get a day older
1357  if ( m_age >= m_lifespan )
1358  {
1359  m_signal = 0; // Too old
1360  FDying();
1361  }
1362  else if ( !DailyMortality() ) CheckManagement();
1363  else
1364  {
1365  m_signal = 1; // Killed
1366  }
1367 #ifdef __PAR_DEBUG
1369 #endif
1370 }
1371 
1372 //------------------------------------------------------------------------------
1373 
1379 {
1380 
1381  if ( m_CurrentStateNo == -1 || m_StepDone )
1382  return;
1383  switch ( m_state )
1384  {
1385  case pars_Initiation:
1386  case pars_FFlocking:
1387  m_state = FFlocking();
1388  m_StepDone = true;
1389  break;
1392  m_StepDone = true;
1393  break;
1394  case pars_FAttractingMate:
1396  m_StepDone = true;
1397  break;
1400  m_StepDone = true;
1401  break;
1402  case pars_FMakingNest:
1403  m_state = FMakingNest();
1404  m_StepDone = true;
1405  break;
1406  case pars_FLaying:
1407  m_state = FLaying();
1408  m_StepDone = true;
1409  break;
1411  m_state = FStartingNewBrood( false );
1412  m_StepDone = true;
1413  break;
1414  case pars_FIncubating:
1415  m_state = FIncubating();
1416  m_StepDone = true;
1417  break;
1418  case pars_FCaringForYoung:
1420  m_StepDone = true;
1421  break;
1422  case pars_FDying:
1423  m_StepDone = true;
1424  break;
1425  default:
1426  char st[255];
1427  sprintf(st,"%d\n",m_state);
1428  m_OurLandscape->Warn( "Partridge_Female::Step - unknown pars type ", st );
1429  exit( 1 );
1430  }
1431 #ifdef __PAR_DEBUG
1433 #endif
1434 }
1435 
1436 //------------------------------------------------------------------------------
1437 
1442 {
1443 #ifdef __PAR_DEBUG
1444 #endif
1445 }
1446 //------------------------------------------------------------------------------
1447 
1455 {
1456  bool dead = false;
1457  double chance = g_rand_uni();
1458  double extramort=1.0;
1459  if ( m_covey->GetCoveySize() == 1 ) {
1461  }
1462  int today = m_OurLandscape->SupplyDayInYear();
1464  if ( chance < cfg_par_adult_mortalitySpring.value()*extramort ) dead = true;
1465  }
1466  else {
1467  // Is it winter?
1468  if ( ( today >= October ) || ( today < April ) ) {
1469  // We are in the "Winter Period"
1470  if ( chance < cfg_par_adult_mortalityWinter.value()*extramort ) dead = true;
1471  }
1472  else // Not winter and not finding territory
1473  {
1474  if ( chance < (cfg_par_adult_mortalitySummer.value()*extramort) ) dead = true;
1475  }
1476  }
1477  if ( dead ) {
1478  FDying();
1479  return true;
1480  }
1481  return false;
1482 }
1483 
1484 //------------------------------------------------------------------------------
1485 
1492 {
1493  switch ( event )
1494  {
1495  case sleep_all_day:
1496  break;
1497  case autumn_plough:
1498  break;
1499  case autumn_harrow:
1500  break;
1501  case autumn_roll:
1502  break;
1503  case autumn_sow:
1504  break;
1505  case winter_plough:
1506  break;
1507  case deep_ploughing:
1508  break;
1509  case spring_plough:
1510  break;
1511  case spring_harrow:
1512  break;
1513  case spring_roll:
1514  break;
1515 
1516  case spring_sow:
1517  break;
1518  case fp_npks:
1519  break;
1520  case fp_npk:
1521  break;
1522  case fp_pk:
1523  break;
1524  case fp_liquidNH3:
1525  break;
1526  case fp_slurry:
1527  break;
1528  case fp_manganesesulphate:
1529  break;
1530  case fp_manure:
1531  break;
1532  case fp_greenmanure:
1533  break;
1534  case fp_sludge:
1535  break;
1536  case fa_npk:
1537  break;
1538  case fa_pk:
1539  break;
1540  case fa_slurry:
1541  break;
1542  case fa_ammoniumsulphate:
1543  break;
1544  case fa_manure:
1545  break;
1546  case fa_greenmanure:
1547  break;
1548  case fa_sludge:
1549  break;
1550  case glyphosate:
1551  case herbicide_treat:
1552  break;
1553  case growth_regulator:
1554  break;
1555  case fungicide_treat:
1556  break;
1557  case syninsecticide_treat:
1558  case insecticide_treat:
1559  case product_treat:
1560  break;
1561  case molluscicide:
1562  break;
1563  case row_cultivation:
1564  break;
1565  case strigling:
1566  if ( g_rand_uni() < cfg_par_ad_cut.value() ) FDying();
1567  break;
1568  case hilling_up:
1569  break;
1570  case water:
1571  break;
1572  case swathing:
1573  break;
1574  case harvest:
1575  if ( g_rand_uni() < cfg_par_ad_cut.value() ) FDying();
1576  break;
1577  case cattle_out:
1578  break;
1579  case cattle_out_low:
1580  break;
1581  case cut_to_hay:
1582  if ( g_rand_uni() < cfg_par_ad_cut.value() ) FDying();
1583  break;
1584  case cut_to_silage:
1585  if ( g_rand_uni() < cfg_par_ad_cut.value() ) FDying();
1586  break;
1587  case straw_chopping:
1588  break;
1589  case hay_turning:
1590  break;
1591  case hay_bailing:
1592  if ( g_rand_uni() < cfg_par_ad_cut.value() ) FDying();
1593  break;
1594  case stubble_harrowing:
1595  break;
1597  break;
1598  case burn_straw_stubble:
1599  break;
1600  case mow:
1601  if ( g_rand_uni() < cfg_par_ad_cut.value() ) FDying();
1602  break;
1603  case cut_weeds:
1604  if ( g_rand_uni() < cfg_par_ad_cut.value() ) FDying();
1605  break;
1606  case pigs_out:
1607  break;
1608  case strigling_sow:
1609  if ( g_rand_uni() < cfg_par_ad_cut.value() ) FDying();
1610  break;
1611  default:
1612  m_OurLandscape->Warn( "Partridge_Female::OnFarmEvent(): Unknown event type:",
1613  m_OurLandscape->EventtypeToString( event ) );
1614  exit( 1 );
1615  }
1616  // Must incorporate a test here in case the animal is dead - killing it twice
1617  // can be a bad idea
1618  if ( m_state == pars_Destroy ) return true;
1619  else
1620  return false;
1621 }
1622 
1623 
1624 
1625 //------------------------------------------------------------------------------
1626 
1633 {
1635  return pars_FFlocking;
1636 }
1637 //------------------------------------------------------------------------------
1638 
1645 {
1646 #ifdef __PAR_DEBUG
1648  /* if ( m_nest_counter < 1 ) { exit( 0 ); } */
1649 #endif
1650  // Note that with default settings the m_buildupwait is always gong to be 0 or less on calling this method.
1651  if (--m_buildupwait < 0) {
1652  // daylength que from when they start the covey dissolve
1653  // This could be altered to include bad weather delays
1655  {
1657  return pars_FMakingNest;
1658  }
1659  }
1661 }
1662 //------------------------------------------------------------------------------
1663 
1674 {
1675  //
1677  {
1678  if ( m_MyMate )
1679  {
1683  }
1684  // No success so clear the oldmate
1685  RemoveOldMate(false);
1686  m_MyMate = NULL;
1687  m_covey->SetFixed( false );
1688  m_HaveTerritory = false;
1689  return pars_FFlocking;
1690  }
1691  // data
1692  const int clutchsize[19] =
1693  {
1694  // This array holds the probabilities of clutch sizes in 20 categories.
1695  // below from Damerham
1696  143, 385, 725, 1163, 1700, 2336, 3070, 3902, 4833, 5863, 6990, 8217, 9037, 9607, 9928, 10000, 10000, 10000
1697  // The data below is from fitting a 3rd order polynomial to the Danish Paludan 1953 for Danish conditions
1698  // 48, 198, 451, 807, 1266, 1828, 2493, 3261, 4132, 5106, 6182, 7361, 8416, 9208, 9736, 10000, 10000, 10000
1699  };
1700  if ( --m_nest_counter == 0 ) {
1701  if ( m_clutch_size == 0 )
1702  { // If it is not zero it must be 2nd brood and is already set so don't alter it
1703  int chance = random( 10000 );
1704  for ( int i = 0; i < 19; i++ )
1705  {
1706  if ( clutchsize[i] > chance )
1707  {
1709  break;
1710  }
1711  }
1712  }
1713 #ifdef __PAR_DEBUG
1715  if ( m_OurLandscape->SupplyDayInYear() > 200 )
1716  {
1717  int rubbish = 0;
1718  }
1719 #endif
1720  // NOW MAKE THE NEST
1721  // Find and move to a nest location
1722  bool fnd = m_covey->NestFindLocation();
1723  if ( !fnd )
1724  {
1725  // No nest site - no breeding here
1726  // so find another territory
1727  // Tell the male too
1728  if ( m_MyMate )
1729  {
1733  }
1734  return pars_FFindingTerritory;
1735  }
1736  unsigned int family = m_family_counter + 1;
1737  // Make a clutch object
1738  Clutch_struct * ac;
1739  ac = new Clutch_struct;
1740  ac->x = m_Location_x;
1741  ac->y = m_Location_y;
1742  ac->bx = m_Location_x;
1743  ac->by = m_Location_y;
1744  ac->Mum = this;
1745  ac->No = 1; // Was clutch size but 24/01/08 the nest is built first then slowly filled. // m_clutch_size;
1746  ac->family_counter = family;
1747  ac->m_covey = m_covey;
1749  delete ac;
1750  if ( m_clutchproduced )
1751  {
1752  // This must be a re-lay, so don't count it towards total clutches laid
1754  }
1755  m_clutchproduced = true;
1757  return pars_FLaying;
1758  }
1759  return pars_FMakingNest;
1760 }
1761 //------------------------------------------------------------------------------
1762 
1769 {
1770  // 24th Jan 2008 CJT added the code below to allow for clutch predation before clutch completion
1771  if ( g_rand_uni() < cfg_par_clutch_mortality.value() ) { // only the eggs
1776  m_covey->NestLeave(); // Should not strictly be necessary, but safe
1777  m_state = FStartingNewBrood( true );
1778  m_MyClutch = NULL;
1779  return m_state;
1780  }
1782  int cs = (int) (days / cfg_par_days_per_egg.value());
1784  if (cs<m_clutch_size) return pars_FLaying;
1785  else {
1786  // Remember this male as a good mate
1788  m_MyMate->SetOldMate(this);
1791  return pars_FIncubating;
1792  }
1793 }
1794 //------------------------------------------------------------------------------
1795 
1803 {
1804  m_clutch_number++;
1805  const int clutchsize[19] =
1806  {
1807  // This array holds the probabilities of clutch sizes in 20 categories.
1808  // below from Damerham
1809  143, 385, 725, 1163, 1700, 2336, 3070, 3902, 4833, 5863, 6990, 8217, 9037, 9607, 9928, 10000, 10000, 10000
1810  // The data below is from fitting a 3rd order polynomial to the Danish Paludan 1953 for Danish conditions
1811  // 48, 198, 451, 807, 1266, 1828, 2493, 3261, 4132, 5106, 6182, 7361, 8416, 9208, 9736, 10000, 10000, 10000
1812  };
1813  int today = m_OurLandscape->SupplyDayInYear();
1814  if ( (cfg_par_last_brood_date.value() >= today ) && (m_clutch_number<2)) {
1815  int chance = random( 10000 );
1816  for ( int i = 0; i < 19; i++ ) {
1817  if ( clutchsize[i] > chance ) {
1818  m_clutch_size = cfg_par_min_no_eggs.value() + i - 4; // Subtract 4 to match with UK data for second clutches
1819  break;
1820  }
1821  }
1822  if (!a_waslaying) {
1823  m_nest_counter = 10; // 10 days refraction period (Aebishcher & Potts - loose idea but implemented for want of hard data )
1824  } else m_nest_counter = 1;
1825  return pars_FMakingNest; // Inlcudes finding nest location
1826  }
1827  else {
1828  // Too late or too many attempts
1829 #ifdef __PAR_DEBUG
1831  if ( m_OurLandscape->SupplyDayInYear() < 30 )
1832  {
1833  m_OurLandscape->Warn( "Partridge_Female::FSTartingNewBrood", "Too early" );
1834  exit( 1 );
1835  }
1836 #endif
1837  // tell the male we are giving up
1838  if ( m_MyMate != NULL )
1839  {
1843  }
1844  m_HaveTerritory = false;
1845  m_MyMate = NULL;
1846  m_covey->SetFixed( false );
1847  return pars_FFlocking;
1848  }
1849 }
1850 //------------------------------------------------------------------------------
1851 
1857 {
1859  { // only the eggs
1864  m_covey->NestLeave();
1865  m_state = FStartingNewBrood( false );
1866  m_MyClutch = NULL;
1867  return m_state;
1868  }
1869  // Only need to calculate the heavy bit if the nest survives egg predation
1870  double dens = 0.000001 + m_OurPopulationManager->ClutchDensity( m_covey->X(), m_covey->Y(), 500 );
1871  // Have use DPotts idea as the basis but modified this to account for the local rather than global density.
1872  double todaysmortchance = cfg_par_female_incubation_mortality_const.value()
1873  - ( pow( (double) dens, (double) cfg_par_female_incubation_mortality_slope.value() ) );
1874  todaysmortchance *= 100000;
1875  if ( random( 100000 ) < todaysmortchance )
1876  {
1877  // both eaten
1878  FDying();
1879  // Register the death with k_factors
1882  m_covey->NestLeave();
1883  return pars_FDying; // This does nothing actually
1884  }
1885  return pars_FIncubating;
1886 }
1887 
1888 
1889 
1890 //------------------------------------------------------------------------------
1891 
1897 {
1898  int ch_age = m_covey->GetChickAge();
1899  m_covey->MoveDistance( g_MaxWalk[ch_age], 10, 10000 );
1900  return pars_FCaringForYoung;
1901 }
1902 //------------------------------------------------------------------------------
1903 
1913 {
1914  // First check that we are not too late in the year
1916  if ( m_MyMate ) {
1920  m_MyMate = NULL;
1921  }
1922  m_covey->SetFixed( false ); // ensure we do not have a fixed territory loc
1923  return pars_FFlocking;
1924  }
1925  int steps = 0;
1926  do {
1927  if (m_covey->FlyTo( random( cfg_par_female_movement_max.value() ) )) {
1928  // OK so ask the covey about quality here
1929  double q = m_covey->AssessHabitatQualityFaster();
1930  int today = m_OurLandscape->SupplyDayInYear();
1931  int dayspast = today - cfg_par_start_dissolve.value(); // start day as soon as covey dissolve starts to happen
1932  double terr_score = m_OurPopulationManager->GetHabitatQuality(dayspast);
1933  // Test whether the score is above the minimum quality required.
1934  if ( q > terr_score )
1935  {
1936  // Is the covey too close to another, therefore this location is unsuitable?
1937  if ( !m_covey->TooClose() ) {
1938  m_HaveTerritory = true;
1939  m_covey->FixHabitat();
1940  m_covey->SetFixed( true ); // Can read this with IsFixed()
1941  #ifdef __PAR_DEBUG
1943  #endif
1944  m_clutch_number = 0;
1945  if ( !m_MyMate ) return pars_FAttractingMate;
1946  else {
1947  // No need to tell the male, he will check the m_HaveTerritory flag
1950  }
1951  }
1952  }
1953  }
1954  } while ( ++steps < 50 ); // this many goes per day
1955  m_HaveTerritory = false;
1956  // try again tomorrow
1957  return pars_FFindingTerritory;
1958 }
1959 //------------------------------------------------------------------------------
1960 
1961 
1963 {
1969  {
1970  return pars_FAttractingMate;
1971  }
1972  else
1973  {
1974  // Unlock covey 'peg'.
1975  m_covey->SetFixed( false );
1976  return pars_FFlocking;
1977  }
1978 }
1979 //------------------------------------------------------------------------------
1980 
1985 {
1986  if ( m_CurrentStateNo == -1 ) return; // Don't kill me twice
1987  // Do I have kids? - dont' care - taken care of by covey
1988  // Do I have a clutch & mate, if so tell them
1993  m_MyMate = NULL;
1994  RemoveOldMate(false);
1995  m_CurrentStateNo = -1;
1996  m_StepDone = true;
1997  m_covey->NestLeave(); // Just in case this is not already done
1998  m_covey->RemoveMember( this );
2000  // Output as necessary
2002  //m_covey->SanityCheck2(m_covey->GetOurChicks() );
2003  // m_OurPopulationManager->WriteParAdMort( m_OurLandscape->SupplyGlobalDate(), m_age, 1, m_signal );
2004 }
2005 
2006 
2007 
2008 //------------------------------------------------------------------------------
2009 
2010 //'''''''''''''''' Female Interface Functions '''''''''''''''''''''''''''''''''
2011 
2016 {
2017  m_covey->SetFixed( false );
2018  if (m_UncleStatus) {
2019  SetUncleStatus( false );
2020  }
2021  RemoveOldMate(false);
2023 }
2024 
2025 
2026 
2027 //------------------------------------------------------------------------------
2032 {
2033  m_MyMate = pc_data->m_male;
2034  RemoveOldMate(false);
2035  SwitchCovey( pc_data->m_covey );
2036  // The state she needs to go to depends on she has a
2037  // territory or not
2038  if ( HaveTerritory() )
2039  {
2042  }
2043  else
2045  m_clutch_number = 0;
2046  m_clutchproduced = false;
2047 }
2048 
2049 
2050 
2051 //------------------------------------------------------------------------------
2052 
2057 {
2058  if (m_state == pars_FIncubating) {
2059  m_state = FStartingNewBrood(false);
2060  } else m_state = FStartingNewBrood(true);
2061  m_covey->NestLeave();
2062  m_MyClutch = NULL;
2063 }
2064 //------------------------------------------------------------------------------
2065 
2070 {
2071  if (m_state==pars_FIncubating) {
2073  {
2074  //Optional output - can depend on the definition of predation in use.
2075  //m_OurPopulationManager->m_Ourkfactors->incNoHensPredated();
2076  FDying();
2077  }
2078  }
2079  OnClutchDeath();
2080 }
2081 //------------------------------------------------------------------------------
2082 
2087 {
2088  m_MyClutch = pc_data->m_clutch;
2090 }
2091 //------------------------------------------------------------------------------
2092 
2097 {
2099  m_covey->NestLeave();
2100  m_MyClutch = NULL;
2101 }
2102 //------------------------------------------------------------------------------
2103 
2108 {
2110  m_MyMate = NULL;
2111  m_HaveTerritory = false;
2112 }
2113 //------------------------------------------------------------------------------
2114 
2119 {
2121  m_HaveTerritory = false;
2122  m_MyMate = NULL;
2123 }
2124 //------------------------------------------------------------------------------
2125 
2130 {
2131  if ( pc_data->m_male != m_MyMate )
2132  {
2133  m_OurLandscape->Warn( "Partridge_Female::OnMateDying(): ""m_MyMate is not the mate that is dying", "" );
2134  exit( 1 );
2135  }
2136  RemoveOldMate(false);
2137  m_MyMate = NULL;
2138  // What she does now depends on whether the chicks have hatched etc.
2139  switch ( m_state )
2140  {
2141  case pars_FCaringForYoung:
2142  break; // keep doing it
2143  case pars_FFlocking:
2145  break;
2148  break;
2149  case pars_FIncubating:
2150  case pars_FLaying:
2151  //break;
2153  m_MyClutch->OnGivenUp();
2154  m_MyClutch = NULL;
2155  m_covey->SetFixed( false );
2156  m_covey->NestLeave();
2157  break;
2158  case pars_FMakingNest:
2162  m_covey->SetFixed( false );
2163  m_covey->NestLeave();
2164  break;
2165  default:
2166  m_OurLandscape->Warn( "Partridge_Female::OnMateDeath - unknown pars type", NULL );
2167  exit( 1 );
2168  }
2169 }
2170 
2171 
2172 
2173 //------------------------------------------------------------------------------
2174 
2175 
2176 //------------------------------------------------------------------------------
2177 //'''''''''''''' Female Interface Functions End ''''''''''''''''''''''''''''''
2178 
2179 //------------------------------------------------------------------------------
2180 // Partridge_Male
2181 //------------------------------------------------------------------------------
2182 
2183 Partridge_Male::Partridge_Male( int a_born_x, int a_born_y, int a_x, int a_y, Partridge_Covey * a_covey, Landscape * a_map,
2184  int a_family_counter, Partridge_Population_Manager * a_manager ) :
2185  Partridge_Base( a_born_x, a_born_y, a_x, a_y, a_family_counter, a_covey, a_map, a_manager )
2186  {
2187  m_MyOldWife=NULL; // Cant call removeOldMate due to knock on effects
2188  m_MyMate = NULL;
2191  //m_visitors_pass = false;
2192 }
2193 
2194 
2195 
2196 //------------------------------------------------------------------------------
2197 
2203 {
2204 #ifdef __PAR_DEBUG
2206 #endif
2207  m_age++; // Get a day older
2208  if ( m_age >= m_lifespan )
2209  {
2210  m_signal = 0;
2211  MDying();
2212  }
2213  else if ( !DailyMortality() ) CheckManagement();
2214  else
2215  {
2216  m_signal = 1;
2217  MDying();
2218  }
2219 #ifdef __PAR_DEBUG
2221 #endif
2222 }
2223 //------------------------------------------------------------------------------
2224 
2229 {
2230 #ifdef __PAR_DEBUG
2232 
2233 #endif
2234  if ( m_CurrentStateNo == -1 || m_StepDone )
2235  return;
2236  switch ( m_state )
2237  {
2238  case pars_Initiation:
2240  break;
2241  case pars_MFlocking:
2242  m_state = MFlocking();
2243  m_StepDone = true;
2244  break;
2245  case pars_MFindingMate:
2246  m_state = MFindingMate();
2247  m_StepDone = true;
2248  break;
2249  case pars_MPairing:
2250  m_state = MPairing();
2251  m_StepDone = true;
2252  break;
2253  case pars_MGuardingMate:
2254  m_state = MGuardingMate();
2255  m_StepDone = true;
2256  break;
2257  case pars_MCaringForYoung:
2259  m_StepDone = true;
2260  break;
2261  case pars_MDying:
2262  case pars_Destroy:
2263  m_StepDone = true;
2264  break;
2265  case pars_MFollowingMate:
2266  m_state = MFollowingMate();
2267  m_StepDone = true;
2268  break;
2269  default:
2270  m_OurLandscape->Warn( "Partridge_Male::Step - unknown pars type", NULL );
2271  exit( 1 );
2272  }
2273 #ifdef __PAR_DEBUG
2275 #endif
2276 }
2277 
2278 
2279 
2280 //------------------------------------------------------------------------------
2281 
2286 {
2287  switch ( m_state )
2288  {
2289  case pars_Initiation:
2290  case pars_MFlocking:
2291  case pars_MFindingMate:
2292  case pars_MPairing:
2293  case pars_MGuardingMate:
2294  case pars_MFollowingMate:
2295  case pars_MCaringForYoung:
2296  case pars_MDying:
2297  case pars_Destroy:
2298  break;
2299  default:
2300  m_OurLandscape->Warn( "Partridge_Male::EndStep - unknown pars type", NULL );
2301  exit( 1 );
2302  }
2303 }
2304 //------------------------------------------------------------------------------
2305 
2310 {
2311  switch ( event )
2312  {
2313  case sleep_all_day:
2314  break;
2315  case autumn_plough:
2316  break;
2317  case autumn_harrow:
2318  break;
2319  case autumn_roll:
2320  break;
2321  case autumn_sow:
2322  break;
2323  case winter_plough:
2324  break;
2325  case deep_ploughing:
2326  break;
2327  case spring_plough:
2328  break;
2329  case spring_harrow:
2330  break;
2331  case spring_roll:
2332  break;
2333  case spring_sow:
2334  break;
2335  case fp_npks:
2336  break;
2337  case fp_npk:
2338  break;
2339  case fp_pk:
2340  break;
2341  case fp_liquidNH3:
2342  break;
2343  case fp_slurry:
2344  break;
2345  case fp_manganesesulphate:
2346  break;
2347  case fp_manure:
2348  break;
2349  case fp_greenmanure:
2350  break;
2351  case fp_sludge:
2352  break;
2353  case fa_npk:
2354  break;
2355  case fa_pk:
2356  break;
2357  case fa_slurry:
2358  break;
2359  case fa_ammoniumsulphate:
2360  break;
2361  case fa_manure:
2362  break;
2363  case fa_greenmanure:
2364  break;
2365  case fa_sludge:
2366  break;
2367  case glyphosate:
2368  case herbicide_treat:
2369  break;
2370  case growth_regulator:
2371  break;
2372  case fungicide_treat:
2373  break;
2374  case syninsecticide_treat:
2375  case insecticide_treat:
2376  case product_treat:
2377  break;
2378  case molluscicide:
2379  break;
2380  case row_cultivation:
2381  break;
2382  case strigling:
2383  if ( g_rand_uni() < 0.01 ) MDying();
2384  break;
2385  case hilling_up:
2386  break;
2387  case water:
2388  break;
2389  case swathing:
2390  break;
2391  case harvest:
2392  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2393  break;
2394  case cattle_out:
2395  break;
2396  case cattle_out_low:
2397  break;
2398  case cut_to_hay:
2399  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2400  break;
2401  case cut_to_silage:
2402  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2403  break;
2404  case straw_chopping:
2405  break;
2406  case hay_turning:
2407  break;
2408  case hay_bailing:
2409  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2410  break;
2411  case stubble_harrowing:
2412  break;
2414  break;
2415  case burn_straw_stubble:
2416  break;
2417  case mow:
2418  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2419  break;
2420  case cut_weeds:
2421  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2422  break;
2423  case pigs_out:
2424  break;
2425  case strigling_sow:
2426  if ( g_rand_uni() < 0.01 ) MDying();
2427  break;
2428  default:
2429  m_OurLandscape->Warn( "Skylark_Clutch::OnFarmEvent(): Unknown event type:", m_OurLandscape->EventtypeToString( event ) );
2430  exit( 1 );
2431  }
2432  // Must incorporate a test here in case the animal is dead - killing it twice
2433  // can be a bad idea
2434  if ( m_state == pars_Destroy ) return true;
2435  else
2436  return false;
2437 }
2438 
2439 
2440 
2441 //------------------------------------------------------------------------------
2442 
2447 {
2448 
2449  double chance = g_rand_uni();
2450  double extramort=1.0;
2451 
2452 // extra mortality chance if in a covey alone
2453  if ( m_covey->GetCoveySize() == 1 )
2454  {
2456  }
2457  // Winter mortality between April and Sept
2458  int today = m_OurLandscape->SupplyDayInYear();
2459  // If the female is looking for a territory then the mortality is higher
2460  if (m_MyMate!=NULL) {
2462  if ( chance < cfg_par_adult_mortalitySpring.value() ) return true;
2463  return false;
2464  }
2465  }
2466  // Is it winter?
2467  if (( ( today >= October ) || ( today < April )) ) {
2468  if (m_OurPopulationManager->SupplyShouldFlock()) { // We are in the "Winter Period"
2469  if ( chance < cfg_par_adult_mortalityWinter.value()*extramort ) {
2470  return true;
2471  } else return false;
2472  } else { // Finding territory value
2473  if ( chance < cfg_par_adult_mortalitySpring.value()*extramort ) {
2474  return true;
2475  } else return false;
2476  }
2477  } else // Not winter and not finding territory
2478  {
2479  if ( chance < (cfg_par_adult_mortalitySummer.value()*extramort) ) return true;
2480  }
2481  return false;
2482 
2483 }
2484 //------------------------------------------------------------------------------
2485 
2490 {
2491  m_covey->MoveDistance( 1000, 10, 10000 );
2492  return pars_MFlocking;
2493 }
2494 //------------------------------------------------------------------------------
2495 
2500 {
2501  if ( m_UncleStatus )
2502  {
2503  // This is no good - he can't stay an uncle anymore - must leave
2504  m_covey->RemoveMember( this );
2505  MakeCovey();
2506  m_UncleStatus = false; // just in case
2507  return pars_MFlocking; // this will send him back here eventually.
2508  }
2510  {
2511  m_UncleStatus = false; // just in case
2512  m_covey->SetFixed( false ); // ensure we do not have a fixed territory loc
2513  //}
2514  return pars_MFlocking;
2515  }
2516  // Depends on the date what happens.
2517  // If early then he will keep hopping if possible, if late and breeding is
2518  // starting then he must wander.
2519  //
2521  {
2522  // Still early so we need a list of possible coveys to hop to
2524  {
2526  if ( pc )
2527  {
2529  if ( m_MyMate )
2530  {
2531  m_covey->RemoveMember( this ); // NB the next two lines MUST come after a call to RemoveMember for adults if they are not dying
2532  m_UncleStatus = false;
2533  MakeCovey(); // Has his own now.
2534  }
2535  }
2536  }
2537  }
2538  else
2539  {
2540  // Must leave the covey he is with if he is not already alone
2541  if ( m_covey->GetCoveySize() > 1 )
2542  {
2543  m_covey->RemoveMember( this );
2544 // m_visitors_pass = false;
2545  m_UncleStatus = false;
2546  MakeCovey();
2547  }
2550  }
2551  // If he has found a mate he will have made his covey and now calls her to him
2552  if ( m_MyMate ) {
2553  // The line below is really debug information, this identifies the caller
2555  // Call the female via the message centre
2558  // This message also sets the females covey to the male's
2560 #ifdef __PAR_DEBUG
2562 #endif
2563  if ( !m_MyMate->HaveTerritory() ) return pars_MFollowingMate;
2564  return pars_MGuardingMate;
2565  }
2566  return pars_MFindingMate;
2567 }
2568 
2569 
2570 
2571 //------------------------------------------------------------------------------
2572 
2577 {
2578 #ifdef __PAR_DEBUG
2580 
2581 #endif
2582  if ( m_MyMate->HaveTerritory() ) return pars_MGuardingMate;
2583  return pars_MFollowingMate;
2584 }
2585 //------------------------------------------------------------------------------
2586 
2588 {
2593 #ifdef __PAR_DEBUG
2595 
2596 #endif
2597  if ( !m_MyMate->HaveTerritory() ) return pars_MFollowingMate;
2598  return pars_MGuardingMate;
2599 }
2600 
2601 
2602 
2603 //------------------------------------------------------------------------------
2604 
2606 {
2610  return pars_MGuardingMate;
2611 }
2612 //------------------------------------------------------------------------------
2613 
2618 {
2619  // dist move is calculated as a function of chick food need-
2620  // First get the chick age
2621  int ch_age = m_covey->GetChickAge();
2622  m_covey->MoveDistance( g_MaxWalk[ch_age], 10, 10000 );
2623  return pars_MCaringForYoung;
2624 }
2625 //------------------------------------------------------------------------------
2626 
2631 {
2632 
2633  if ( m_CurrentStateNo != -1 )
2634  { // Don't kill me twice
2635  // Tell my mate if I have one
2636  if ( m_MyMate )
2637  {
2638  // The line below is really debug information, this identifies the caller
2640  // Call the female via the message centre
2643  m_MyMate = NULL;
2644  }
2645  RemoveOldMate(false);
2646  m_CurrentStateNo = -1;
2647  m_StepDone = true;
2648  //m_covey->SanityCheck2(m_covey->GetOurChicks() );
2649 
2650  m_covey->RemoveMember( this );
2653  // m_OurPopulationManager->WriteParAdMort( m_OurLandscape->SupplyGlobalDate(), m_age, 0, m_signal );
2654  }
2655 }
2656 //------------------------------------------------------------------------------
2657 
2661 void Partridge_Male::RemoveOldMate( bool a_knockon ) {
2662  if (m_MyOldWife!= NULL) {
2663  if (!a_knockon) m_MyOldWife->RemoveOldMate(true);
2664  m_MyOldWife= NULL;
2665  }
2666  }
2667 //------------------------------------------------------------------------------
2668 
2669 
2670 //'''''''''''''''''''' Male Interface Functions '''''''''''''''''''''''''''''
2671 
2676 {
2677  // He doesn't actually do anything, just records that fact that this is
2678  // what his biological counterpart would be doing now.
2680 #ifdef __PAR_DEBUG
2682 #endif
2683 }
2684 //------------------------------------------------------------------------------
2685 
2690 {
2691  m_MyMate = NULL;
2693 }
2694 //------------------------------------------------------------------------------
2695 
2700 {
2701  m_MyMate = NULL;
2703 }
2704 //------------------------------------------------------------------------------
2705 
2710 {
2711  m_MyMate = NULL;
2713 
2714 }
2715 //------------------------------------------------------------------------------
2720 {
2722  RemoveOldMate(false);
2723 }
2724 //------------------------------------------------------------------------------
2725 
2730 {
2732 }
2733 //------------------------------------------------------------------------------
2734 
2739 {
2740 #ifdef __PAR_DEBUG
2741  if ( m_MyMate != NULL )
2742  {
2743  m_OurLandscape->Warn( "Partridge_Male::OnMating(): ""m_MyMate is not NULL on Mating", "" );
2744  exit( 1 );
2745  }
2746 #endif
2747  m_MyMate = a_mate;
2748  RemoveOldMate(false);
2750  SetFamily( m_MyMate->GetFamily() ); // synchronize families
2751 #ifdef __PAR_DEBUG
2753 #endif
2754 
2755 }
2756 //------------------------------------------------------------------------------
2757 
2762 {
2763 #ifdef __PAR_DEBUG
2765 
2766 #endif
2767  RemoveOldMate(false);
2768  m_MyMate = NULL;
2769  // This will send him to finding a mate if it is early, otherwise
2770  // indirectly to flocking unless he still has kids in which case he has to
2771  // look after them
2772  //
2773  if ( m_covey->GetOurChicks() == 0 ) m_state = pars_MFindingMate;
2774 }
2775 
2776 
2777 
2778 //------------------------------------------------------------------------------
2779 
2784 {
2785 #ifdef __PAR_DEBUG
2787 
2788 #endif
2789  m_MyMate = NULL;
2790  RemoveOldMate(false);
2792  m_covey->SetFixed( false );
2793 }
2794 //------------------------------------------------------------------------------
2795 //'''''''''''''' Male Interface Functions End ''''''''''''''''''''''''''''''''
2796 
2801 {
2802  //**CJT** DEBUG
2803  if ( m_MyMate )
2804  {
2805  // Check for mutual pointers here
2806  if ( m_MyMate->GetMate() != this )
2807  {
2808  m_OurLandscape->Warn( "Partridge_Male::CheckMatePointers(): ""Non-mutual mate pointers", "" );
2809  exit( 1 );
2810  }
2811  if ( m_state == pars_MFlocking )
2812  {
2813  m_OurLandscape->Warn( "Partridge_Male::CheckMatePointers(): ""Mated & Flocking", "" );
2814  exit( 1 );
2815  }
2816  if ( m_MyMate->GetCurrentStateNo() == -1 )
2817  {
2818  m_OurLandscape->Warn( "Partridge_Male::CheckMatePointers(): ""Dead Mate", "" );
2819  exit( 1 );
2820  }
2821  }
2822 }
2823 
2828 {
2829  //**CJT** DEBUG
2830  if ( m_MyMate )
2831  {
2832  // Check for mutual pointers here
2833  if ( m_MyMate->GetMate() != this )
2834  {
2835  m_OurLandscape->Warn( "Partridge_Female::CheckMatePointers(): ""Non-mutual mate pointers", "" );
2836  exit( 1 );
2837  }
2838  if ( m_state == pars_FFlocking )
2839  {
2840  m_OurLandscape->Warn( "Partridge_Female::CheckMatePointers(): ""Mated & Flocking", "" );
2841 
2842  exit( 1 );
2843  }
2844  if ( m_MyMate->GetCurrentStateNo() == -1 )
2845  {
2846  m_OurLandscape->Warn( "Partridge_Female::CheckMatePointers(): ""Dead Mate", "" );
2847  exit( 1 );
2848  }
2849  }
2850 }
2851 
2852 
2853 
2854 //-----------------------------------------------------------------------------
2855 //----------------- class k_factor methods ------------------------------------
2856 //-----------------------------------------------------------------------------
2857 
2859 {
2860  kfactorsfile = fopen("k_factors_output.txt", "w" );
2861  if ( !kfactorsfile ) {
2862  g_msg->Warn( "k_factors::k_factors()","Cannot open k_factors_output.txt" );
2863  exit( 1 );
2864  }
2867  reset();
2868 }
2869 //-----------------------------------------------------------------------------
2870 
2872 {
2873  fclose( kfactorsfile );
2874  delete m_ThisYear;
2875  delete m_LastYear;
2876 }
2877 
2878 //-----------------------------------------------------------------------------
2879 //----------------- class population_attributes methods ------------------------------------
2880 //-----------------------------------------------------------------------------
2881 
2883 {
2884  reset();
2885 }
2886 //-----------------------------------------------------------------------------
2887 
2889 {
2890 }
2891 //-----------------------------------------------------------------------------
2892 
2894 {
2895  //calcDickPottsk();
2896  fprintf( kfactorsfile, "%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n", m_rk1, m_rk2, m_rk3, m_rk4, m_rk5, m_rk6, m_dpk1,
2897  m_dpk2, m_dpk3, m_dpk4, m_dpk5 );
2898  fflush( kfactorsfile );
2899  DumpInfoDatabase();
2900  reset();
2901 }
2902 //-----------------------------------------------------------------------------
2903 
2905 {
2906  m_NoClutches = a_population_attributes->m_NoClutches;
2907  m_NoChicksHatched = a_population_attributes->m_NoChicksHatched;
2908  m_NoChicksSixWeeks = a_population_attributes->m_NoChicksSixWeeks;
2909  m_NoChicksSept = a_population_attributes->m_NoChicksSept;
2910  m_NoOldMales = a_population_attributes->m_NoOldMales;
2911  m_NoOldFemales = a_population_attributes->m_NoOldFemales;
2912  m_geomeanBroodSize = a_population_attributes->m_geomeanBroodSize;
2913  m_NoMalesSept = a_population_attributes->m_NoMalesSept;
2914  m_NoFemalesSept = a_population_attributes->m_NoFemalesSept;
2915  m_NoShotBirds = a_population_attributes->m_NoShotBirds;
2916  m_NoShotFemales = a_population_attributes->m_NoShotFemales;
2917  m_NoClutchesHatched = a_population_attributes->m_NoClutchesHatched;
2918  m_NoClutchesPredated = a_population_attributes->m_NoClutchesPredated;
2919  m_NoHensPredated = a_population_attributes->m_NoHensPredated;
2920  m_NoDeadChicks = a_population_attributes->m_NoDeadChicks;
2921  m_NoDeadFemales = a_population_attributes->m_NoDeadFemales;
2922  m_NoDeadMales = a_population_attributes->m_NoDeadMales;
2923  m_NoPairsApril = a_population_attributes->m_NoPairsApril;
2924  m_NoFemalesApril = a_population_attributes->m_NoFemalesApril;
2925  m_NoMalesApril = a_population_attributes->m_NoMalesApril;
2926  m_NoTerritorialFemalesApril = a_population_attributes->m_NoTerritorialFemalesApril;
2927  m_NoBirdsApril = a_population_attributes->m_NoBirdsApril;
2928  m_NoClutchesReplacements = a_population_attributes->m_NoClutchesReplacements;
2929  m_NoDeadClutches = a_population_attributes->m_NoDeadClutches;
2930  m_NoAgDeadClutches = a_population_attributes->m_NoAgDeadClutches;
2931  m_NoChick1sAug = a_population_attributes->m_NoChick1sAug;
2932  m_NoChick2sAug= a_population_attributes->m_NoChick2sAug;
2933  m_NoMalesAug= a_population_attributes->m_NoMalesAug;
2934  m_NoFemsAug = a_population_attributes->m_NoFemsAug;
2935  m_NoStarvedChicks = a_population_attributes->m_NoStarvedChicks;
2936  m_NoTerritorialFemalesMay = a_population_attributes->m_NoTerritorialFemalesMay;
2938 }
2939 //-----------------------------------------------------------------------------
2940 
2942 {
2943  m_NoClutches = 0;
2944  m_NoChicksHatched = 0;
2945  m_NoChicksSixWeeks = 0;
2946  m_NoChicksSept = 0;
2947  m_NoOldMales = 0;
2948  m_NoOldFemales = 0;
2949  m_geomeanBroodSize = 0.0;
2950  m_NoMalesSept = 0;
2951  m_NoFemalesSept = 0;
2952  m_NoShotBirds = 0;
2953  m_NoShotFemales = 0;
2954  m_NoClutchesHatched = 0;
2956  m_NoHensPredated = 0;
2957  m_NoDeadChicks = 0;
2958  m_NoDeadFemales = 0;
2959  m_NoDeadMales = 0;
2960  m_NoPairsApril = 0;
2961  m_NoFemalesApril = 0;
2962  m_NoMalesApril = 0;
2964  m_NoBirdsApril = 0;
2966  m_NoDeadClutches = 0;
2967  m_NoAgDeadClutches = 0;
2968  m_NoChick1sAug = 0;
2969  m_NoChick2sAug= 0;
2970  m_NoMalesAug= 0;
2971  m_NoFemsAug = 0;
2975 }
2976 //-----------------------------------------------------------------------------
2977 
2979 {
2980  m_ThisYear-> reset();
2981  m_rk1 = 0;
2982  m_rk2 = 0;
2983  m_rk3 = 0;
2984  m_rk4 = 0;
2985  m_rk5 = 0;
2986  m_dpk1 = 0;
2987  m_dpk2 = 0;
2988  m_dpk3 = 0;
2989  m_dpk4 = 0;
2990  m_dpk5 = 0;
2991 
2992 }
2993 
2995 {
2996  // These can be calculated on Sept 1st.
2997  double anum = 1 + ( m_ThisYear->m_NoClutches - m_ThisYear->m_NoHensPredated );
2998  m_rk2 = log10( ( 1 + m_ThisYear->m_NoClutches ) / anum );
2999  anum = 1 + m_ThisYear->m_NoClutchesHatched;
3000  m_rk1 = log10( ( 1 + m_ThisYear->m_NoClutches ) / anum ) - m_rk2;
3001  anum = 1 + m_ThisYear->m_NoChicksSept;
3002  m_rk3 = log10( ( 1 + m_ThisYear->m_NoChicksHatched ) / anum );
3003 }
3004 //-----------------------------------------------------------------------------
3005 
3007 {
3008  // This can only be calculated after shooting
3009  double NoBirdsAfterShoot = ( ( m_ThisYear->m_NoMalesSept + m_ThisYear->m_NoFemalesSept ) - m_ThisYear->m_NoShotBirds );
3010  double anum = 1 + NoBirdsAfterShoot;
3011  m_rk4 = log10( ( 1 + m_ThisYear->m_NoMalesSept + m_ThisYear->m_NoFemalesSept ) / anum );
3012 }
3013 //-----------------------------------------------------------------------------
3014 
3016 {
3017  // K5 is the number of males and females in Sept/those that survive to
3018  // breeding time. This means k5 can only be calculated in April.
3019  double anum = 1 + m_ThisYear->m_NoFemalesSept - m_ThisYear->m_NoShotBirds / 2;
3020  m_rk5 = log10( anum / ( double )( 1 + m_ThisYear->m_NoFemalesApril ) );
3022  m_rk6 = log10( anum / ( double )( 1 + m_ThisYear->m_NoBirdsApril ) );
3023 }
3024 //-----------------------------------------------------------------------------
3025 
3027 {
3028  // Dick makes some assumptions such it is assumed old males seen on 1st sept
3029  // is the same number as the number of pairs in Spring.
3030  // He also uses a calculation for the number of chicks hatched based on
3031  // the geometric mean of brood size on 1st September.
3032  // k2 assumes the differences between old males and old females is female on nest mortality
3033 
3034  // Requires the following values to be set before entry:
3035  // 1) GeoMean brood size, 1st sept.
3036  // 2) No. old males
3037  // 3) No. old females
3038  // 4) No. Males Sept
3039  // 5) No. Females Sept
3040  // 6) No. Females Sept of last year
3041  // 7) No. chicks at 1st Sept.
3042 
3043  // Calculate HatchedChicks
3044  double HatchedChicks;
3045  double CSR;
3046  if ( m_LastYear->m_geomeanBroodSize < 10.0 ) CSR = 0.03665 * ( pow( ( double )m_LastYear->m_geomeanBroodSize, ( double )1.293 ) );
3047  else
3048  CSR = m_LastYear->m_geomeanBroodSize / 13.84;
3049  if ( CSR > 0 ) HatchedChicks = m_LastYear->m_NoChicksSept / CSR;
3050  else
3051  HatchedChicks = 0;
3052  //
3053  double Broods = HatchedChicks / 13.8; // 13.8 is the mean brood size used by Dick, but we use 14
3054  // k2 is assuming old males is the same as pairs
3055  m_dpk2 = log10( ( double )( 1 + m_LastYear->m_NoOldMales ) / ( double )( 1 + m_LastYear->m_NoOldFemales ) );
3056  // k1 assumes old males in sept is the same as no. pairs in spring
3057  m_dpk1 = log10( ( double )( 1 + m_LastYear->m_NoOldMales ) / ( 1 + Broods ) ) - m_dpk2;
3058  // k3 contains a calculated number of chicks at six weeks based on the number
3059  // of chicks in Sept and brood size.
3060  m_dpk3 = log10( ( double )( 1 + HatchedChicks ) / ( double )( 1 + m_LastYear->m_NoChicksSept ) );
3061  // k4 Shooting numbers recorded so should be solid
3062  double NoBirdsAfterShoot = ( ( m_LastYear->m_NoMalesSept + m_LastYear->m_NoFemalesSept ) - m_LastYear->m_NoShotBirds );
3063  m_dpk4 = log10( ( double )( ( 1 + m_LastYear->m_NoMalesSept + m_LastYear->m_NoFemalesSept ) ) / ( double )( 1 + NoBirdsAfterShoot ) );
3064  // k5 - tricky one. Assumes 1:1 sex ratio. Assumes that the number of females
3065  // at the end of year 1 is equal to the number of breeding males and this is
3066  // equal to the number of old males in year 2. Hence the difference is the number
3067  // of birds that die of everything else except hen mortality.
3068  m_dpk5 = log10( ( double )( 1 + (m_LastYear->m_NoFemalesSept - m_LastYear->m_NoShotFemales)) / ( double )( 1 + m_ThisYear->m_NoOldMales ) );
3069  DumpInfoDatabase1( ( int )Broods, ( int )HatchedChicks, CSR );
3070 
3072  //m_ThisYear->reset(); // ***CJT*** 6/7/2010 removed because otherwise our counts are destroyed - why was this here?
3073 }
3074 //-----------------------------------------------------------------------------
3075 
3076 void k_factors::DumpInfoDatabase1( int Broods, int HC, double CSR )
3077 {
3078  FILE * idb = fopen("k_facInfoBase.txt", "a" );
3079  if ( !idb ) {
3080  g_msg->Warn( "k_factors::DumpInfoDatabase1","Cannot open k_facInfoBase.txt" );
3081  exit( 1 );
3082  }
3083  fprintf( idb, "%d\t%d\t%d\t%g\t", HC, Broods, m_ThisYear->m_NoOldMales, CSR );
3084  fclose( idb );
3085 }
3086 //-----------------------------------------------------------------------------
3087 
3089 {
3090  FILE * idb = fopen("k_facInfoBase.txt", "a" );
3091  if (!idb) {
3092  g_msg->Warn( "k_factors::DumpInfoDatabase","Cannot open k_facInfoBase.txt" );
3093  exit( 1 );
3094  }
3095  fprintf( idb, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%g\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
3102 
3103  /*
3104  1m_NoClutches,
3105  2m_NoClutchesHatched,
3106  3m_NoHensPredated,
3107  4m_NoChicksSixWeeks,
3108  5m_NoChicksSept,
3109  6m_NoMalesSept,
3110  7m_NoFemalesSept,
3111  8m_NoDeadFemales,
3112  9m_NoDeadMales,
3113  10m_NoShotBirds,
3114  11m_NoChicksHatched,
3115  12m_NoOldMales,
3116  13m_NoOldFemales,
3117  14m_geomeanBroodSize,
3118  15m_NoClutchesPredated,
3119  16m_NoFemalesApril,
3120  17m_NoTerritorialFemalesApril,
3121  18m_NoDeadChicks,
3122  19m_NoDeadClutches,
3123  20m_NoClutchesReplacements,
3124  21m_NoAgDeadClutches,
3125  22m_NoPairsApril,
3126  23m_NoMalesApril,
3127  24m_NoTerritorialFemalesMay,
3128  25m_NoNonTerritorialFemalesMay
3129  26m_NoMalesDec
3130  27m_NoFemalesDec
3131  28m_NoChick1sAug,
3132  29m_NoChick2sAug,
3133  30m_NoMalesAug,
3134  31m_NoFemsAug
3135  32m_NoStarvedChicks
3136  */
3137 
3138  fclose( idb );
3139 }
3140 //-----------------------------------------------------------------------------
3141 
3146 {
3147  FILE * idb = fopen("k_facInfoBase.txt", "w" );
3148  if (!idb) {
3149  g_msg->Warn("k_factors::CreateInfoDatabaseFile","Cannot open k_facInfoBase.txt" );
3150  exit( 1 );
3151  }
3152  fclose( idb );
3153 }
3154 //-----------------------------------------------------------------------------
3155 
3160 {
3161  if ( m_covey->GetCurrentStateNo() == -1 )
3162  {
3163  //exit(0);
3164  return 1;
3165  }
3166  if ( !m_covey->IsMember( this ) ) return 2;
3167  return 0;
3168 }
3169 
3170 
pars_ClDeveloping
Definition: Partridge_All.h:273
insecticide_treat
Definition: treatment.h:74
k_factors::calcreal_2
void calcreal_2()
Definition: Partridge_All.cpp:3006
Partridge_Base::m_object_type
Partridge_Object m_object_type
Type of pob object this is.
Definition: Partridge_All.h:418
g_MaxWalk
int g_MaxWalk[200]
Definition: Partridge_Population_Manager.cpp:66
Partridge_Population_Manager::m_Ourkfactors
k_factors * m_Ourkfactors
Pointer to kfactors object.
Definition: Partridge_Population_Manager.h:169
Clutch_struct::Mum
Partridge_Female * Mum
Definition: Partridge_All.h:365
population_attributes::incNoDeadClutches
void incNoDeadClutches()
Definition: Partridge_All.h:160
k_factors::m_ThisYear
population_attributes * m_ThisYear
Definition: Partridge_All.h:251
pcomm_MumDeadC
Definition: Partridge_Communication.h:66
Partridge_Base::SetUncleStatus
void SetUncleStatus(bool a_Status)
Set uncle status.
Definition: Partridge_All.h:442
Partridge_Population_Manager::GetHabitatQuality
double GetHabitatQuality(int a_day)
Definition: Partridge_Population_Manager.h:304
Partridge_Clutch::OnEaten
void OnEaten()
Message handler.
Definition: Partridge_All.cpp:645
k_factors::k_factors
k_factors()
Definition: Partridge_All.cpp:2858
Partridge_Male::Partridge_Male
Partridge_Male(int a_born_x, int a_born_y, int a_x, int a_y, Partridge_Covey *a_flock, Landscape *a_map, int a_family_counter, Partridge_Population_Manager *a_manager)
Constructor.
Definition: Partridge_All.cpp:2183
Partridge_Covey::RemoveMember
int RemoveMember(Partridge_Base *a_former_member)
Remove a member from the covey.
Definition: Partridge_Covey.cpp:1664
pars_FCaringForYoung
Definition: Partridge_All.h:283
strigling
Definition: treatment.h:77
Partridge_Covey::OnAddChick
void OnAddChick(Partridge_Female *a_pf)
Add a chick.
Definition: Partridge_Covey.cpp:2451
g_par_rainfactor
double g_par_rainfactor
Definition: Partridge_Population_Manager.cpp:63
Partridge_Base::m_family_counter
int m_family_counter
Family ID.
Definition: Partridge_All.h:408
hay_bailing
Definition: treatment.h:89
k_factors::m_rk5
double m_rk5
Definition: Partridge_All.h:244
cfg_par_starve_threshold
static CfgInt cfg_par_starve_threshold("PAR_STARVE_THRESHOLD", CFG_CUSTOM, 4)
Chick - no. days or negative energy before death.
k_factors::m_dpk1
double m_dpk1
Definition: Partridge_All.h:245
k_factors::DumpInfoDatabase
void DumpInfoDatabase()
Definition: Partridge_All.cpp:3088
autumn_roll
Definition: treatment.h:38
Partridge_Chick::Partridge_Chick
Partridge_Chick(int a_x, int a_y, Partridge_Female *a_mother, Partridge_Covey *a_flock, Landscape *a_map, bool a_sex, int a_family_counter, Partridge_Population_Manager *a_manager)
Constructor.
Definition: Partridge_All.cpp:663
Partridge_struct::family_counter
int family_counter
Definition: Partridge_All.h:350
Partridge_Base::m_state
Partridge_State m_state
Current behavioural state.
Definition: Partridge_All.h:422
Partridge_Female
The partridge female class.
Definition: Partridge_All.h:770
Partridge_Communication::PassMessage
bool PassMessage(PartridgeCommunicationData *pc_data, TypeOfPartridge_Communication pc)
Pass a message.
Definition: Partridge_Communication.cpp:86
Partridge_Chick::OnYouAreDead
void OnYouAreDead()
Message handler.
Definition: Partridge_All.cpp:1016
Chick_struct::Mum
Partridge_Female * Mum
Definition: Partridge_All.h:376
Partridge_Clutch::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
Handle farm event.
Definition: Partridge_All.cpp:380
Partridge_Female::OnMating
void OnMating(PartridgeCommunicationData *pc_datae)
Message handler.
Definition: Partridge_All.cpp:2031
Partridge_Chick::m_sex
bool m_sex
Sex.
Definition: Partridge_All.h:590
Partridge_Clutch::OnGivenUp
void OnGivenUp()
Message handler.
Definition: Partridge_All.cpp:631
k_factors::m_rk3
double m_rk3
Definition: Partridge_All.h:244
Partridge_Population_Manager
The population manager for partridge objects.
Definition: Partridge_Population_Manager.h:83
pars_MFollowingMate
Definition: Partridge_All.h:279
cfg_par_max_terr_qual
CfgInt cfg_par_max_terr_qual("PAR_MAX_TERR_QUAL", CFG_CUSTOM, 13000)
The minimum territory quality needed in early season.
Partridge_Male::MFindingMate
Partridge_State MFindingMate(void)
State male finding mate.
Definition: Partridge_All.cpp:2499
cfg_par_clutch_mortality
static CfgFloat cfg_par_clutch_mortality("PAR_CLUTCH_MORTALITY", CFG_CUSTOM, 0.00135)
Clutch - daily probability of non-explicitly modelled mortality.
population_attributes::m_NoMalesSept
int m_NoMalesSept
Definition: Partridge_All.h:53
population_attributes::m_NoDeadMales
int m_NoDeadMales
Definition: Partridge_All.h:75
k_factors::m_dpk4
double m_dpk4
Definition: Partridge_All.h:245
Partridge_Base::MakeCovey
void MakeCovey()
Create our own covey.
Definition: Partridge_All.cpp:206
population_attributes::m_NoNonTerritorialFemalesMay
int m_NoNonTerritorialFemalesMay
Definition: Partridge_All.h:77
Partridge_State
Partridge_State
Definition: Partridge_All.h:266
cfg_par_days_per_egg
static CfgFloat cfg_par_days_per_egg("PAR_DAY_PER_EGG", CFG_CUSTOM, 1.5)
Days taken to lay 1 egg.
Partridge_Female::FFindingTerritory
Partridge_State FFindingTerritory(void)
Female finding 'territory' state.
Definition: Partridge_All.cpp:1912
pcomm_ClutchEaten
Definition: Partridge_Communication.h:68
cfg_par_ad_cut
static CfgFloat cfg_par_ad_cut("PAR_AD_CUT_MORT", CFG_CUSTOM, 0.01)
Adult % mortality on cutting.
population_attributes::m_NoStarvedChicks
int m_NoStarvedChicks
Definition: Partridge_All.h:84
Partridge_struct::L
Landscape * L
Definition: Partridge_All.h:348
population_attributes::m_geomeanBroodSize
double m_geomeanBroodSize
Definition: Partridge_All.h:60
fa_ammoniumsulphate
Definition: treatment.h:65
autumn_harrow
Definition: treatment.h:37
population_attributes::m_NoTerritorialFemalesApril
int m_NoTerritorialFemalesApril
Definition: Partridge_All.h:67
Partridge_Female::m_MyClutch
Partridge_Clutch * m_MyClutch
A pointer to any current clutch.
Definition: Partridge_All.h:823
Partridge_Base::Partridge_Base
Partridge_Base(int a_born_x, int a_born_y, int a_x, int a_y, int a_family_counter, Partridge_Covey *a_covey, Landscape *a_map, Partridge_Population_Manager *a_manager)
Constructor for Partridge_Base.
Definition: Partridge_All.cpp:156
cfg_buildupwait
static CfgInt cfg_buildupwait("PAR_BUILDUP_WAIT", CFG_CUSTOM, 130)
Time period after finding territory before making nest.
Partridge_Female::FLaying
Partridge_State FLaying(void)
Female laying state.
Definition: Partridge_All.cpp:1768
population_attributes::m_NoOldFemales
int m_NoOldFemales
Definition: Partridge_All.h:59
population_attributes::incNoAgDeadClutches
void incNoAgDeadClutches()
Definition: Partridge_All.h:164
k_factors::m_dpk2
double m_dpk2
Definition: Partridge_All.h:245
k_factors::m_rk6
double m_rk6
Definition: Partridge_All.h:244
Partridge_Clutch::EndStep
virtual void EndStep(void)
Clutch EndStep.
Definition: Partridge_All.cpp:327
k_factors::m_rk4
double m_rk4
Definition: Partridge_All.h:244
Partridge_Male::OnMateDying
void OnMateDying()
Message handler.
Definition: Partridge_All.cpp:2761
Partridge_Male::m_lifespan
int m_lifespan
Physiological lifespan.
Definition: Partridge_All.h:674
pars_MCaringForYoung
Definition: Partridge_All.h:279
population_attributes::m_NoChicksHatched
int m_NoChicksHatched
Definition: Partridge_All.h:51
k_factors::m_rk2
double m_rk2
Definition: Partridge_All.h:244
autumn_sow
Definition: treatment.h:41
population_attributes::m_NoDeadChicks
int m_NoDeadChicks
Definition: Partridge_All.h:73
population_attributes::m_NoChick2sAug
int m_NoChick2sAug
Definition: Partridge_All.h:81
Partridge_Female::FCaringForYoung
Partridge_State FCaringForYoung(void)
Female caring for young state.
Definition: Partridge_All.cpp:1896
cfg_par_max_lifespan
CfgInt cfg_par_max_lifespan("PAR_MAX_LIFESPAN", CFG_CUSTOM, 3650)
Maximum physiological lifespan.
glyphosate
Definition: treatment.h:102
pcomm_MovingHome
Definition: Partridge_Communication.h:70
cfg_par_adult_mortalityWinter
static CfgFloat cfg_par_adult_mortalityWinter("PAR_ADULT_MORTALITYWINTER", CFG_CUSTOM, 0.0217)
Adults - daily probability of non-explicitly modelled mortality in Winter.
harvest
Definition: treatment.h:82
Partridge_Covey::GetmaxFoodNeedToday
double GetmaxFoodNeedToday()
Return the maximum food need today.
Definition: Partridge_Covey.h:416
April
const int April
Definition: landscape.h:39
k_factors::kfactorsfile
FILE * kfactorsfile
Definition: Partridge_All.h:243
Partridge_Population_Manager::ClutchDensity
int ClutchDensity(int x, int y, int radius)
Returns clutch density at x,y with radius radius.
Definition: Partridge_Population_Manager.cpp:569
cfg_par_female_incubation_mortality_const
static CfgFloat cfg_par_female_incubation_mortality_const("PAR_FEMALE_INCUBATION_MORTALITY_CONST", CFG_CUSTOM, 1.00192)
Increasing hen predation with density (intercept)
Partridge_Chick::ChDying
void ChDying(void)
Chick Dying.
Definition: Partridge_All.cpp:989
pcomm_ClutchMown
Definition: Partridge_Communication.h:65
k_factors::DumpInfoDatabase1
void DumpInfoDatabase1(int, int, double)
Definition: Partridge_All.cpp:3076
cfg_par_start_dissolve
CfgInt cfg_par_start_dissolve("PAR_START_DISSOLVE", CFG_CUSTOM, 30)
The earliest covey dissolve date.
Definition: Partridge_Population_Manager.cpp:94
TAnimal::m_OurLandscape
Landscape * m_OurLandscape
Definition: populationmanager.h:229
population_attributes::m_NoAgDeadClutches
int m_NoAgDeadClutches
Definition: Partridge_All.h:72
fp_slurry
Definition: treatment.h:52
Partridge_Covey::RemoveExtraChick
void RemoveExtraChick()
Decrement the chick number.
Definition: Partridge_Covey.h:466
Partridge_Covey::OnChickDeath
void OnChickDeath()
Remove a dead chick.
Definition: Partridge_Covey.cpp:2477
population_attributes::m_NoFemalesApril
int m_NoFemalesApril
Definition: Partridge_All.h:65
Partridge_Clutch::SetClutchSize
void SetClutchSize(int cs)
Set no. eggs.
Definition: Partridge_All.h:556
Partridge_Male::RemoveOldMate
void RemoveOldMate(bool a_knockon)
Forget any old mate.
Definition: Partridge_All.cpp:2661
Partridge_Population_Manager::m_comms_data
PartridgeCommunicationData * m_comms_data
Message data.
Definition: Partridge_Population_Manager.h:161
cfg_par_triggerlaying
static CfgInt cfg_par_triggerlaying("PAR_TRIGGERLAYING", CFG_CUSTOM, 850)
The number of minutes daylight as a minimum before triggering egg-laying behaviour.
Partridge_Covey::AssessHabitatQualityFaster
double AssessHabitatQualityFaster()
Assess habitat quality (efficient)
Definition: Partridge_Covey.cpp:1068
population_attributes
Definition: Partridge_All.h:45
Partridge_Female::m_MyMate
Partridge_Male * m_MyMate
A pointer to the current mate if any.
Definition: Partridge_All.h:819
Partridge_Covey::FindNeighbour
Partridge_Covey * FindNeighbour()
Finds the closest other covey.
Definition: Partridge_Covey.cpp:2290
fa_sludge
Definition: treatment.h:68
Partridge_Female::OnChicksMatured
void OnChicksMatured()
Message handler.
Definition: Partridge_All.cpp:2107
cfg_par_extraction_rate
static CfgFloat cfg_par_extraction_rate("PAR_EXTRACTION_RATE", CFG_CUSTOM, 0.0085)
Food extraction rate.
fp_greenmanure
Definition: treatment.h:56
Partridge_Covey::MoveDistance
void MoveDistance(int a_max_distance, int a_step_size, double a_food_density_needed)
Entry point for movement.
Definition: Partridge_Covey.cpp:652
population_attributes::m_NoMalesDec
int m_NoMalesDec
Definition: Partridge_All.h:69
Partridge_Base
Base class for all partridge classes.
Definition: Partridge_All.h:401
population_attributes::m_NoMalesApril
int m_NoMalesApril
Definition: Partridge_All.h:66
Partridge_Covey::GetOurChicks
int GetOurChicks()
Return the number of chicks.
Definition: Partridge_Covey.h:471
Partridge_Female::m_clutchproduced
bool m_clutchproduced
Flag for having produced a clutch.
Definition: Partridge_All.h:803
hay_turning
Definition: treatment.h:88
k_factors::calcDickPottsk
void calcDickPottsk()
Definition: Partridge_All.cpp:3026
g_FoodNeed
double g_FoodNeed[200]
Definition: Partridge_Population_Manager.cpp:65
Partridge_struct::m_covey
Partridge_Covey * m_covey
Definition: Partridge_All.h:349
Partridge_Clutch::AgDying
void AgDying()
Killed by management.
Definition: Partridge_All.cpp:364
pars_ChDying
Definition: Partridge_All.h:276
k_factors::m_rk1
double m_rk1
Definition: Partridge_All.h:244
Partridge_Male::GetMate
Partridge_Female * GetMate(void)
Are we paired?
Definition: Partridge_All.h:719
pars_MFindingMate
Definition: Partridge_All.h:279
k_factors::calcreal_1
void calcreal_1()
Definition: Partridge_All.cpp:2994
Partridge_Covey::GetChickAge
int GetChickAge()
Return chick age.
Definition: Partridge_Covey.h:486
population_attributes::m_NoFemsAug
int m_NoFemsAug
Definition: Partridge_All.h:83
Partridge_Chick2::Partridge_Chick2
Partridge_Chick2(int a_x, int a_y, Partridge_Female *a_mother, Partridge_Covey *a_flock, Landscape *a_map, bool a_sex, int a_family_counter, Partridge_Population_Manager *a_manager)
Constructor.
Definition: Partridge_All.cpp:1028
Partridge_Female::m_nest_counter
int m_nest_counter
Days spent nest building.
Definition: Partridge_All.h:809
Partridge_Female::OnClutchMown
void OnClutchMown()
Message handler.
Definition: Partridge_All.cpp:2069
Partridge_Covey::FindMeAMateInCovey
Partridge_Female * FindMeAMateInCovey(int a_family_counter)
Is their a suitable female mate in the covey?
Definition: Partridge_Covey.cpp:2334
water
Definition: treatment.h:80
Partridge_Male::BeginStep
virtual void BeginStep(void)
Male BeginStep.
Definition: Partridge_All.cpp:2202
pars_FAttractingMate
Definition: Partridge_All.h:283
fp_liquidNH3
Definition: treatment.h:51
population_attributes::decNoClutches
void decNoClutches()
Definition: Partridge_All.h:91
cfg_female_mowing_chance
static CfgFloat cfg_female_mowing_chance("PAR_FEMALEMOWNMORTALITY", CFG_CUSTOM, 1)
Chance of female death if incubating a mown clutch.
Partridge_Female::m_buildupwait
int m_buildupwait
Delay before breeding can commence.
Definition: Partridge_All.h:817
Partridge_struct::x
int x
Definition: Partridge_All.h:344
Partridge_Female::GetMate
Partridge_Male * GetMate(void)
Supply mate pointer.
Definition: Partridge_All.h:872
molluscicide
Definition: treatment.h:75
pcomm_Mating
Definition: Partridge_Communication.h:57
Chick_struct::sex
bool sex
Definition: Partridge_All.h:377
Partridge_Female::m_MyOldHusband
Partridge_Male * m_MyOldHusband
A record of the previous mate if any.
Definition: Partridge_All.h:821
Partridge_Base::CheckMatePointers
virtual void CheckMatePointers()
Debug.
Definition: Partridge_All.h:426
Partridge_Clutch::OnStartIncubating
void OnStartIncubating()
Flag under incubation.
Definition: Partridge_All.h:536
burn_straw_stubble
Definition: treatment.h:92
PartridgeCommunicationData::m_male
Partridge_Male * m_male
Definition: Partridge_Communication.h:83
Partridge_Male::DailyMortality
virtual bool DailyMortality()
Background mortality check.
Definition: Partridge_All.cpp:2446
population_attributes::~population_attributes
~population_attributes()
Definition: Partridge_All.cpp:2888
Partridge_Base::m_id
long m_id
Individual bird ID.
Definition: Partridge_All.h:406
Partridge_Covey::GetmaxAllowedMove
int GetmaxAllowedMove()
Return the max possible move distance today.
Definition: Partridge_Covey.h:411
pars_FStartingNewBrood
Definition: Partridge_All.h:282
g_msg
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:41
Partridge_Male::SetOldMate
void SetOldMate(Partridge_Female *pf)
Set old mate pointer.
Definition: Partridge_All.h:752
Partridge_Chick::Dying
virtual void Dying()
Generic dying handler.
Definition: Partridge_All.h:607
Partridge_Covey::FindMateInArea
Partridge_Female * FindMateInArea(int a_max_distance)
Find mate in area.
Definition: Partridge_Covey.cpp:1561
Partridge_Clutch::OnMumDead
void OnMumDead()
Message handler.
Definition: Partridge_All.cpp:617
cattle_out_low
Definition: treatment.h:100
pars_FBuildingUpResources
Definition: Partridge_All.h:282
Partridge_Population_Manager::CreateObjects
void CreateObjects(int ob_type, Partridge_struct *data, int number)
Definition: Partridge_Population_Manager.cpp:368
Partridge_Chick::m_starve
int m_starve
Days spent starving.
Definition: Partridge_All.h:592
Partridge_Base::PossibleMate
bool PossibleMate(Partridge_Base *a_partridge)
Can we mate?
Definition: Partridge_All.cpp:179
Chick_struct
Struct to pass chick information.
Definition: Partridge_All.h:374
population_attributes::m_NoChicksSept
int m_NoChicksSept
Definition: Partridge_All.h:55
pars_ChDeveloping
Definition: Partridge_All.h:276
k_factors::calcreal_3
void calcreal_3()
Definition: Partridge_All.cpp:3015
pcomm_StoppingBreeding
Definition: Partridge_Communication.h:69
fp_pk
Definition: treatment.h:50
fa_npk
Definition: treatment.h:61
Landscape
The landscape class containing all environmental and topographical data.
Definition: landscape.h:112
cattle_out
Definition: treatment.h:83
Partridge_Base::DailyMortality
virtual bool DailyMortality()
Background mortality test.
Definition: Partridge_All.cpp:228
Partridge_Clutch::m_underincubation
bool m_underincubation
Are we being incubated?
Definition: Partridge_All.h:528
Partridge_Clutch::DailyMortality
virtual bool DailyMortality()
Background mortality test.
Definition: Partridge_All.cpp:354
Partridge_Population_Manager::AddHatchSuccess
void AddHatchSuccess(int sz)
Definition: Partridge_Population_Manager.h:228
Partridge_Female::FAttractingMate
Partridge_State FAttractingMate(void)
Female attracting mate state.
Definition: Partridge_All.cpp:1962
October
const int October
Definition: landscape.h:45
Partridge_Male::Step
virtual void Step(void)
Male Step.
Definition: Partridge_All.cpp:2228
Partridge_Covey::TooClose
bool TooClose()
Test for another covey too close.
Definition: Partridge_Covey.cpp:1271
population_attributes::m_NoFemalesSept
int m_NoFemalesSept
Definition: Partridge_All.h:54
population_attributes::m_NoShotBirds
int m_NoShotBirds
Definition: Partridge_All.h:56
fp_npk
Definition: treatment.h:49
Partridge_Female::BeginStep
virtual void BeginStep(void)
Female BeginStep.
Definition: Partridge_All.cpp:1354
cfg_par_MaleMateSearchArea
static CfgInt cfg_par_MaleMateSearchArea("PAR_MALEMATESEARCHAREA", CFG_CUSTOM, 500)
Male mate searching radius.
pars_FIncubating
Definition: Partridge_All.h:283
pars_FFindingTerritory
Definition: Partridge_All.h:282
Partridge_Female::EndStep
virtual void EndStep(void)
Female EndStep.
Definition: Partridge_All.cpp:1441
Partridge_Population_Manager::WriteParClutches
void WriteParClutches(int a_min, int a_num1, int a_num2)
Output method.
Definition: Partridge_Population_Manager.cpp:1682
stubble_harrowing
Definition: treatment.h:90
cfg_par_days_to_make_nest
static CfgInt cfg_par_days_to_make_nest("PAR_DAYS_TO_MAKE_NEST", CFG_CUSTOM, 5)
Days used for nestbuilding.
Partridge_Clutch::Partridge_Clutch
Partridge_Clutch(int a_x, int a_y, Partridge_Female *a_mother, Partridge_Covey *a_flock, Landscape *a_map, int a_num_eggs, int a_family_counter, Partridge_Population_Manager *a_manager)
Constructor.
Definition: Partridge_All.cpp:261
cfg_par_infertile_eggs
static CfgFloat cfg_par_infertile_eggs("PAR_INFERTILE_EGGS", CFG_CUSTOM, 0.08)
Proportion of infertile eggs.
PartridgeCommunicationData::m_female
Partridge_Female * m_female
Definition: Partridge_Communication.h:84
autumn_plough
Definition: treatment.h:34
Partridge_Clutch::ClDeveloping
Partridge_State ClDeveloping(void)
Development state.
Definition: Partridge_All.cpp:538
Partridge_Covey::GetCoveySize
unsigned int GetCoveySize()
Return the covey size.
Definition: Partridge_Covey.h:476
fp_manure
Definition: treatment.h:55
Partridge_Male::MFollowingMate
Partridge_State MFollowingMate(void)
State male follow mate.
Definition: Partridge_All.cpp:2587
TAnimal::m_Location_y
int m_Location_y
Definition: populationmanager.h:228
strigling_sow
Definition: treatment.h:95
Partridge_Chick2::ChDeveloping
virtual Partridge_State ChDeveloping(void)
State developing.
Definition: Partridge_All.cpp:1205
Partridge_Female::m_startlayingday
int m_startlayingday
Records the day laying started.
Definition: Partridge_All.h:815
pars_ChMaturing
Definition: Partridge_All.h:276
Partridge_Chick::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
Farm event handler.
Definition: Partridge_All.cpp:765
population_attributes::m_NoBirdsApril
int m_NoBirdsApril
Definition: Partridge_All.h:68
k_factors::m_dpk5
double m_dpk5
Definition: Partridge_All.h:245
cfg_par_min_terr_qual
CfgInt cfg_par_min_terr_qual("PAR_MIN_TERR_QUAL", CFG_CUSTOM, 6900)
The minimum territory quality needed in late season.
cfg_par_base_mortality
static CfgInt cfg_par_base_mortality("PAR_BASE_MORTALITY", CFG_CUSTOM, 0)
Unused.
pob_Chick2
Definition: Partridge_All.h:297
AdultPartridge_struct::age
int age
Definition: Partridge_All.h:389
Partridge_Base::m_UncleStatus
bool m_UncleStatus
If has uncle status in the covey.
Definition: Partridge_All.h:416
Partridge_Clutch::Step
virtual void Step(void)
ClutchStep.
Definition: Partridge_All.cpp:297
Partridge_Base::m_born_x
int m_born_x
x-coord of birth
Definition: Partridge_All.h:412
cfg_par_cl_cut
static CfgFloat cfg_par_cl_cut("PAR_CL_CUT_MORT", CFG_CUSTOM, 0.29)
Clutch % mortality on cutting.
pcomm_FemaleGivingUp
Definition: Partridge_Communication.h:67
Partridge_Chick::Step
virtual void Step(void)
Chick Step.
Definition: Partridge_All.cpp:709
population_attributes::copyself
void copyself(population_attributes *a_population_attributes)
Definition: Partridge_All.cpp:2904
TAnimal
The base class for all ALMaSS animal classes.
Definition: populationmanager.h:205
Partridge_Male::MFlocking
Partridge_State MFlocking(void)
State male flocking.
Definition: Partridge_All.cpp:2489
Partridge_Covey
The collective for a family of partridges
Definition: Partridge_Covey.h:90
Partridge_Female::OnEggsHatch
void OnEggsHatch()
Message handler.
Definition: Partridge_All.cpp:2096
Partridge_Male::AmIaMember
int AmIaMember()
A debug function.
Definition: Partridge_All.cpp:3159
Partridge_Base::m_signal
int m_signal
Used to pass information to outputs.
Definition: Partridge_All.h:404
winter_plough
Definition: treatment.h:42
Partridge_Male::MCaringForYoung
Partridge_State MCaringForYoung(void)
State male caring for young.
Definition: Partridge_All.cpp:2617
Partridge_Female::FMakingNest
Partridge_State FMakingNest(void)
Female making nest state.
Definition: Partridge_All.cpp:1673
population_attributes::m_NoClutchesPredated
int m_NoClutchesPredated
Definition: Partridge_All.h:62
Partridge_Female::OnClutchDeath
void OnClutchDeath()
Message handler.
Definition: Partridge_All.cpp:2056
Partridge_struct::y
int y
Definition: Partridge_All.h:345
population_attributes::m_NoTerritorialFemalesMay
int m_NoTerritorialFemalesMay
Definition: Partridge_All.h:76
Partridge_Female::CheckMatePointers
virtual void CheckMatePointers()
Debug function - checking mate consistency
Definition: Partridge_All.cpp:2827
Partridge_Chick::DailyMortality
virtual bool DailyMortality()
Background mortality test.
Definition: Partridge_All.cpp:905
PartridgeCommunicationData::m_covey
Partridge_Covey * m_covey
Definition: Partridge_Communication.h:85
Partridge_Covey::SetFixed
void SetFixed(bool a_is_fixed)
Prevent/enable peg drift.
Definition: Partridge_Covey.h:572
Partridge_Male::OnStoppingBreeding
void OnStoppingBreeding()
Message handler.
Definition: Partridge_All.cpp:2709
pcomm_EggsHatch
Definition: Partridge_Communication.h:61
Partridge_Female::OnWaitForMale
void OnWaitForMale()
Message handler.
Definition: Partridge_All.cpp:2015
pcomm_MaleDying
Definition: Partridge_Communication.h:55
population_attributes::m_NoChicksSixWeeks
int m_NoChicksSixWeeks
Definition: Partridge_All.h:52
k_factors::m_LastYear
population_attributes * m_LastYear
Definition: Partridge_All.h:252
AdultPartridge_struct::sex
bool sex
Definition: Partridge_All.h:388
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
fp_sludge
Definition: treatment.h:57
AdultPartridge_struct
Struct to pass adult partridge information.
Definition: Partridge_All.h:386
Partridge_Base::m_age
int m_age
Age in days.
Definition: Partridge_All.h:410
pars_ClHatching
Definition: Partridge_All.h:273
k_factors::m_dpk3
double m_dpk3
Definition: Partridge_All.h:245
straw_chopping
Definition: treatment.h:87
population_attributes::m_NoClutchesReplacements
int m_NoClutchesReplacements
Definition: Partridge_All.h:61
cfg_par_chick_mortality
static CfgFloat cfg_par_chick_mortality("PAR_CHICK_MORTALITY", CFG_CUSTOM, 0.02043)
Chick - daily probability of non-explicitly modelled mortality.
cfg_par_min_lifespan
CfgInt cfg_par_min_lifespan("PAR_MIN_LIFESPAN", CFG_CUSTOM, 1825)
Minimum physiological lifespan.
fungicide_treat
Definition: treatment.h:73
deep_ploughing
Definition: treatment.h:43
Landscape::SupplyDayInYear
int SupplyDayInYear(void)
Definition: landscape.h:1596
pars_Destroy
Definition: Partridge_All.h:287
Partridge_Population_Manager::m_messagecentre
Partridge_Communication m_messagecentre
Message class pointer.
Definition: Partridge_Population_Manager.h:163
Partridge_Base::GetFamily
int GetFamily(void)
Supply family ID.
Definition: Partridge_All.h:467
cfg_par_adult_mortalitySummer
static CfgFloat cfg_par_adult_mortalitySummer("PAR_ADULT_MORTALITYSUMMER", CFG_CUSTOM, 0.0001)
Adults - daily probability of non-explicitly modelled mortality in Summer.
mow
Definition: treatment.h:93
fa_pk
Definition: treatment.h:62
Partridge_Female::DailyMortality
virtual bool DailyMortality()
Background mortality check.
Definition: Partridge_All.cpp:1454
TALMaSSObject::m_StepDone
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: populationmanager.h:118
Partridge_Female::OnMateDying
void OnMateDying(PartridgeCommunicationData *pc_data)
Message handler.
Definition: Partridge_All.cpp:2129
Partridge_Chick::EndStep
virtual void EndStep(void)
Chick EndStep.
Definition: Partridge_All.cpp:738
Partridge_Female::m_lifespan
int m_lifespan
Physiological lifespan in days.
Definition: Partridge_All.h:811
population_attributes::m_NoChick1sAug
int m_NoChick1sAug
Definition: Partridge_All.h:80
Partridge_Female::Partridge_Female
Partridge_Female(int a_born_x, int a_born_y, int a_x, int a_y, Partridge_Covey *a_flock, Landscape *a_map, int a_family_counter, Partridge_Population_Manager *a_manager)
Constructor.
Definition: Partridge_All.cpp:1334
Partridge_Female::GetNestingCoverDensity
double GetNestingCoverDensity()
Calls Partridge_Population_Manager::GetNestingCoverDensity
Definition: Partridge_All.cpp:273
spring_harrow
Definition: treatment.h:45
cfg_par_triggerlayingvar
static CfgInt cfg_par_triggerlayingvar("PAR_TRIGGERLAYINGVAR", CFG_CUSTOM, 48)
Generates variation around the laying trigger.
Clutch_struct
Struct to pass clutch information.
Definition: Partridge_All.h:362
Partridge_Male::OnMating
void OnMating(Partridge_Female *a_mate)
Message handler.
Definition: Partridge_All.cpp:2738
population_attributes::population_attributes
population_attributes()
Definition: Partridge_All.cpp:2882
Partridge_Population_Manager::FillCoveyNeigbourList
bool FillCoveyNeigbourList(Partridge_Covey *a_covey, int a_distance, int a_x, int a_y)
Get a list of neighbour covies.
Definition: Partridge_Population_Manager.cpp:1571
Partridge_Clutch::ClDying
void ClDying(void)
Dying state.
Definition: Partridge_All.cpp:596
Partridge_Chick::BeginStep
virtual void BeginStep(void)
Chick BeginStep.
Definition: Partridge_All.cpp:680
Partridge_Clutch::BeginStep
virtual void BeginStep(void)
Clutch BeginStep.
Definition: Partridge_All.cpp:282
Partridge_Chick2::DailyMortality
virtual bool DailyMortality()
Background mortality check.
Definition: Partridge_All.cpp:1179
Partridge_Base::SwitchCovey
void SwitchCovey(Partridge_Covey *a_covey)
Swap coveys.
Definition: Partridge_All.cpp:216
Partridge_Covey::ChickExtraMortality
void ChickExtraMortality()
Apply extra chick mortality.
Definition: Partridge_Covey.cpp:2671
Partridge_Covey::FlyTo
bool FlyTo(int a_distance)
Fly to
Definition: Partridge_Covey.cpp:1484
Partridge_Male::m_MyOldWife
Partridge_Female * m_MyOldWife
Old mate pointer.
Definition: Partridge_All.h:676
cfg_par_min_no_eggs
static CfgInt cfg_par_min_no_eggs("PAR_MIN_NO_EGGS", CFG_CUSTOM, 7)
Minimum clutch size.
Partridge_Female::OnSetMyClutch
void OnSetMyClutch(PartridgeCommunicationData *pc_data)
Message handler.
Definition: Partridge_All.cpp:2086
cfg_par_MaleFlyingDistance
static CfgInt cfg_par_MaleFlyingDistance("PAR_MALEFLYINGDISTANCE", CFG_CUSTOM, 2000)
The maximum flying distance for males.
CfgFloat::value
double value(void)
Definition: configurator.h:118
population_attributes::m_NoFemalesDec
int m_NoFemalesDec
Definition: Partridge_All.h:70
cfg_par_male_gives_up
CfgInt cfg_par_male_gives_up("PAR_MALE_GIVES_UP", CFG_CUSTOM, 170)
Latest date a male will mate search.
Partridge_Female::m_triggerlayingvar
int m_triggerlayingvar
Adds stochasticity to the light triggering of breeding.
Definition: Partridge_All.h:813
Partridge_Chick2::ChMaturing
virtual Partridge_State ChMaturing(void)
State maturing.
Definition: Partridge_All.cpp:1221
Partridge_Covey::SetChickAge
void SetChickAge(int age)
Set chick age.
Definition: Partridge_Covey.h:481
pars_FLaying
Definition: Partridge_All.h:282
hilling_up
Definition: treatment.h:79
Landscape::EventtypeToString
std::string EventtypeToString(int a_event)
Definition: Landscape.cpp:3918
Partridge_Base::SetFamily
void SetFamily(unsigned int family)
Set family ID.
Definition: Partridge_All.h:487
TAnimal::CopyMyself
virtual void CopyMyself()
Definition: populationmanager.h:224
Partridge_Base::m_OurPopulationManager
Partridge_Population_Manager * m_OurPopulationManager
Pointer to the population manager.
Definition: Partridge_All.h:430
Partridge_Covey::NestFindLocation
bool NestFindLocation(void)
Try to locate a suitable nesting location.
Definition: Partridge_Covey.cpp:1107
Partridge_Male::m_MyMate
Partridge_Female * m_MyMate
Current mate pointer.
Definition: Partridge_All.h:678
population_attributes::m_NoPairsApril
int m_NoPairsApril
Definition: Partridge_All.h:64
pars_ClDying
Definition: Partridge_All.h:273
Partridge_Base::~Partridge_Base
virtual ~Partridge_Base(void)
Destructor.
Definition: Partridge_All.cpp:192
CFG_CUSTOM
Definition: configurator.h:60
Partridge_Covey::IsMember
bool IsMember(Partridge_Base *a_possible_member)
Definition: Partridge_Covey.cpp:1709
syninsecticide_treat
Definition: treatment.h:99
fa_manure
Definition: treatment.h:66
Partridge_Covey::FixHabitat
void FixHabitat(void)
Accept this breeding location.
Definition: Partridge_Covey.cpp:1074
fp_npks
Definition: treatment.h:48
cfg_par_adult_mortality_alone
static CfgFloat cfg_par_adult_mortality_alone("PAR_ADULT_MORTALITY_ALONE", CFG_CUSTOM, 1.4)
Adults - extra mortality scaler if alone.
Partridge_Chick2::EndStep
virtual void EndStep(void)
Chick2 EndSte[.
Definition: Partridge_All.cpp:1302
row_cultivation
Definition: treatment.h:76
Landscape::SupplyRain
double SupplyRain(void)
Definition: landscape.h:1365
Partridge_Clutch::m_clutch_size
int m_clutch_size
No. of eggs.
Definition: Partridge_All.h:524
Partridge_Female::m_HaveTerritory
bool m_HaveTerritory
Flag for having found a suitable breeding area.
Definition: Partridge_All.h:801
Partridge_Male::MDying
void MDying(void)
State male dying.
Definition: Partridge_All.cpp:2630
Partridge_Female::FIncubating
Partridge_State FIncubating(void)
Female incubating state.
Definition: Partridge_All.cpp:1856
pars_Initiation
Definition: Partridge_All.h:267
pars_MPairing
Definition: Partridge_All.h:279
Partridge_Chick
Partridge chick class.
Definition: Partridge_All.h:581
k_factors::reset
void reset()
Definition: Partridge_All.cpp:2978
cfg_par_last_brood_date
CfgInt cfg_par_last_brood_date("PAR_LAST_BROOD_DATE", CFG_CUSTOM, 180)
Latest date for a reproduction attempt.
cfg_par_chick2_mortality
static CfgFloat cfg_par_chick2_mortality("PAR_CHICK_TWO_MORTALITY", CFG_CUSTOM, 1.0)
Chick2 - scaler applied to adult mortalities.
Partridge_Male::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
Management event handler.
Definition: Partridge_All.cpp:2309
Partridge_Female::SetOldMate
void SetOldMate(Partridge_Male *pm)
Set old mate pointer.
Definition: Partridge_All.h:898
Partridge_Covey::X
unsigned int X(void)
Definition: Partridge_Covey.h:708
population_attributes::m_NoOldMales
int m_NoOldMales
Definition: Partridge_All.h:58
CfgInt
Integer configurator entry class.
Definition: configurator.h:87
Partridge_Male::OnLookAfterKids
void OnLookAfterKids(void)
Message handler.
Definition: Partridge_All.cpp:2675
Partridge_Female::m_clutch_size
int m_clutch_size
Current clutch size.
Definition: Partridge_All.h:805
population_attributes::incNoDeadChicks
void incNoDeadChicks()
Definition: Partridge_All.h:168
Partridge_Female::FFlocking
Partridge_State FFlocking(void)
Female flocking state.
Definition: Partridge_All.cpp:1632
Partridge_Female::HaveTerritory
bool HaveTerritory(void)
Have we a breeding 'territory'?
Definition: Partridge_All.h:920
TALMaSSObject::GetCurrentStateNo
int GetCurrentStateNo()
Returns the current state number.
Definition: populationmanager.h:121
Partridge_struct::by
int by
Definition: Partridge_All.h:347
spring_plough
Definition: treatment.h:44
fa_greenmanure
Definition: treatment.h:67
pars_MFlocking
Definition: Partridge_All.h:279
Partridge_Base::m_born_y
int m_born_y
y-coord of birth
Definition: Partridge_All.h:414
Partridge_Male::MGuardingMate
Partridge_State MGuardingMate(void)
State male guarding mate.
Definition: Partridge_All.cpp:2605
TAnimal::CheckManagement
void CheckManagement(void)
Definition: PopulationManager.cpp:1404
Partridge_Female::FBuildingUpResources
Partridge_State FBuildingUpResources(void)
Female building up resources state.
Definition: Partridge_All.cpp:1644
Partridge_Chick2::BeginStep
virtual void BeginStep(void)
Chick2 BeginStep.
Definition: Partridge_All.cpp:1251
PartridgeCommunicationData
Data structure of a message.
Definition: Partridge_Communication.h:78
Partridge_struct::bx
int bx
Definition: Partridge_All.h:346
CfgFloat
Double configurator entry class.
Definition: configurator.h:106
g_partridge_id
static long g_partridge_id
Definition: Partridge_All.cpp:151
Partridge_Population_Manager::CreateCloneObjects
void CreateCloneObjects(int ob_type, AdultPartridge_struct *as)
Definition: Partridge_Population_Manager.cpp:535
Partridge_Covey::AddMember
void AddMember(Partridge_Base *a_new_member)
Definition: Partridge_Covey.cpp:1644
Partridge_Chick::ChDeveloping
virtual Partridge_State ChDeveloping(void)
Development.
Definition: Partridge_All.cpp:922
Partridge_Female::FDying
void FDying(void)
Definition: Partridge_All.cpp:1984
spring_roll
Definition: treatment.h:46
population_attributes::incNoClutchesPredated
void incNoClutchesPredated()
Definition: Partridge_All.h:100
cut_weeds
Definition: treatment.h:94
CfgInt::value
int value(void)
Definition: configurator.h:98
Partridge_Female::m_clutch_number
int m_clutch_number
Current clutch attempt.
Definition: Partridge_All.h:807
Partridge_Male::OnFemaleGivingUp
void OnFemaleGivingUp()
Message handler.
Definition: Partridge_All.cpp:2783
k_factors::Output_kfactors
void Output_kfactors()
Definition: Partridge_All.cpp:2893
PartridgeCommunicationData::m_clutch
Partridge_Clutch * m_clutch
Definition: Partridge_Communication.h:80
population_attributes::m_NoShotFemales
int m_NoShotFemales
Definition: Partridge_All.h:57
pcomm_AllInfertile
Definition: Partridge_Communication.h:60
Partridge_Female::Step
virtual void Step(void)
Female Step.
Definition: Partridge_All.cpp:1378
pars_FFlocking
Definition: Partridge_All.h:282
fp_manganesesulphate
Definition: treatment.h:53
Partridge_Covey::SupplyFoodToday
double SupplyFoodToday(void)
Return the food obtained today.
Definition: Partridge_Covey.cpp:905
herbicide_treat
Definition: treatment.h:71
Partridge_Female::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
Management event handler.
Definition: Partridge_All.cpp:1491
Partridge_Base::m_covey
Partridge_Covey * m_covey
Pointer to the covey.
Definition: Partridge_All.h:420
pob_Male
Definition: Partridge_All.h:297
cfg_par_adult_mortalitySpring
static CfgFloat cfg_par_adult_mortalitySpring("PAR_ADULT_MORTALITYSPRING", CFG_CUSTOM, 0.0096)
Adults - daily probability of non-explicitly modelled mortality in Spring.
population_attributes::incNoDeadFemales
void incNoDeadFemales()
Definition: Partridge_All.h:172
growth_regulator
Definition: treatment.h:72
pars_MGuardingMate
Definition: Partridge_All.h:279
cut_to_silage
Definition: treatment.h:86
product_treat
Definition: treatment.h:101
k_factors::CreateInfoDatabaseFile
void CreateInfoDatabaseFile()
Definition: Partridge_All.cpp:3145
Partridge_Population_Manager::GetNestingCoverDensity
double GetNestingCoverDensity(int x, int y)
Definition: Partridge_Population_Manager.cpp:754
FarmToDo
FarmToDo
Definition: treatment.h:31
Partridge_Chick2::OnFarmEvent
virtual bool OnFarmEvent(FarmToDo event)
Management event handler.
Definition: Partridge_All.cpp:1044
population_attributes::incNoHensPredated
void incNoHensPredated()
Definition: Partridge_All.h:104
TALMaSSObject::m_CurrentStateNo
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: populationmanager.h:116
Partridge_Male::StartBreedingBehaviour
void StartBreedingBehaviour(void)
Message handler.
Definition: Partridge_All.cpp:2719
population_attributes::m_NoDeadFemales
int m_NoDeadFemales
Definition: Partridge_All.h:74
Partridge_Female::OnChicksDead
void OnChicksDead()
Message handler.
Definition: Partridge_All.cpp:2118
population_attributes::m_NoClutches
int m_NoClutches
Definition: Partridge_All.h:50
Partridge_Chick2::Step
virtual void Step(void)
Chick2Step.
Definition: Partridge_All.cpp:1273
pigs_out
Definition: treatment.h:84
pob_Clutch
Definition: Partridge_All.h:297
Partridge_Male::OnMovingHome
void OnMovingHome()
Message handler.
Definition: Partridge_All.cpp:2729
Clutch_struct::No
int No
Definition: Partridge_All.h:364
population_attributes::m_NoHensPredated
int m_NoHensPredated
Definition: Partridge_All.h:63
Partridge_Male::CheckMatePointers
virtual void CheckMatePointers()
A debug function.
Definition: Partridge_All.cpp:2800
pob_Chick
Definition: Partridge_All.h:297
cut_to_hay
Definition: treatment.h:85
Partridge_Covey::Y
unsigned int Y(void)
Definition: Partridge_Covey.h:713
spring_sow
Definition: treatment.h:47
pars_FDying
Definition: Partridge_All.h:283
Landscape::Warn
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
population_attributes::m_NoDeadClutches
int m_NoDeadClutches
Definition: Partridge_All.h:71
g_rand_uni
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
Partridge_Male::EndStep
virtual void EndStep(void)
Male EndStep.
Definition: Partridge_All.cpp:2285
population_attributes::incNoStarvedChicks
void incNoStarvedChicks()
Definition: Partridge_All.h:188
Partridge_Female::RemoveOldMate
void RemoveOldMate(bool a_knockon)
Forget old mate.
Definition: Partridge_All.h:903
sleep_all_day
Definition: treatment.h:33
Partridge_Population_Manager::SupplyShouldFlock
bool SupplyShouldFlock()
Definition: Partridge_Population_Manager.h:286
Partridge_Male::OnChicksDead
void OnChicksDead()
Message handler.
Definition: Partridge_All.cpp:2689
population_attributes::incNoDeadMales
void incNoDeadMales()
Definition: Partridge_All.h:176
g_manager
Partridge_Population_Manager * g_manager
Clutch mortality on soil cultivation.
Definition: Partridge_All.cpp:150
TAnimal::m_Location_x
int m_Location_x
Definition: populationmanager.h:225
pars_FMakingNest
Definition: Partridge_All.h:282
autumn_or_spring_plough
Definition: treatment.h:91
Landscape::SupplyDaylength
int SupplyDaylength(void)
Definition: landscape.h:1530
Partridge_Covey::OnChickMature
void OnChickMature()
Remove a matured chick.
Definition: Partridge_Covey.cpp:2460
Partridge_Male::OnChicksMatured
void OnChicksMatured()
Message handler.
Definition: Partridge_All.cpp:2699
pob_Female
Definition: Partridge_All.h:297
TAnimal::WhatState
virtual int WhatState()
Definition: populationmanager.h:263
pars_MDying
Definition: Partridge_All.h:279
cfg_par_female_incubation_mortality_slope
static CfgFloat cfg_par_female_incubation_mortality_slope("PAR_FEMALE_INCUBATION_MORTALITY_SLOPE", CFG_CUSTOM, -0.00122)
Increasing hen predation with density (slope)
cfg_par_mature_threshold
CfgInt cfg_par_mature_threshold("PAR_MATURE_THRESHOLD", CFG_CUSTOM, 84)
Age at maturing in days.
Partridge_Clutch::m_mother
Partridge_Female * m_mother
Pointer to mother.
Definition: Partridge_All.h:526
population_attributes::reset
void reset()
Definition: Partridge_All.cpp:2941
Partridge_Chick::ChMaturing
virtual Partridge_State ChMaturing(void)
Maturation.
Definition: Partridge_All.cpp:961
Partridge_Male::MPairing
Partridge_State MPairing(void)
State male pairing.
Definition: Partridge_All.cpp:2576
fa_slurry
Definition: treatment.h:63
Landscape::SupplyGlobalDate
long SupplyGlobalDate(void)
Definition: landscape.h:1621
swathing
Definition: treatment.h:81
cfg_par_incubation_period
static CfgInt cfg_par_incubation_period("PAR_INCUBATION_PERIOD", CFG_CUSTOM, 24)
Lenght of incubation period.
population_attributes::m_NoClutchesHatched
int m_NoClutchesHatched
Definition: Partridge_All.h:78
cfg_par_female_movement_max
static CfgInt cfg_par_female_movement_max("PAR_FEMALE_MOVEMENT_MAX", CFG_CUSTOM, 100)
Female max daily movement.
Partridge_Covey::NestLeave
void NestLeave(void)
Leave the nest
Definition: Partridge_Covey.h:516
population_attributes::m_NoMalesAug
int m_NoMalesAug
Definition: Partridge_All.h:82
cfg_par_ch_cut
static CfgFloat cfg_par_ch_cut("PAR_CH_CUT_MORT", CFG_CUSTOM, 0.05)
Chick % mortality on cutting.
k_factors::~k_factors
~k_factors()
Definition: Partridge_All.cpp:2871
Partridge_Female::FStartingNewBrood
Partridge_State FStartingNewBrood(bool a_waslaying)
Female starting new brood state.
Definition: Partridge_All.cpp:1802