ALMaSS Partridge ODdox
1.1
The partridge model description following ODdox protocol
|
Go to the documentation of this file.
46 #include "../Landscape/ls.h"
47 #include "../BatchALMaSS/PopulationManager.h"
48 #include "../Partridge/Partridge_Communication.h"
49 #include "../Partridge/Partridge_All.h"
50 #include "../Partridge/Partridge_Population_Manager.h"
51 #include "../Partridge/Partridge_Covey.h"
52 #include "../BatchALMaSS/BoostRandomGenerators.h"
233 #define TRIG_TABLE_LENGTH 8000
234 #define TRIG_TABLE_LENGTH_INV 0.00025
248 if ( random( 100 ) < 50 )
262 bool l_found =
false;
266 int l_goto_sub =
NormDec( l_goto - 1, 8 );
267 int l_goto_add =
NormInc( l_goto + 1, 8 );
285 l_goto_sub =
NormDec( l_goto_sub - 1, 8 );
286 l_goto_add =
NormInc( l_goto_add + 1, 8 );
299 l_goto_sub =
NormDec( l_goto_sub - 1, 8 );
300 l_goto_add =
NormInc( l_goto_add + 1, 8 );
337 printf(
"l_rnd : %d\n", l_rnd );
375 if ( random( 100 ) < 50 ) {
406 if ( -l_dx > (
m_width >> 1 ) ) {
410 if ( l_dx > (
m_width >> 1 ) ) {
426 printf(
"dX, dY : %d %d\n", l_dx, l_dy );
431 int l_dist_sq = l_dx * l_dx + l_dy * l_dy;
437 if ( -l_dy > l_dx ) {
487 if ( l_dy > -l_dx ) {
540 for (
int i = 0; i < MOVE_QUAL_HIST_SIZE - 1; i++ ) {
558 for (
int i = 0; i < MOVE_QUAL_HIST_SIZE; i++ ) {
600 if ( l_x - a_step_size >= 0 && l_x + a_step_size < m_width && l_y - a_step_size >= 0 && l_y + a_step_size <
m_height ) {
618 printf(
"Selected: %d\n", l_dir );
629 printf(
"Coords : %d %d\n\n", l_x, l_y );
669 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::MoveDistance(): ",
"Asked to move while on nest." );
702 if ( l_x - a_step_size >= 0 && l_x + a_step_size < m_width && l_y - a_step_size >= 0 && l_y + a_step_size <
m_height ) {
720 printf(
"Selected: %d\n", l_dir );
731 printf(
"Coords : %d %d\n\n", l_x, l_y );
812 int l_diag_length = ( int )( (
double )a_step_size * 0.71 );
813 double l_length = ( double )a_step_size;
817 * a_y -= a_step_size;
821 * a_y -= l_diag_length;
822 * a_x += l_diag_length;
825 * a_x += a_step_size;
828 * a_y += l_diag_length;
829 * a_x += l_diag_length;
832 * a_y += a_step_size;
835 * a_y += l_diag_length;
836 * a_x -= l_diag_length;
839 * a_x -= a_step_size;
842 * a_y -= l_diag_length;
843 * a_x -= l_diag_length;
870 while ( a_coord < 0 ) {
873 while ( a_coord >= a_size ) {
887 return a_coord + a_size;
899 if ( a_coord >= a_size )
900 return a_coord - a_size;
907 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::SupplyFoodToday: Move not done yet!",
"" );
916 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::SupplyDistanceMoved: Move not done yet!",
"" );
927 int l_poly_cache = -1;
928 double l_poly_value = 0.0;
931 for (
int y = a_min_y_incl; y < a_max_y_excl; y++ ) {
932 for (
int x = a_min_x_incl; x < a_max_x_excl; x++ ) {
936 if ( l_poly != l_poly_cache ) {
941 l_poly_cache = l_poly;
943 l_qual += l_poly_value;
953 int l_poly_cache = -1;
954 double l_poly_value = 0.0;
963 for (
int iy = 0; iy < l_fy->
GetLimit(); iy++ ) {
965 for (
int ix = 0; ix < l_fx->
GetLimit(); ix++ ) {
971 if ( l_poly != l_poly_cache ) {
976 l_poly_cache = l_poly;
978 l_qual += l_poly_value;
998 if ( a_rethink_size ) {
1002 }
else if ( l_whh < 50 ) {
1005 * a_size_used = l_whh;
1007 l_whh = * a_size_used;
1010 int l_min_x_incl = a_center_x - l_whh;
1011 int l_max_x_excl = a_center_x + l_whh;
1012 int l_min_y_incl = a_center_y - l_whh;
1013 int l_max_y_excl = a_center_y + l_whh;
1015 if ( l_min_x_incl < 0 || l_max_x_excl >
m_width || l_min_y_incl < 0 || l_max_y_excl >
m_height ) {
1030 a_center_x = a_center_x / 10;
1031 a_center_y = a_center_y / 10;
1032 int l_min_x_incl = a_center_x - 5;
1033 int l_max_x_excl = a_center_x + 5;
1034 int l_min_y_incl = a_center_y - 5;
1035 int l_max_y_excl = a_center_y + 5;
1038 if ((l_min_x_incl<0) || (l_min_y_incl<0) || (l_max_x_excl >= (
m_width/10)) || (l_max_y_excl >= (
m_height /10)) )
return 0;
1039 for (
int i = l_min_x_incl; i < l_min_x_incl + 5; i++ )
1041 for (
int j = l_min_y_incl; j < l_min_y_incl + 5; j++ )
1121 if ( l_min_x_incl < 0 || l_max_x_excl >
m_width || l_min_y_incl < 0 || l_max_y_excl >
m_height ) {
1122 return NestFindSlow( l_min_x_incl, l_max_x_excl, l_min_y_incl, l_max_y_excl );
1125 return NestFindFast( l_min_x_incl, l_max_x_excl, l_min_y_incl, l_max_y_excl );
1140 if ( l_min_x < 0 || l_max_x >=
m_width || l_min_y < 0 || l_max_y >=
m_height ) {
1153 for (
int i = 0; i < a_length; i++ ) {
1171 for (
int i = 0; i < a_length; i++ ) {
1172 int x_inc = a_min_x + i;
1173 int y_inc = a_min_y + i;
1189 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
1196 int dx = l_covey->
NestGetX() - a_x;
1197 int dy = l_covey->
NestGetX() - a_y;
1199 if ( dx * dx + dy * dy < a_min_dist_sq ) {
1208 int l_poly_cache = -1;
1210 for (
int loops = 0; loops < 10; loops++ ) {
1212 for (
int x = a_min_x_incl; x < a_max_x_excl; x++ ) {
1213 for (
int y = a_min_y_incl; y < a_max_y_excl; y++ ) {
1215 if ( l_poly == l_poly_cache )
1218 l_poly_cache = l_poly;
1237 int l_poly_cache = -1;
1245 for (
int loop = 0; loop < 10; loop++ ) {
1246 for (
int iy = loop; iy < l_fy->
GetLimit(); iy++ ) {
1248 for (
int ix = loop; ix < l_fx->
GetLimit(); ix++ ) {
1252 if ( l_poly != l_poly_cache ) {
1253 l_poly_cache = l_poly;
1284 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
1304 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
1324 double wf = ( double )(
m_width >> 1 );
1325 double hf = ( double )(
m_height >> 1 );
1338 if ( dx < MIN_MATH_DIST_SQ ) {
1339 dx = MIN_MATH_DIST_SQ + ( double )( random( 100 ) ) / 100.0;
1341 if ( dy < MIN_MATH_DIST_SQ ) {
1342 dy = MIN_MATH_DIST_SQ + ( double )( random( 100 ) ) / 100.0;
1345 return max( dx * dx + dy * dy, MIN_MATH_DIST_SQ );
1351 double l_dist = ( double )a_distance;
1371 bool l_found =
false;
1374 int l_poly_cache = -1;
1375 int l_dx_cache = -20000;
1376 int l_dy_cache = -20000;
1382 int index = ( int )floor( l_tss );
1385 int dx = ( int )floor( l_dist *
g_trig_cos[ index ] + 0.5 );
1386 int dy = ( int )floor( l_dist *
g_trig_sin[ index ] + 0.5 );
1388 if ( dx == l_dx_cache && dy == l_dy_cache )
1396 if ( l_poly != l_poly_cache ) {
1397 l_poly_cache = l_poly;
1404 }
else if ( l_geo == 0 && l_new_x == -1 ) {
1423 double l_dist = ( double )a_distance;
1436 bool l_found =
false;
1439 int l_poly_cache = -1;
1440 int l_dx_cache = -20000;
1441 int l_dy_cache = -20000;
1447 int index = ( int )floor( l_tss );
1450 int dx = ( int )floor( l_dist *
g_trig_cos[ index ] + 0.5 );
1451 int dy = ( int )floor( l_dist *
g_trig_sin[ index ] + 0.5 );
1453 if ( dx == l_dx_cache && dy == l_dy_cache )
1461 if ( l_poly != l_poly_cache ) {
1462 l_poly_cache = l_poly;
1468 }
else if ( l_geo == 0 && l_new_x == -1 ) {
1487 if ( a_distance <= 0 )
1490 bool l_did_move =
false;
1521 if ( a_female->GetMate() ) {
1527 l_female = dynamic_cast < Partridge_Female * > (
m_members[ i ] );
1528 if ( !l_female->
GetMate() )
return l_female;
1537 if ( a_male->GetMate() ) {
1543 l_male = dynamic_cast < Partridge_Male * > (
m_members[ i ] );
1544 if ( !l_male->
GetMate() )
return l_male;
1562 int l_dsq = a_max_distance * a_max_distance;
1569 while ( l_candidate ) {
1573 if ( ( l_dx * l_dx + l_dy * l_dy ) < l_dsq ) {
1574 return dynamic_cast < Partridge_Female * > ( l_candidate );
1646 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::AddMember(): ""Attempting to add a member to non-existent flock!",
"" );
1650 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::AddMember(): ""Attempting to add a member already belonging to the flock!",
"" );
1665 if ( !
IsMember( a_former_member ) ) {
1667 "Attempting to remove a member not belonging to the flock!",
"" );
1671 if ( a_former_member ==
m_theDad ) {
1673 }
else if ( a_former_member ==
m_theMum ) {
1713 if ( a_possible_member ==
m_members[ i ] ) {
1729 return 1.0 / max( a_distance, MIN_MATH_DIST_SQ );
1752 double l_x_sign = 1.0;
1753 double l_y_sign = 1.0;
1754 double wf = ( double )(
m_width >> 1 );
1755 double hf = ( double )(
m_height >> 1 );
1786 double dsum = sqrt( dx * dx + dy * dy );
1800 for (
unsigned int i = 0; i < sz; i++ ) {
1803 if (
m_id == p_pc->
ID() ) {
1820 for (
unsigned int k = 0; k < nu; k++ ) {
1841 if ( (UncleNumber + a_noOfUncles) > 4 )
return false;
1845 if ( (UncleNumber + a_noOfUncles) > 4 ) {
1848 }
else if ( (UncleNumber + a_noOfUncles) > 8 )
return false;
1863 double l_force_x = 0.0;
1864 double l_force_y = 0.0;
1865 double l_pressure_sum = 0.0;
1866 double wf = ( double )(
m_width >> 1 );
1867 double hf = ( double )(
m_height >> 1 );
1868 double l_x_sign = 1.0;
1869 double l_y_sign = 1.0;
1873 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
1918 if ( dx < MIN_MATH_DIST_SQ ) {
1919 dx = MIN_MATH_DIST_SQ;
1921 if ( dy < MIN_MATH_DIST_SQ ) {
1922 dy = MIN_MATH_DIST_SQ;
1924 double dist = max( dx * dx + dy * dy, MIN_MATH_DIST_SQ );
1927 l_pressure_sum +=
Pressure( sqrt( dist ) );
1928 l_force_x += l_x_sign * dx / dist;
1929 l_force_y += l_y_sign * dy / dist;
1933 double l_vector_force = sqrt( l_force_x * l_force_x + l_force_y * l_force_y );
1978 unsigned int a_center_x,
unsigned int a_center_y,
Landscape * a_map ) :
TAnimal( a_center_x, a_center_y, a_map ) {
2024 if ( a_first_member ) {
2031 for (
int i = 0; i < MOVE_QUAL_HIST_SIZE; i++ ) {
2105 for ( PointerInt i = 0; i < (unsigned)
g_covey_list.size(); i++ ) {
2122 for (
int i = 0; i < sz; i++ ) {
2123 double chs = ( double )
g_covey_list[ i ]->GetOurChicks();
2126 product += log10( chs );
2131 double power = 1.0 / NoBr;
2134 double result = pow( 10, product );
2146 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
2151 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
2157 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
2166 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
2182 int x1 = x - radius;
2183 int x2 = x + radius;
2184 int y1 = y - radius;
2185 int y2 = y + radius;
2192 for (
int i = 0; i < (int)
g_covey_list.size(); i++ ) {
2195 int dx = abs( x - tx );
2196 int dy = abs( y - ty );
2199 if ( ( tx < x2 ) && ( tx >= x1 ) && ( ty >= y1 ) && ( ty < y2 ) ) {
2208 for (
int i = 0; i < (int) (
g_covey_list.size()); i++ ) {
2211 if ( ( tx <= x2 ) && ( tx >= x1 ) && ( ty >= y1 ) && ( ty <= y2 ) ) {
2231 unsigned int l_id = a_covey->
ID();
2239 for (
unsigned int i = 0; i <
g_covey_list.size(); i++ ) {
2243 for (
unsigned int j = i + 1; j <
g_covey_list.size(); j++ ) {
2258 if ( a_step_size > 1 )
2259 m_limit = ( a_max_excl - a_min_incl ) / a_step_size;
2261 m_limit = a_max_excl - a_min_incl;
2263 if ( !
m_list ) assert(
false );
2267 for ( i = a_min_incl; i < a_norm_min_incl && index <
m_limit; i += a_step_size ) {
2268 m_list[ index++ ] = i + a_norm_max_excl;
2274 for ( ; i < a_norm_max_excl && index <
m_limit; i += a_step_size ) {
2278 for ( ; i < a_max_excl && index <
m_limit; i += a_step_size ) {
2279 m_list[ index++ ] = i - a_norm_max_excl;
2339 if ( pf->
GetMate() == NULL ) {
2340 if ( pf->
GetFamily() != a_family_counter )
2389 MP = dynamic_cast < Partridge_Male * > (
m_members[ i ] );
2393 FP = dynamic_cast < Partridge_Female * > (
m_members[ i ] );
2407 if (
m_members[ i ]->GetCovey() !=
this ) {
2408 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::SanityCheck(): ""Non-mutual pointers",
"" );
2422 if ( count != no_chicks ) {
2423 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::SanityCheck2(): ""wrong number of chicks",
"" );
2432 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::SanityCheck3(): ""m_move_list illegal",
"" );
2443 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::SanityCheck(): ""Clutch present when it should not be!",
"" );
2542 if (
m_members[ i ]->GetUncleStatus() ) {
2555 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::SetUncle(): ""Called but no uncles found",
"" );
2563 if (
m_members[ i ]->GetUncleStatus() ) {
2578 for (
int decimate = 0; decimate < tokill; decimate++ ) {
2581 pc = dynamic_cast < Partridge_Chick * > (
m_members[ i ] );
2599 if ( random( 100 ) < percent )
2600 dynamic_cast < Partridge_Chick * > (
m_members[ i ] )->OnYouAreDead();
2675 dynamic_cast < Partridge_Chick * > (
m_members[ i ] )->OnYouAreDead();
2702 #ifdef MOVE_EVAL_KLUDGE
2719 if ( a_edges > 2 ) result += 3;
else if ( a_edges > 0 ) {
2721 if ( result == 3 ) result += 3;
else result += 2;
2725 result = result >> 1;
2738 l_hrs = l_hrs * l_hrs;
2739 if ( a_dist_sq < l_hrs || ( random( 100 ) < 50 ) )
2753 l_hrs = l_hrs * l_hrs;
2754 if ( a_dist_sq < l_hrs )
2757 if ( a_dist_sq < l_hrs * 1.6 && random( 100 ) < 10 )
2866 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::TerrEvalPoly(): Unknown tole type",
"" );
2938 if ( score > random( 1000 ) )
return true;
3018 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::NestBadArea(): Unknown tole type",
"" );
3192 if (l_height_bin < 0.0 )
return l_magic;
3196 if (l_density_bin > 4.0 ) l_density_bin = 4.0;
3197 if (l_height_bin > 4.0 ) l_height_bin = 4.0;
3198 double l_intermediate = 1.0 -(( l_density_bin + l_height_bin - 2.0 ) * 0.25);
3199 if (l_intermediate <0.0)
return 0.0;
3200 if (l_intermediate >= 1.0)
return l_magic;
3201 return l_magic * l_intermediate;
3292 g_msg->
Warn(
WARN_BUG,
"Partridge_Covey::MoveCanMove(): Unknown tole type",
"" );
3418 double l_quality = 0.0;
3419 double l_qual_cache = 0.0;
3420 int l_fantastic = 0;
3421 int l_poly_cache = -1;
3422 int l_geo_cache = 0;
3434 if ( l_poly != l_poly_cache ) {
3438 if ( l_geo_cache == -1 ) {
3443 l_poly_cache = l_poly;
3448 l_fantastic += l_geo_cache;
3450 l_quality += l_qual_cache;
3467 for (
int y = a_y - 1, x = a_x + 1; y >= a_y - l_diag_length; y--, x++ ) {
3469 if ( l_poly != l_poly_cache ) {
3471 if ( l_geo_cache == -1 ) {
3475 l_poly_cache = l_poly;
3478 l_fantastic += l_geo_cache;
3479 l_quality += l_qual_cache;
3497 if ( l_poly != l_poly_cache ) {
3499 if ( l_geo_cache == -1 ) {
3503 l_poly_cache = l_poly;
3506 l_fantastic += l_geo_cache;
3507 l_quality += l_qual_cache;
3523 for (
int x = a_x + 1, y = a_y + 1; x <= a_x + l_diag_length; x++, y++ ) {
3525 if ( l_poly != l_poly_cache ) {
3527 if ( l_geo_cache == -1 ) {
3531 l_poly_cache = l_poly;
3534 l_fantastic += l_geo_cache;
3535 l_quality += l_qual_cache;
3553 if ( l_poly != l_poly_cache ) {
3555 if ( l_geo_cache == -1 ) {
3559 l_poly_cache = l_poly;
3562 l_fantastic += l_geo_cache;
3563 l_quality += l_qual_cache;
3579 for (
int x = a_x - 1, y = a_y + 1; x >= a_x - l_diag_length; x--, y++ ) {
3581 if ( l_poly != l_poly_cache ) {
3583 if ( l_geo_cache == -1 ) {
3587 l_poly_cache = l_poly;
3590 l_fantastic += l_geo_cache;
3591 l_quality += l_qual_cache;
3609 if ( l_poly != l_poly_cache ) {
3611 if ( l_geo_cache == -1 ) {
3615 l_poly_cache = l_poly;
3618 l_fantastic += l_geo_cache;
3619 l_quality += l_qual_cache;
3635 for (
int y = a_y - 1, x = a_x - 1; y >= a_y - l_diag_length; y--, x-- ) {
3637 if ( l_poly != l_poly_cache ) {
3639 if ( l_geo_cache == -1 ) {
3643 l_poly_cache = l_poly;
3646 l_fantastic += l_geo_cache;
3647 l_quality += l_qual_cache;
3670 int l_geo_cache = 0;
3671 double l_quality = 0.0;
3672 double l_qual_cache = 0.0;
3673 int l_fantastic = 0;
3674 int l_poly_cache = -1;
3682 if ( l_poly != l_poly_cache ) {
3684 if ( l_geo_cache == -1 ) {
3688 l_poly_cache = l_poly;
3691 l_fantastic += l_geo_cache;
3692 l_quality += l_qual_cache;
3708 for (
int y = a_y - 1, x = a_x + 1; y >= a_y - l_diag_length; y--, x++ ) {
3710 if ( l_poly != l_poly_cache ) {
3712 if ( l_geo_cache == -1 ) {
3716 l_poly_cache = l_poly;
3719 l_fantastic += l_geo_cache;
3720 l_quality += l_qual_cache;
3738 if ( l_poly != l_poly_cache ) {
3740 if ( l_geo_cache == -1 ) {
3744 l_poly_cache = l_poly;
3747 l_fantastic += l_geo_cache;
3748 l_quality += l_qual_cache;
3764 for (
int x = a_x + 1, y = a_y + 1; x <= a_x + l_diag_length; x++, y++ ) {
3766 if ( l_poly != l_poly_cache ) {
3768 if ( l_geo_cache == -1 ) {
3772 l_poly_cache = l_poly;
3775 l_fantastic += l_geo_cache;
3776 l_quality += l_qual_cache;
3794 if ( l_poly != l_poly_cache ) {
3796 if ( l_geo_cache == -1 ) {
3800 l_poly_cache = l_poly;
3803 l_fantastic += l_geo_cache;
3804 l_quality += l_qual_cache;
3820 for (
int x = a_x - 1, y = a_y + 1; x >= a_x - l_diag_length; x--, y++ ) {
3822 if ( l_poly != l_poly_cache ) {
3824 if ( l_geo_cache == -1 ) {
3828 l_poly_cache = l_poly;
3831 l_fantastic += l_geo_cache;
3832 l_quality += l_qual_cache;
3850 if ( l_poly != l_poly_cache ) {
3852 if ( l_geo_cache == -1 ) {
3856 l_poly_cache = l_poly;
3859 l_fantastic += l_geo_cache;
3860 l_quality += l_qual_cache;
3876 for (
int y = a_y - 1, x = a_x - 1; y >= a_y - l_diag_length; y--, x-- ) {
3878 if ( l_poly != l_poly_cache ) {
3880 if ( l_geo_cache == -1 ) {
3884 l_poly_cache = l_poly;
3887 l_fantastic += l_geo_cache;
3888 l_quality += l_qual_cache;
int m_covey_x
Covey x-coord.
CfgInt cfg_par_chick_extra_mort("PAR_CHICK_EXTRA_MORT", CFG_CUSTOM, 200)
Extra mortality applied to chicks on death of parents.
int m_world_width_div2
Half landscape width.
Partridge_State m_state
The current behavioural state.
int m_ourChicks
No chicks in covey.
void SetUncleStatus(bool a_Status)
Set uncle status.
bool m_essence_low
flag for excess density - unused
bool NestBadAreasScanFast(int a_min_x, int a_min_y, int a_length, int a_x, int a_y)
Nest location evaluation function.
void BeginStep(void)
Covey BeginStep.
double m_assess_qual
Habitat quality.
void OntheMumDead()
Behaviour when alpha female is killed.
int MoveSelectFuzzy(void)
Fuzzdy movement selection.
bool ManagerIsPermanant(void)
Unused
int RemoveMember(Partridge_Base *a_former_member)
Remove a member from the covey.
double Pressure(double a_distance)
Get the pressure force.
void OnAddChick(Partridge_Female *a_pf)
Add a chick.
void MoveTo(int a_x, int a_y)
unused
int * m_list
List of points
The partridge male class.
double Getpar_force_ignore_below()
Get the minimum interesting force.
The partridge female class.
double m_maxFoodNeedToday
Food needed today.
bool PassMessage(PartridgeCommunicationData *pc_data, TypeOfPartridge_Communication pc)
Pass a message.
void OnYouAreDead()
Message handler.
void MoveDirectionsAllowed(int a_x, int a_y)
Test possible movement directions.
int m_center_y
Covey centre.
Partridge_Male * GetMaleInCovey()
Find a male in the covey.
void OnDissolve(int date)
Dissolve message handler.
int NormInc(int a_coord, int a_size)
Wrap-around utility function.
Partridge_Base * GetMember(int a_member)
Returns pointer to a_member.
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
int NormDec(int a_coord, int a_size)
Wrap-around utility function.
int m_limit
How many points
int MoveCanMove(TTypesOfLandscapeElement a_ele)
Test if we can go there.
The population manager for partridge objects.
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
TAnimal * ObjectLoopFetch(void)
void ManagerUpdatePos(void)
int SupplyChickAge(void)
Returns the age of the chicks.
int NestGetX(void)
Return nest x-coord.
Iterator class for wrap around landscape
CfgInt cfg_par_movequal_histlimit("PAR_MOVEQUAL_HISTLIMIT", CFG_CUSTOM, 3)
The length of memory for backtracking.
int m_move_get_index
Internal variable.
Partridge_Base * GetAMember()
Returns a random member.
CoveyManager(unsigned int a_world_width, unsigned int a_world_height, Landscape *a_map)
Constructor.
double m_new_center_y_float
Covey centre as float.
CfgInt cfg_par_move_fuzzy_chance("PAR_MOVE_FUZZY_CHANCE", CFG_CUSTOM, 50)
Chance of imperfect movement decisions.
CfgInt cfg_IndividualEmigration
Emigration rate of alone individuals (of 10000)
Landscape * m_map
A pointer to the landscape.
void CoveyUpdateMemberPositions(int a_x, int a_y)
Update all covey members x,y coords.
int m_CoveyDissolveDate
Date for covey dissolve.
int m_width
Landscape width.
CfgInt cfg_par_mature_threshold
Age at maturing in days.
bool NestFindSlow(int a_min_x_incl, int a_max_x_excl, int a_min_y_incl, int a_max_y_excl)
Find nest location (wrap around)
CfgInt cfg_nest_fieldboundary("PAR_NEST_FIELDBOUNDARY", CFG_CUSTOM, 200)
Nesting quality for field boundaries.
CfgInt cfg_par_highqualthreshold("PAR_HIGHQUALTHRESHOLD", CFG_CUSTOM, 18)
An arbitrary value for determine movement quality.
bool NestFindFast(int a_min_x_incl, int a_max_x_excl, int a_min_y_incl, int a_max_y_excl)
Find nest location.
bool PressureLimitExceeded(double a_pressure)
Test for exceedence of pressure limit.
void SanityCheck3()
Debug method.
Landscape * m_OurLandscape
void ManagerDriftPos(void)
void OnChickDeath()
Remove a dead chick.
CfgInt cfg_nest_field("PAR_NEST_FIELD", CFG_CUSTOM, 1)
Nesting quality for fields.
void SetState(Partridge_State a_pars)
Set state.
double m_center_x_float
Covey centre as float.
PartridgeCommunicationData * m_comms_data
Message data.
int m_height
Landscape height.
double AssessHabitatQualityFaster()
Assess habitat quality (efficient)
int m_world_height
Landscape height.
static vector< Partridge_Covey * > g_covey_list
CfgInt cfg_par_parentdead_age2("PAR_PARENTDEAD_AGETWO", CFG_CUSTOM, 63)
Mortalty chance on parent death, older.
static int m_move_select_list[8]
Partridge_Covey * FindNeighbour()
Finds the closest other covey.
bool AllFlocking2()
Debug method.
int m_maxAllowedMove
Max move distance today.
CfgInt cfg_nest_permsetaside("PAR_NEST_PERMSETASIDE", CFG_CUSTOM, 100)
Nesting quality for setaside.
int m_world_width
Landscape width.
double GetQualIndexed(int a_x, int a_y)
void MoveDistance(int a_max_distance, int a_step_size, double a_food_density_needed)
Entry point for movement.
Base class for all partridge classes.
void ActOnParentDeath()
Determine the chick mortality on parent death.
int GetOurChicks()
Return the number of chicks.
Partridge_Female * m_theMum
Pointer to the alpha male.
int m_flyto_steps
costly intermediate variable
CfgInt cfg_nest_roadside("PAR_NEST_ROADSIDE", CFG_CUSTOM, 100)
Nesting quality for roadsize verges.
int Supply_m_Location_x()
double SupplyDistanceMoved(void)
Return the distance moved today.
Partridge_Female * GetMate(void)
Are we paired?
void DistanceUpdate(void)
Updates distance to nearest covey.
CfgInt cfg_nest_permpastlowyield("PAR_NEST_PERMPASTLOWYIELD", CFG_CUSTOM, 1)
Nesting quality for low yield pasture.
double MoveMagicVegToFood(int a_polygon)
Move optimising food intake.
Partridge_Female * FindMeAMateInCovey(int a_family_counter)
Is their a suitable female mate in the covey?
ForIterator(int a_min_incl, int a_max_excl, int a_step_size, int a_norm_min_incl, int a_norm_max_excl)
Constructor
void MoveVegConstInit(void)
Part of movement evaluation.
int MoveSelect(void)
Part of movement evaluation.
void KillChicks(int percent)
Kill a proportion of the chicks.
int SupplyVegDensity(int a_polyref)
Partridge_Male * GetMate(void)
Supply mate pointer.
int CoveyDensity(int x, int y, int radius)
Unused.
void MoveOptimalDirectionSlow(int a_x, int a_y)
Choose best foraging direction.
bool NestGoodSpot(int a_x, int a_y)
Evaluate x,y as a nest location.
CfgInt cfg_par_firstmerge("PAR_FIRSTMERGE", CFG_CUSTOM, 150)
The Earliest merging date.
#define TRIG_TABLE_LENGTH
class MapErrorMsg * g_msg
bool m_assess_done
Have assessed habitat quality?
CfgFloat cfg_par_bio_hindrance_inv("PAR_BIO_HINDRANCE", CFG_CUSTOM, 0.00667)
bool DelCovey(Partridge_Covey *a_covey)
Remove a covey.
Partridge_Female * FindMateInArea(int a_max_distance)
Find mate in area.
CfgFloat cfg_par_force_abs_limit("PAR_COVEY_FORCE_ABS_LIMIT", CFG_CUSTOM, 100.0)
void MoveOptimalDirectionFast(int a_x, int a_y)
Choose best foraging direction (wrap around)
Partridge_Male * m_theDad
Pointer to the alpha female.
CfgInt cfg_par_lastmerge("PAR_LASTMERGE", CFG_CUSTOM, 59)
The latest merging date.
CoverTempMap * m_territoryqualmap
Pointer to territory quality map.
bool NestNearBadAreas(int a_x, int a__y)
Test for proximity to unacceptable areas.
The landscape class containing all environmental and topographical data.
bool AllFlocking()
Debug method.
Partridge_Population_Manager * m_manager
Covey's population manager.
void ManagerRethinkPos(void)
bool TooClose()
Test for another covey too close.
void Tick(void)
Do the covey management for the time-step.
long GetID(void)
Supply ID.
double m_par_force_ignore_below
Minimum interesting force.
bool NestBadArea(int a_x, int a__y)
Nest location evaluation function.
Partridge_Female * m_female
static bool m_move_veg_const_init_done
bool NestNearNests(int a_x, int a_y, int a_min_dist_sq)
Nest location evaluation function.
double m_terr_qual
Homerange evaluation score
int SupplySimAreaHeight(void)
double m_move_step_size_inv
Internal variable.
unsigned int GetCoveySize()
Return the covey size.
int SupplySimAreaWidth(void)
int m_neighbourlist_size
Number of coveys close to this covey.
CfgBool cfg_par_covey_drift_enable("PAR_COVEY_DRIFT_ENABLE", CFG_CUSTOM, true)
void Setpar_force_ignore_below(double ff)
Set the minimum interesting force.
~ForIterator(void)
Destructor
bool MoveTryExcludeHarder(int a_dist_sq)
Uses the peg force to exclude possible movement directions.
~CoveyManager(void)
Destructor.
Bool configurator entry class.
static int m_move_select_size
void DistanceUpdate2(void)
Updates distance to fixed nearest covey.
double HabitatEvaluateSlow(int a_min_x_incl, int a_max_x_excl, int a_min_y_incl, int a_max_y_excl)
double SupplyHabitatQuality()
Return habitat quality at our location.
The base class for all ALMaSS animal classes.
The collective for a family of partridges
double m_nearest_covey_dist
Closest covey distance
void Step(void)
Covey Step.
Partridge_Male * GetOldMate(void)
Supply old mate pointer.
bool SupplyVegPatchy(int a_polyref)
unsigned int m_members_size
Size of covey
double m_move_veg_const[]
Partridge_Female * FindMeAWife(Partridge_Male *a_male)
Find mate in covey.
int MoveWeighDirection(int a_x, int a_y)
Weighted foraging walk.
class CoveyManager * g_covey_manager
Partridge_Covey * m_covey
void SetFixed(bool a_is_fixed)
Prevent/enable peg drift.
int m_center_x
Covey centre.
double m_flyto_ts
costly intermediate variable
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
int m_move_qual_hist[4][MOVE_QUAL_HIST_SIZE]
Internal variable.
CfgBool cfg_par_force_enable("PAR_COVEY_FORCE_ENABLE", CFG_CUSTOM, true)
Enable the calculation of the repulsive inter-covey 'force'.
CfgFloat cfg_terr_qual_good("PAR_TERR_QUAL_GOOD", CFG_CUSTOM, 4.0)
Nesting quality for OK areas.
int SupplyDayInYear(void)
Partridge_Communication m_messagecentre
Message class pointer.
int GetFamily(void)
Supply family ID.
CfgInt cfg_nest_naturalgrass("PAR_NEST_NATURALGRASS", CFG_CUSTOM, 100)
Nesting quality for natural grass.
bool NestBadAreasScanSlow(int a_min_x, int a_min_y, int a_length, int a_x, int a_y)
Nest location evaluation function.
int m_assess_size
Current homerange assessment radius.
bool SupplyHasTramlines(int a_x, int a_y)
CfgFloat cfg_par_force_ignore_below("PAR_COVEY_FORCE_IGNORE_BELOW", CFG_CUSTOM, 0.0)
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
unsigned int m_id
Unique ID no-
void CoveyIndividualEmigrate()
Test for individuals from covey emigrating.
CfgInt cfg_par_parentdead_age1("PAR_PARENTDEAD_AGEONE", CFG_CUSTOM, 35)
Mortalty chance on parent death, young.
Partridge_Object GetObjectType(void)
Return object type.
void SetCoveyDissolveDate(int date)
Set the dissolve date.
void ChickExtraMortality()
Apply extra chick mortality.
bool FlyTo(int a_distance)
Fly to
double m_food_today
Food collected.
int m_covey_y
Covey y-coord.
void MoveQualMemory(int a_qual)
Make a move based on memory of quality.
CfgFloat cfg_par_force_speed("PAR_COVEY_FORCE_SPEED", CFG_CUSTOM, 2.0)
bool FlyToFast(int a_distance)
Move a_distance from current covey position.
CfgFloat cfg_parinsectScaler("PAR_INSECTSCALER", CFG_CUSTOM, 0.5)
Default for 2000s, 1950s=1.0.
Partridge_Female * GetUnpairedFemale()
Finds the first unpaired female in the covey.
bool m_move_done
Have moved?
double BroodGeoMean()
Calculate the geometric mean of no of chicks.
int m_move_step_size
Internal variable.
CfgInt cfg_nest_permpasttussocky("PAR_NEST_PERMPASTTUSSOCKY", CFG_CUSTOM, 1)
Nesting quality for very low grazed pasture.
void SanityCheck()
Debug method.
bool NestOnNest(void)
Are we nesting?
int m_ChickAge
Age of chicks.
bool NestFindLocation(void)
Try to locate a suitable nesting location.
void SetCovey(Partridge_Covey *a_covey)
Set covey pointer.
CfgInt g_par_terr_max_width("PAR_TERR_MAX_WIDTH", CFG_CUSTOM, 500)
Limit to homerange radius.
void SanityCheck2(int no_chicks)
Debug method.
double AssessHabitatQuality(int &a_sz)
Assess habitat quality (with checks)
Partridge_Covey(Partridge_Base *a_first_member, Partridge_Population_Manager *a_manager, unsigned int a_center_x, unsigned int a_center_y, Landscape *a_map)
Constructor.
double HabitatEvalPoly(TTypesOfLandscapeElement a_cet, int a_poly)
bool IsMember(Partridge_Base *a_possible_member)
void FixHabitat(void)
Accept this breeding location.
bool FlyToSlow(int a_distance)
Move a_distance from current covey position (wraparound)
double SupplyInsects(int a_polyref)
CfgFloat cfg_par_covey_drift_speed("PAR_COVEY_DRIFT_SPEED", CFG_CUSTOM, 2.0)
Drift force on the peg.
bool m_nest_on_nest
Nesting flag.
double DistanceToCovey(Partridge_Covey *a_covey)
Get distance too covey.
CfgFloat cfg_min_merge_dist("PAR_MIN_MERGE_DIST", CFG_CUSTOM, 50.0)
The minimum merging distance.
CfgInt cfg_nest_railway("PAR_NEST_RAILWAY", CFG_CUSTOM, 100)
Nesting quality for railway ebankments.
double SupplyVegHeight(int a_polyref)
double m_dist_moved
Distance moved.
void ManagerCheckMerge(void)
int m_world_height_div2
Half landscape height.
int m_terr_size
Homerange width.
void SetUncle()
Swap uncle to alhpha.
bool MoveTryExclude(int a_dist_sq)
Uses the peg force to exclude possible movement directions.
static double * g_trig_sin
CfgInt g_par_nest_min_dist_bad_areas("PAR_NEST_MIN_DIST_BAD_AREAS", CFG_CUSTOM, 25)
Minimum nest distance to 'bad' areas.
Integer configurator entry class.
int m_move_qual_memory[4]
Steps remembered.
static double * g_trig_cos
void DissolveCovey(Partridge_Covey *a_covey)
CfgInt cfg_nest_hedgebank2("PAR_NEST_HEDGEBANKTWO", CFG_CUSTOM, 200)
Nesting quality for hedgebank type 2.
CfgFloat cfg_par_force_ignore_dist_sq("PAR_COVEY_FORCE_IGNORE_DIST_SQ", CFG_CUSTOM, 250000.0)
double m_new_center_x_float
Covey centre as float.
int m_nest_y
Nest coord-y.
int Supply_m_Location_y()
void ObjectLoopInit(int ob_type)
int GetUncleNumber()
Returns the number of uncles.
Double configurator entry class.
void SanityCheck4()
Debug method.
void AddMember(Partridge_Base *a_new_member)
int GetLimit(void)
Get how many points
bool CoveyEmigrate()
Test for covey emigration.
bool m_peg_is_fixed
flag for fixed homerange
double HabitatEvaluateFaster(int a_center_x, int a_center_y)
Evaluate habitat fast.
int m_move_whence_we_came
Internal variable.
void OntheDadDead()
Behaviour when alpha male is killed.
Partridge_Base * m_members[100]
List of covey members
double SupplyFoodToday(void)
Return the food obtained today.
bool HaveWeChicks(void)
Check if covey contains chicks.
CfgFloat cfg_par_force_below("PAR_COVEY_FORCE_BELOW", CFG_CUSTOM, 0.1)
int m_flyto_dist
costly intermediate variable
CfgInt cfg_nest_hedgebank0("PAR_NEST_HEDGEBANKZERO", CFG_CUSTOM, 1)
Nesting quality for hedgebank type 0.
CfgFloat cfg_NOT1950sinsects("PAR_NOTFIFTIESINSECTSSCALER", CFG_CUSTOM, 0.1)
Default for 2000s, 1950s=1.0.
bool ArePaired()
Debug method.
Landscape * m_map
Pointer to the landscape.
bool IsFixed(void)
Wonder whether the peg is fixed?
Partridge_Female * GetUnpairedFemale_virgin()
Finds the first never paired female in the covey.
double HabitatEvaluate(int a_center_x, int a_center_y, int *a_size_used, bool a_rethink_size)
Entry point for habitat evaluation.
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
double MoveDoIt(int *a_x, int *a_y, int a_dir, int a_step_size)
We know where we want to go. Now do it!
void KillExcessChicks(int remaining)
Kill extra chicks.
void AddCovey(Partridge_Covey *a_covey)
Add a new covey.
void SanityCheck1()
A debug function.
bool CanWeMerge(int a_NoUncles)
Merging test.
CfgInt cfg_par_merging_chance("PAR_MERGE_CHANCE", CFG_CUSTOM, 5)
The merging probability.
int HabitatEvalPolyField(int a_field)
Evaluate a field's habitat quality.
Partridge_Covey * m_neighbourlist[50]
List of coveys close to this covey.
void RemoveOldMate(bool a_knockon)
Forget old mate.
CfgInt cfg_nest_hedgebank1("PAR_NEST_HEDGEBANKONE", CFG_CUSTOM, 100)
Nesting quality for hedgebank type 1.
bool MoveSelectLimit(int a_limit, int a_x, int a_y)
Part of movement evaluation.
void EndStep(void)
Covey EndStep.
int MoveEvalEdgesAndQual(int a_edges, double a_qual)
Move evaluation taking edges into account.
CfgInt cfg_par_flyto_stepsize("PAR_FLYTO_STEPSIZE", CFG_CUSTOM, 1)
CfgInt g_par_nest_min_dist_other_nest("PAR_NEST_MIN_DIST_OTHER_NEST", CFG_CUSTOM, 50)
Minimum nest distance to other nests.
int SupplyPolyRef(int a_x, int a_y)
virtual ~Partridge_Covey(void)
Destructor.
void OnChickMature()
Remove a matured chick.
double m_move_dir_qual[8]
bool m_dist_done
Signals distance updating is done for today
CfgFloat cfg_par_hei_hindrance_inv("PAR_HEI_HINDRANCE", CFG_CUSTOM, 0.04)
static unsigned int g_covey_id_counter
int GetAge(void)
Supply age.
int m_nest_x
Nest coord-x.
bool m_terr_done
Signals homerange evaluation done
Partridge_Male * FindMeAHusband(Partridge_Female *a_female)
Find mate in covey.
CfgInt cfg_par_parentdead_mort("PAR_PARENTDEAD_MORT", CFG_CUSTOM, 100)
Mortalty chance on parent death.
int SupplyElementSubType(int a_polyref)
int Norm(int a_coord, int a_size)
Wrap-around utility function.
bool m_step_done
Signals Step is done for today
double HabitatEvaluateFast(int a_min_x_incl, int a_max_x_excl, int a_min_y_incl, int a_max_y_excl)
Evaluate habitat (wrap around)
bool m_permanent_marker
Unused
double m_center_y_float
Covey centre as float.
void AddObject(int ob_type, TAnimal *pTAo)
int * GetList(void)
Get pointer to list of points