2#include "dcon_generated.hpp"
16 return dcon::pop_demographics_key(dcon::pop_demographics_key::value_base_t(v.index() +
count_special_keys));
19 return dcon::pop_demographics_key(
20 dcon::pop_demographics_key::value_base_t(state.world.ideology_size() + v.index() +
count_special_keys));
23 return state.world.ideology_size() + state.world.issue_option_size() +
count_special_keys;
27 state.world.for_each_pop([&](dcon::pop_id p) {
28 state.world.pop_set_is_primary_or_accepted_culture(p,
false);
30 if(state.world.nation_get_primary_culture(n) == state.world.pop_get_culture(p)) {
31 state.world.pop_set_is_primary_or_accepted_culture(p,
true);
34 if(state.world.nation_get_accepted_cultures(n, state.world.pop_get_culture(p)) ==
true) {
35 state.world.pop_set_is_primary_or_accepted_culture(p,
true);
47 return dcon::demographics_key(dcon::pop_demographics_key::value_base_t(
51 return dcon::demographics_key(dcon::pop_demographics_key::value_base_t(
55 return dcon::demographics_key(
56 dcon::pop_demographics_key::value_base_t(
count_special_keys + state.world.pop_type_size() * 2 + v.index()));
59 return dcon::demographics_key(dcon::pop_demographics_key::value_base_t(
count_special_keys + state.world.pop_type_size() * 2 + state.world.culture_size() + v.index()));
62 return dcon::demographics_key(dcon::pop_demographics_key::value_base_t(
count_special_keys + state.world.pop_type_size() * 2 + state.world.culture_size() + state.world.ideology_size() + v.index()));
65 return dcon::demographics_key(dcon::pop_demographics_key::value_base_t(
count_special_keys + state.world.pop_type_size() * 2 + state.world.culture_size() + state.world.ideology_size() + state.world.issue_option_size() + v.index()));
69 return count_special_keys + state.world.ideology_size() + state.world.issue_option_size() +
70 uint32_t(2) * state.world.pop_type_size() + state.world.culture_size() + state.world.religion_size();
81 state.world.for_each_pop([&](dcon::pop_id p) {
82 auto location = state.world.pop_get_province_from_pop_location(p);
83 state.world.province_get_demographics(location, key) += source(state, p);
86 state.world.execute_serial_over_state_instance(
87 [&](
auto si) { state.world.state_instance_set_demographics(si, key, ve::fp_vector()); });
90 auto location = state.world.province_get_state_membership(p);
91 state.world.state_instance_get_demographics(location, key) += state.world.province_get_demographics(p, key);
94 state.world.execute_serial_over_nation([&](
auto ni) { state.world.nation_set_demographics(ni, key, ve::fp_vector()); });
96 state.world.for_each_state_instance([&](dcon::state_instance_id s) {
97 auto location = state.world.state_instance_get_nation_from_state_ownership(s);
98 state.world.nation_get_demographics(location, key) += state.world.state_instance_get_demographics(s, key);
107 for(
auto pc : state.world.nation_get_province_control_as_nation(n)) {
108 auto location = pc.get_province();
109 state.world.province_set_demographics(location, key, 0.f);
110 for(
auto pl : pc.get_province().get_pop_location_as_province()) {
111 state.world.province_get_demographics(location, key) += source(state, pl.get_pop());
114 for(
auto sc : state.world.nation_get_state_ownership_as_nation(n)) {
115 auto location = sc.get_state();
116 state.world.state_instance_set_demographics(location, key, 0.f);
117 for(
auto sm : sc.get_state().get_definition().get_abstract_state_membership()) {
118 state.world.state_instance_get_demographics(location, key) += state.world.province_get_demographics(sm.get_province(), key);
122 state.world.nation_set_demographics(n, key, 0.f);
123 for(
auto sc : state.world.nation_get_state_ownership_as_nation(n)) {
124 state.world.nation_get_demographics(n, key) += state.world.state_instance_get_demographics(sc.get_state(), key);
129 dcon::demographics_key key =
to_key(state, state.culture_definitions.jingoism);
131 for(
const auto pc : state.world.nation_get_province_control_as_nation(n)) {
133 return state.world.pop_get_demographics(p, pdemo_key) * state.world.pop_get_size(p);
140 auto const sz =
size(state);
142 auto const extra_size = sz - csz;
145 concurrency::parallel_for(
uint32_t(0), full ? sz : csz + extra_group_size, [&](
uint32_t base_index) {
146 auto index = base_index;
147 if constexpr(!full) {
154 dcon::demographics_key key{dcon::demographics_key::value_base_t(index)};
162 return state.world.pop_type_get_has_unemployment(state.world.pop_get_poptype(p)) ? state.world.pop_get_size(p) : 0.0f;
167 [](
sys::state const& state, dcon::pop_id p) {
return state.world.pop_get_employment(p); });
171 return state.world.pop_get_consciousness(p) * state.world.pop_get_size(p);
176 return state.world.pop_get_militancy(p) * state.world.pop_get_size(p);
181 return state.world.pop_get_literacy(p) * state.world.pop_get_size(p);
186 if(state.world.province_get_is_colonial(state.world.pop_get_province_from_pop_location(p)) ==
false) {
187 auto movement = state.world.pop_get_movement_from_pop_movement_membership(p);
189 auto opt = state.world.movement_get_associated_issue_option(movement);
190 auto optpar = state.world.issue_option_get_parent_issue(opt);
191 if(opt && state.world.issue_get_issue_type(optpar) == uint8_t(culture::issue_type::political))
192 return state.world.pop_get_size(p);
201 if(state.world.province_get_is_colonial(state.world.pop_get_province_from_pop_location(p)) ==
false) {
202 auto movement = state.world.pop_get_movement_from_pop_movement_membership(p);
204 auto opt = state.world.movement_get_associated_issue_option(movement);
205 auto optpar = state.world.issue_option_get_parent_issue(opt);
206 if(opt && state.world.issue_get_issue_type(optpar) == uint8_t(culture::issue_type::social))
207 return state.world.pop_get_size(p);
217 ? state.world.pop_get_militancy(p) * state.world.pop_get_size(p)
224 ? state.world.pop_get_militancy(p) * state.world.pop_get_size(p)
231 ? state.world.pop_get_militancy(p) * state.world.pop_get_size(p)
238 ? state.world.pop_get_life_needs_satisfaction(p) * state.world.pop_get_size(p)
245 ? state.world.pop_get_life_needs_satisfaction(p) * state.world.pop_get_size(p)
252 ? state.world.pop_get_life_needs_satisfaction(p) * state.world.pop_get_size(p)
259 ? state.world.pop_get_everyday_needs_satisfaction(p) * state.world.pop_get_size(p)
266 ? state.world.pop_get_everyday_needs_satisfaction(p) * state.world.pop_get_size(p)
273 ? state.world.pop_get_everyday_needs_satisfaction(p) * state.world.pop_get_size(p)
280 ? state.world.pop_get_luxury_needs_satisfaction(p) * state.world.pop_get_size(p)
287 ? state.world.pop_get_luxury_needs_satisfaction(p) * state.world.pop_get_size(p)
294 ? state.world.pop_get_luxury_needs_satisfaction(p) * state.world.pop_get_size(p)
301 ? state.world.pop_get_size(p)
308 ? state.world.pop_get_size(p)
315 ? state.world.pop_get_size(p)
321 }
else if(key.index() <
to_employment_key(state, dcon::pop_type_id(0)).index()) {
322 dcon::pop_type_id pkey{ dcon::pop_type_id::value_base_t(index - (
count_special_keys)) };
324 return state.world.pop_get_poptype(p) == pkey ?
state.world.pop_get_size(p) : 0.0f;
326 }
else if(key.index() <
to_key(state, dcon::culture_id(0)).index()) {
327 dcon::pop_type_id pkey{ dcon::pop_type_id::value_base_t(index - (
count_special_keys +
state.world.pop_type_size())) };
328 if(
state.world.pop_type_get_has_unemployment(pkey)) {
330 return state.world.pop_get_poptype(p) == pkey ?
state.world.pop_get_employment(p) : 0.0f;
334 return state.world.pop_get_poptype(p) == pkey ?
state.world.pop_get_size(p) : 0.0f;
337 }
else if(key.index() <
to_key(state, dcon::ideology_id(0)).index()) {
338 dcon::culture_id pkey{
341 return state.world.pop_get_culture(p) == pkey ?
state.world.pop_get_size(p) : 0.0f;
343 }
else if(key.index() <
to_key(state, dcon::issue_option_id(0)).index()) {
344 dcon::ideology_id pkey{dcon::ideology_id::value_base_t(index - (
count_special_keys +
state.world.pop_type_size() * 2 +
state.world.culture_size()))};
347 return state.world.pop_get_demographics(p, pdemo_key) *
state.world.pop_get_size(p);
349 }
else if(key.index() <
to_key(state, dcon::religion_id(0)).index()) {
350 dcon::issue_option_id pkey{dcon::issue_option_id::value_base_t(index - (
count_special_keys +
state.world.pop_type_size() * 2 +
state.world.culture_size() +
state.world.ideology_size()))};
353 return state.world.pop_get_demographics(p, pdemo_key) *
state.world.pop_get_size(p);
356 dcon::religion_id pkey{dcon::religion_id::value_base_t(
359 return state.world.pop_get_religion(p) == pkey ?
state.world.pop_get_size(p) : 0.0f;
370 static ve::vectorizable_buffer<float, dcon::province_id> max_buffer =
state.world.province_make_vectorizable_float_buffer();
372 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()),
373 [&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
374 state.world.for_each_culture([&](dcon::culture_id c) {
375 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()), [&, k =
to_key(state, c)](
auto p) {
376 auto v =
state.world.province_get_demographics(p, k);
377 auto old_max = max_buffer.get(p);
378 auto mask = v > old_max;
379 state.world.province_set_dominant_culture(p,
380 ve::select(mask, ve::tagged_vector<dcon::culture_id>(c),
state.world.province_get_dominant_culture(p)));
381 max_buffer.set(p,
ve::select(mask, v, old_max));
387 static ve::vectorizable_buffer<float, dcon::state_instance_id> max_buffer(
uint32_t(1));
390 auto new_count =
state.world.state_instance_size();
391 if(new_count > old_count) {
392 max_buffer =
state.world.state_instance_make_vectorizable_float_buffer();
393 old_count = new_count;
395 state.world.execute_serial_over_state_instance([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
396 state.world.for_each_culture([&](dcon::culture_id c) {
397 state.world.execute_serial_over_state_instance([&, k =
to_key(state, c)](
auto p) {
398 auto v =
state.world.state_instance_get_demographics(p, k);
399 auto old_max = max_buffer.get(p);
400 auto mask = v > old_max;
401 state.world.state_instance_set_dominant_culture(p,
402 ve::select(mask, ve::tagged_vector<dcon::culture_id>(c),
state.world.state_instance_get_dominant_culture(p)));
403 max_buffer.set(p,
ve::select(mask, v, old_max));
409 static ve::vectorizable_buffer<float, dcon::nation_id> max_buffer(
uint32_t(1));
412 auto new_count =
state.world.nation_size();
413 if(new_count > old_count) {
414 max_buffer =
state.world.nation_make_vectorizable_float_buffer();
415 old_count = new_count;
417 state.world.execute_serial_over_nation([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
418 state.world.for_each_culture([&](dcon::culture_id c) {
419 state.world.execute_serial_over_nation([&, k =
to_key(state, c)](
auto p) {
420 auto v =
state.world.nation_get_demographics(p, k);
421 auto old_max = max_buffer.get(p);
422 auto mask = v > old_max;
423 state.world.nation_set_dominant_culture(p,
424 ve::select(mask, ve::tagged_vector<dcon::culture_id>(c),
state.world.nation_get_dominant_culture(p)));
425 max_buffer.set(p,
ve::select(mask, v, old_max));
431 static ve::vectorizable_buffer<float, dcon::province_id> max_buffer =
state.world.province_make_vectorizable_float_buffer();
433 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()),
434 [&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
435 state.world.for_each_religion([&](dcon::religion_id c) {
436 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()), [&, k =
to_key(state, c)](
auto p) {
437 auto v =
state.world.province_get_demographics(p, k);
438 auto old_max = max_buffer.get(p);
439 auto mask = v > old_max;
440 state.world.province_set_dominant_religion(p,
441 ve::select(mask, ve::tagged_vector<dcon::religion_id>(c),
state.world.province_get_dominant_religion(p)));
442 max_buffer.set(p,
ve::select(mask, v, old_max));
448 static ve::vectorizable_buffer<float, dcon::state_instance_id> max_buffer(
uint32_t(1));
451 auto new_count =
state.world.state_instance_size();
452 if(new_count > old_count) {
453 max_buffer =
state.world.state_instance_make_vectorizable_float_buffer();
454 old_count = new_count;
456 state.world.execute_serial_over_state_instance([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
457 state.world.for_each_religion([&](dcon::religion_id c) {
458 state.world.execute_serial_over_state_instance([&, k =
to_key(state, c)](
auto p) {
459 auto v =
state.world.state_instance_get_demographics(p, k);
460 auto old_max = max_buffer.get(p);
461 auto mask = v > old_max;
462 state.world.state_instance_set_dominant_religion(p,
463 ve::select(mask, ve::tagged_vector<dcon::religion_id>(c),
state.world.state_instance_get_dominant_religion(p)));
464 max_buffer.set(p,
ve::select(mask, v, old_max));
470 static ve::vectorizable_buffer<float, dcon::nation_id> max_buffer(
uint32_t(1));
473 auto new_count =
state.world.nation_size();
474 if(new_count > old_count) {
475 max_buffer =
state.world.nation_make_vectorizable_float_buffer();
476 old_count = new_count;
478 state.world.execute_serial_over_nation([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
479 state.world.for_each_religion([&](dcon::religion_id c) {
480 state.world.execute_serial_over_nation([&, k =
to_key(state, c)](
auto p) {
481 auto v =
state.world.nation_get_demographics(p, k);
482 auto old_max = max_buffer.get(p);
483 auto mask = v > old_max;
484 state.world.nation_set_dominant_religion(p,
485 ve::select(mask, ve::tagged_vector<dcon::religion_id>(c),
state.world.nation_get_dominant_religion(p)));
486 max_buffer.set(p,
ve::select(mask, v, old_max));
492 static ve::vectorizable_buffer<float, dcon::province_id> max_buffer =
state.world.province_make_vectorizable_float_buffer();
494 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()),
495 [&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
496 state.world.for_each_ideology([&](dcon::ideology_id c) {
497 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()), [&, k =
to_key(state, c)](
auto p) {
498 auto v =
state.world.province_get_demographics(p, k);
499 auto old_max = max_buffer.get(p);
500 auto mask = v > old_max;
501 state.world.province_set_dominant_ideology(p,
502 ve::select(mask, ve::tagged_vector<dcon::ideology_id>(c),
state.world.province_get_dominant_ideology(p)));
503 max_buffer.set(p,
ve::select(mask, v, old_max));
509 static ve::vectorizable_buffer<float, dcon::state_instance_id> max_buffer(
uint32_t(1));
512 auto new_count =
state.world.state_instance_size();
513 if(new_count > old_count) {
514 max_buffer =
state.world.state_instance_make_vectorizable_float_buffer();
515 old_count = new_count;
517 state.world.execute_serial_over_state_instance([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
518 state.world.for_each_ideology([&](dcon::ideology_id c) {
519 state.world.execute_serial_over_state_instance([&, k =
to_key(state, c)](
auto p) {
520 auto v =
state.world.state_instance_get_demographics(p, k);
521 auto old_max = max_buffer.get(p);
522 auto mask = v > old_max;
523 state.world.state_instance_set_dominant_ideology(p,
524 ve::select(mask, ve::tagged_vector<dcon::ideology_id>(c),
state.world.state_instance_get_dominant_ideology(p)));
525 max_buffer.set(p,
ve::select(mask, v, old_max));
531 static ve::vectorizable_buffer<float, dcon::nation_id> max_buffer(
uint32_t(1));
534 auto new_count =
state.world.nation_size();
535 if(new_count > old_count) {
536 max_buffer =
state.world.nation_make_vectorizable_float_buffer();
537 old_count = new_count;
539 state.world.execute_serial_over_nation([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
540 state.world.for_each_ideology([&](dcon::ideology_id c) {
541 state.world.execute_serial_over_nation([&, k =
to_key(state, c)](
auto p) {
542 auto v =
state.world.nation_get_demographics(p, k);
543 auto old_max = max_buffer.get(p);
544 auto mask = v > old_max;
545 state.world.nation_set_dominant_ideology(p,
546 ve::select(mask, ve::tagged_vector<dcon::ideology_id>(c),
state.world.nation_get_dominant_ideology(p)));
547 max_buffer.set(p,
ve::select(mask, v, old_max));
553 static ve::vectorizable_buffer<float, dcon::province_id> max_buffer =
state.world.province_make_vectorizable_float_buffer();
555 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()),
556 [&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
557 state.world.for_each_issue_option([&](dcon::issue_option_id c) {
558 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()), [&, k =
to_key(state, c)](
auto p) {
559 auto v =
state.world.province_get_demographics(p, k);
560 auto old_max = max_buffer.get(p);
561 auto mask = v > old_max;
562 state.world.province_set_dominant_issue_option(p,
563 ve::select(mask, ve::tagged_vector<dcon::issue_option_id>(c),
state.world.province_get_dominant_issue_option(p)));
564 max_buffer.set(p,
ve::select(mask, v, old_max));
570 static ve::vectorizable_buffer<float, dcon::state_instance_id> max_buffer(
uint32_t(1));
573 auto new_count =
state.world.state_instance_size();
574 if(new_count > old_count) {
575 max_buffer =
state.world.state_instance_make_vectorizable_float_buffer();
576 old_count = new_count;
578 state.world.execute_serial_over_state_instance([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
579 state.world.for_each_issue_option([&](dcon::issue_option_id c) {
580 state.world.execute_serial_over_state_instance([&, k =
to_key(state, c)](
auto p) {
581 auto v =
state.world.state_instance_get_demographics(p, k);
582 auto old_max = max_buffer.get(p);
583 auto mask = v > old_max;
584 state.world.state_instance_set_dominant_issue_option(p,
ve::select(mask, ve::tagged_vector<dcon::issue_option_id>(c),
state.world.state_instance_get_dominant_issue_option(p)));
585 max_buffer.set(p,
ve::select(mask, v, old_max));
591 static ve::vectorizable_buffer<float, dcon::nation_id> max_buffer(
uint32_t(1));
594 auto new_count =
state.world.nation_size();
595 if(new_count > old_count) {
596 max_buffer =
state.world.nation_make_vectorizable_float_buffer();
597 old_count = new_count;
599 state.world.execute_serial_over_nation([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
600 state.world.for_each_issue_option([&](dcon::issue_option_id c) {
601 state.world.execute_serial_over_nation([&, k =
to_key(state, c)](
auto p) {
602 auto v =
state.world.nation_get_demographics(p, k);
603 auto old_max = max_buffer.get(p);
604 auto mask = v > old_max;
605 state.world.nation_set_dominant_issue_option(p,
606 ve::select(mask, ve::tagged_vector<dcon::issue_option_id>(c),
state.world.nation_get_dominant_issue_option(p)));
607 max_buffer.set(p,
ve::select(mask, v, old_max));
613 static ve::vectorizable_buffer<float, dcon::pop_id> max_buffer(
uint32_t(1));
616 auto new_count =
state.world.pop_size();
617 if(new_count > old_count) {
618 max_buffer =
state.world.pop_make_vectorizable_float_buffer();
619 old_count = new_count;
621 state.world.execute_serial_over_pop([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
622 state.world.for_each_issue_option([&](dcon::issue_option_id c) {
624 auto v =
state.world.pop_get_demographics(p, k);
625 auto old_max = max_buffer.get(p);
626 auto mask = v > old_max;
627 state.world.pop_set_dominant_issue_option(p,
628 ve::select(mask, ve::tagged_vector<dcon::issue_option_id>(c),
state.world.pop_get_dominant_issue_option(p)));
629 max_buffer.set(p,
ve::select(mask, v, old_max));
635 static ve::vectorizable_buffer<float, dcon::pop_id> max_buffer(
uint32_t(1));
638 auto new_count =
state.world.pop_size();
639 if(new_count > old_count) {
640 max_buffer =
state.world.pop_make_vectorizable_float_buffer();
641 old_count = new_count;
643 state.world.execute_serial_over_pop([&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
644 state.world.for_each_ideology([&](dcon::ideology_id c) {
646 auto v =
state.world.pop_get_demographics(p, k);
647 auto old_max = max_buffer.get(p);
648 auto mask = v > old_max;
649 state.world.pop_set_dominant_ideology(p,
650 ve::select(mask, ve::tagged_vector<dcon::ideology_id>(c),
state.world.pop_get_dominant_ideology(p)));
651 max_buffer.set(p,
ve::select(mask, v, old_max));
658 state.world.execute_serial_over_nation(
659 [&](
auto ni) {
state.world.nation_set_non_colonial_population(ni, ve::fp_vector()); });
661 state.world.for_each_state_instance([&](dcon::state_instance_id s) {
662 if(!
state.world.province_get_is_colonial(
state.world.state_instance_get_capital(s))) {
663 auto location = state.world.state_instance_get_nation_from_state_ownership(s);
664 state.world.nation_get_non_colonial_population(location) +=
665 state.world.state_instance_get_demographics(s, demographics::total);
672 state.world.execute_serial_over_nation(
673 [&](
auto ni) {
state.world.nation_set_non_colonial_bureaucrats(ni, ve::fp_vector()); });
675 state.world.for_each_state_instance(
677 if(!state.world.province_get_is_colonial(state.world.state_instance_get_capital(s))) {
678 auto location = state.world.state_instance_get_nation_from_state_ownership(s);
679 state.world.nation_get_non_colonial_bureaucrats(location) += state.world.state_instance_get_demographics(s, k);
686 static ve::vectorizable_buffer<float, dcon::province_id> max_buffer =
state.world.province_make_vectorizable_float_buffer();
687 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()),
688 [&](
auto p) { state.world.province_set_dominant_accepted_culture(p, dcon::culture_id{}); });
689 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()),
690 [&](
auto p) { max_buffer.set(p, ve::fp_vector()); });
692 state.world.for_each_culture([&](dcon::culture_id c) {
693 ve::execute_serial<dcon::province_id>(
uint32_t(
state.province_definitions.first_sea_province.index()), [&, key =
to_key(state, c)](
auto p) {
694 auto v =
state.world.province_get_demographics(p, key);
695 auto old_max = max_buffer.get(p);
697 state.world.province_set_dominant_accepted_culture(p,
698 ve::select(mask, ve::tagged_vector<dcon::culture_id>(c),
state.world.province_get_dominant_accepted_culture(p)));
699 max_buffer.set(p,
ve::select(mask, v, old_max));
711 regenerate_from_pop_data<true>(state);
714 regenerate_from_pop_data<false>(state);
721 auto block_index = 16 * offset;
722 auto const block_advance = 16 * divisions;
726 while(block_index < max) {
728 functor(ve::contiguous_tags<dcon::pop_id>(block_index + i * ve::vector_size));
730 block_index += block_advance;
736 concurrency::parallel_for(16 * offset, max, 16 * divisions, [&](
uint32_t index) {
738 functor(ve::contiguous_tags<dcon::pop_id>(index + i * ve::vector_size));
768 auto loc = state.world.pop_get_province_from_pop_location(ids);
769 auto owner = state.world.province_get_nation_from_province_ownership(loc);
770 auto ruling_party = state.world.nation_get_ruling_party(owner);
771 auto ruling_ideology = state.world.political_party_get_ideology(ruling_party);
773 auto lx_mod = ve::max(state.world.pop_get_luxury_needs_satisfaction(ids) - 0.5f, 0.0f) * state.defines.mil_has_luxury_need;
774 auto con_sup = (state.world.pop_get_demographics(ids, conservatism_key) * state.defines.mil_ideology);
775 auto ruling_sup = ve::apply(
776 [&](dcon::pop_id p, dcon::ideology_id i) {
777 return i ? state.world.pop_get_demographics(p, pop_demographics::to_key(state, i)) * state.defines.mil_ruling_party
780 ids, ruling_ideology);
781 auto ref_mod =
ve::select(state.world.province_get_is_colonial(loc), 0.0f,
782 (state.world.pop_get_social_reform_desire(ids) + state.world.pop_get_political_reform_desire(ids)) *
783 (state.defines.mil_require_reform * 0.25f));
785 auto o_spending = state.world.nation_get_overseas_penalty(owner);
786 auto spending_level = state.world.nation_get_spending_level(owner);
789 (state.defines.alice_overseas_mil * 2.f)
790 * (0.5f - (o_spending * spending_level)),
794 auto sub_t = (lx_mod + ruling_sup) + (con_sup + ref_mod);
796 auto pmod = state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::pop_militancy_modifier);
797 auto omod = state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::global_pop_militancy_modifier);
798 auto cmod =
ve::select(state.world.province_get_is_colonial(loc), 0.0f,
799 state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::core_pop_militancy_modifier));
801 auto local_mod = (pmod + omod) + cmod;
803 auto sep_mod =
ve::select(state.world.pop_get_is_primary_or_accepted_culture(ids), 0.0f,
804 (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::non_accepted_pop_militancy_modifier) + 1.0f) *
805 state.defines.mil_non_accepted);
806 auto ln_mod = ve::min((state.world.pop_get_life_needs_satisfaction(ids) - 0.5f), 0.0f) * state.defines.mil_no_life_need;
808 ve::min(0.0f, (state.world.pop_get_everyday_needs_satisfaction(ids) - 0.5f)) * state.defines.mil_lack_everyday_need;
810 ve::max(0.0f, (state.world.pop_get_everyday_needs_satisfaction(ids) - 0.5f)) * state.defines.mil_has_everyday_need;
812 auto war_exhaustion = state.world.nation_get_war_exhaustion(owner) * state.defines.mil_war_exhaustion;
813 auto old_mil = state.world.pop_get_militancy(ids);
815 state.world.pop_set_militancy(
821 owner != dcon::nation_id{},
826 + old_mil * (1.f - state.defines.alice_militancy_decay)
830 + (en_mod_b - en_mod_a)
831 + (war_exhaustion + overseas_mil)
846 auto loc = state.world.pop_get_province_from_pop_location(ids);
847 auto owner = state.world.province_get_nation_from_province_ownership(loc);
848 auto ruling_party = state.world.nation_get_ruling_party(owner);
849 auto ruling_ideology = state.world.political_party_get_ideology(ruling_party);
851 float lx_mod = std::max(state.world.pop_get_luxury_needs_satisfaction(ids) - 0.5f, 0.0f) * state.defines.mil_has_luxury_need;
852 float con_sup = (state.world.pop_get_demographics(ids, conservatism_key) * state.defines.mil_ideology);
853 float ruling_sup = ruling_ideology
854 ? state.world.pop_get_demographics(ids,
pop_demographics::to_key(state, ruling_ideology)) * state.defines.mil_ruling_party
856 float ref_mod = state.world.province_get_is_colonial(loc) ? 0.0f :
857 (state.world.pop_get_social_reform_desire(ids) + state.world.pop_get_political_reform_desire(ids)) *
858 (state.defines.mil_require_reform * 0.25f);
860 auto o_spending = state.world.nation_get_overseas_penalty(owner);
861 auto spending_level = state.world.nation_get_spending_level(owner);
864 (state.defines.alice_overseas_mil * 2.f)
865 * (0.5f - (o_spending * spending_level)),
869 float sub_t = (lx_mod + ruling_sup) + (con_sup + ref_mod);
871 float pmod = state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::pop_militancy_modifier);
872 float omod = state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::global_pop_militancy_modifier);
873 float cmod =
ve::select(state.world.province_get_is_colonial(loc), 0.0f,
874 state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::core_pop_militancy_modifier));
876 float local_mod = (pmod + omod) + cmod;
878 float sep_mod =
ve::select(state.world.pop_get_is_primary_or_accepted_culture(ids), 0.0f,
879 (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::non_accepted_pop_militancy_modifier) + 1.0f) *
880 state.defines.mil_non_accepted);
881 float ln_mod = std::min((state.world.pop_get_life_needs_satisfaction(ids) - 0.5f), 0.0f) * state.defines.mil_no_life_need;
883 std::min(0.0f, (state.world.pop_get_everyday_needs_satisfaction(ids) - 0.5f)) * state.defines.mil_lack_everyday_need;
885 std::max(0.0f, (state.world.pop_get_everyday_needs_satisfaction(ids) - 0.5f)) * state.defines.mil_has_everyday_need;
886 float war_exhaustion =
887 state.world.nation_get_war_exhaustion(owner) * 0.005f;
888 auto old_mil = state.world.pop_get_militancy(ids);
890 return (sub_t + local_mod) + ((sep_mod - ln_mod) + (en_mod_b - en_mod_a) + (war_exhaustion + overseas_mil)) - old_mil * state.defines.alice_militancy_decay;
895 for(
auto prov :
dcon::fatten(state.world, n).get_province_ownership()) {
896 for(
auto pop : prov.get_province().get_pop_location()) {
901 return t != 0.f ? sum / t : 0.f;
920 auto loc = state.world.pop_get_province_from_pop_location(ids);
921 auto owner = state.world.province_get_nation_from_province_ownership(loc);
923 state.world.province_get_demographics(loc, clergy_key) / state.world.province_get_demographics(loc, demographics::total);
924 auto types = state.world.pop_get_poptype(ids);
926 auto lx_mod = state.world.pop_get_luxury_needs_satisfaction(ids) * state.defines.con_luxury_goods;
927 auto cl_mod = cfrac * ve::select(state.world.pop_type_get_strata(types) == int32_t(culture::pop_strata::poor),
928 ve::fp_vector{state.defines.con_poor_clergy}, ve::fp_vector{state.defines.con_midrich_clergy});
929 auto lit_mod = ((state.world.nation_get_plurality(owner) / 10.0f) *
930 (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::literacy_con_impact) + 1.0f) *
931 state.defines.con_literacy * state.world.pop_get_literacy(ids) *
932 ve::select(state.world.province_get_is_colonial(loc), ve::fp_vector{state.defines.con_colonial_factor}, 1.0f)) / 10.f;
934 auto pmod = state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::pop_consciousness_modifier);
935 auto omod = state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::global_pop_consciousness_modifier);
936 auto cmod =
ve::select(state.world.province_get_is_colonial(loc), 0.0f,
937 state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::core_pop_consciousness_modifier));
939 auto local_mod = (pmod + omod) + cmod;
941 auto sep_mod =
ve::select(state.world.pop_get_is_primary_or_accepted_culture(ids), 0.0f,
942 state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::non_accepted_pop_consciousness_modifier));
944 auto old_con = state.world.pop_get_consciousness(ids);
946 state.world.pop_set_consciousness(ids,
947 ve::min(ve::max(
ve::select(owner != dcon::nation_id{}, ((old_con * 0.99f + lx_mod) + (cl_mod + lit_mod)) + (local_mod + sep_mod), 0.0f), 0.0f), 10.f));
954 auto loc = state.world.pop_get_province_from_pop_location(ids);
955 auto owner = state.world.province_get_nation_from_province_ownership(loc);
957 state.world.province_get_demographics(loc, clergy_key) / state.world.province_get_demographics(loc,
demographics::total);
958 auto types = state.world.pop_get_poptype(ids);
960 float lx_mod = state.world.pop_get_luxury_needs_satisfaction(ids) * state.defines.con_luxury_goods;
962 state.defines.con_poor_clergy, state.defines.con_midrich_clergy);
963 float lit_mod = ((state.world.nation_get_plurality(owner) / 10.0f) *
964 (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::literacy_con_impact) + 1.0f) *
965 state.defines.con_literacy * state.world.pop_get_literacy(ids) *
966 ve::select(state.world.province_get_is_colonial(loc), state.defines.con_colonial_factor, 1.0f)) / 10.f;
968 float pmod = state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::pop_consciousness_modifier);
969 float omod = state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::global_pop_consciousness_modifier);
970 float cmod =
ve::select(state.world.province_get_is_colonial(loc), 0.0f,
971 state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::core_pop_consciousness_modifier));
973 float local_mod = (pmod + omod) + cmod;
975 float sep_mod =
ve::select(state.world.pop_get_is_primary_or_accepted_culture(ids), 0.0f,
976 state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::non_accepted_pop_consciousness_modifier));
977 auto old_con = state.world.pop_get_consciousness(ids);
979 return (lx_mod + (cl_mod + lit_mod)) + (local_mod + sep_mod) - old_con * 0.01f;
984 for(
auto prov :
dcon::fatten(state.world, n).get_province_ownership()) {
985 for(
auto pop : prov.get_province().get_pop_location()) {
990 return t != 0.f ? sum / t : 0.f;
1013 auto loc = state.world.pop_get_province_from_pop_location(ids);
1014 auto owner = state.world.province_get_nation_from_province_ownership(loc);
1016 state.world.province_get_demographics(loc, clergy_key) / state.world.province_get_demographics(loc, demographics::total);
1018 auto tmod = state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::education_efficiency) + 1.0f;
1019 auto nmod = state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::education_efficiency_modifier) + 1.0f;
1020 auto espending = 0.5f +
1021 (ve::to_float(state.world.nation_get_education_spending(owner)) / 100.0f) * state.world.nation_get_spending_level(owner) * 0.5f;
1022 auto cmod = ve::max(
1026 (cfrac - state.defines.base_clergy_for_literacy)
1027 / (state.defines.max_clergy_for_literacy - state.defines.base_clergy_for_literacy)
1031 auto old_lit = state.world.pop_get_literacy(ids);
1032 auto new_lit = ve::min(
1035 + (0.01f * state.defines.literacy_change_speed)
1047 state.world.pop_set_literacy(ids, ve::select(owner != dcon::nation_id{}, new_lit, old_lit));
1054 auto loc = state.world.pop_get_province_from_pop_location(ids);
1055 auto owner = state.world.province_get_nation_from_province_ownership(loc);
1057 state.world.province_get_demographics(loc, clergy_key) / state.world.province_get_demographics(loc,
demographics::total);
1059 auto tmod = state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::education_efficiency) + 1.0f;
1060 auto nmod = state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::education_efficiency_modifier) + 1.0f;
1062 (float(state.world.nation_get_education_spending(owner)) / 100.0f) * state.world.nation_get_spending_level(owner);
1063 auto cmod = std::max(0.0f, std::min(1.0f, (cfrac - state.defines.base_clergy_for_literacy) /
1064 (state.defines.max_clergy_for_literacy - state.defines.base_clergy_for_literacy)));
1066 auto old_lit = state.world.pop_get_literacy(ids);
1067 auto new_lit = std::min(std::max(old_lit + (0.01f * state.defines.literacy_change_speed) * ((espending * cmod) * (tmod * nmod)), 0.01f), 1.0f);
1069 return new_lit - old_lit;
1074 for(
auto prov :
dcon::fatten(state.world, n).get_province_ownership()) {
1075 for(
auto pop : prov.get_province().get_pop_location()) {
1080 return t != 0.f ? sum / t : 0.f;
1089 auto new_pop_count = state.world.pop_size();
1090 ibuf.
update(state, new_pop_count);
1096 state.world.for_each_ideology([&](dcon::ideology_id i) {
1097 if(state.world.ideology_get_enabled(i)) {
1098 auto const i_key = pop_demographics::to_key(state, i);
1099 if(state.world.ideology_get_is_civilized_only(i)) {
1100 pexecute_staggered_blocks(offset, divisions, new_pop_count, [&](auto ids) {
1101 auto owner = nations::owner_of_pop(state, ids);
1103 auto amount = ve::apply(
1104 [&](dcon::pop_id pid, dcon::pop_type_id ptid, dcon::nation_id o) {
1105 if(state.world.nation_get_is_civilized(o)) {
1106 if(auto mfn = state.world.pop_type_get_ideology_fns(ptid, i); mfn != 0) {
1107 using ftype = float(*)(int32_t);
1108 ftype fn = (ftype)mfn;
1109 float llvm_result = fn(pid.index());
1110#ifdef CHECK_LLVM_RESULTS
1111 float interp_result = 0.0f;
1112 if(auto mtrigger = state.world.pop_type_get_ideology(ptid, i); mtrigger) {
1113 interp_result = trigger::evaluate_multiplicative_modifier(state, mtrigger, trigger::to_generic(pid), trigger::to_generic(pid), 0);
1115 assert(llvm_result == interp_result);
1119 auto ptrigger = state.world.pop_type_get_ideology(ptid, i);
1120 return ptrigger ? trigger::evaluate_multiplicative_modifier(state, ptrigger, trigger::to_generic(pid), trigger::to_generic(pid), 0) : 0.0f;
1126 ids, state.world.pop_get_poptype(ids), owner);
1128 ibuf.temp_buffers[i].set(ids, amount);
1129 ibuf.totals.set(ids, ibuf.totals.get(ids) + amount);
1132 pexecute_staggered_blocks(offset, divisions, new_pop_count, [&](auto ids) {
1133 auto owner = nations::owner_of_pop(state, ids);
1135 auto amount = ve::apply(
1136 [&](dcon::pop_id pid, dcon::pop_type_id ptid, dcon::nation_id o) {
1137 if(auto mfn = state.world.pop_type_get_ideology_fns(ptid, i); mfn != 0) {
1138 using ftype = float(*)(int32_t);
1139 ftype fn = (ftype)mfn;
1140 float llvm_result = fn(pid.index());
1141#ifdef CHECK_LLVM_RESULTS
1142 float interp_result = 0.0f;
1143 if(auto mtrigger = state.world.pop_type_get_ideology(ptid, i); mtrigger) {
1144 interp_result = trigger::evaluate_multiplicative_modifier(state, mtrigger, trigger::to_generic(pid), trigger::to_generic(pid), 0);
1146 assert(llvm_result == interp_result);
1150 auto ptrigger = state.world.pop_type_get_ideology(ptid, i);
1151 return ptrigger ? trigger::evaluate_multiplicative_modifier(state, ptrigger, trigger::to_generic(pid), trigger::to_generic(pid), 0) : 0.0f;
1154 ids, state.world.pop_get_poptype(ids), owner);
1156 ibuf.temp_buffers[i].set(ids, amount);
1157 ibuf.totals.set(ids, ibuf.totals.get(ids) + amount);
1173 state.world.for_each_ideology([&](dcon::ideology_id i) {
1174 if(state.world.ideology_get_enabled(i)) {
1175 auto const i_key = pop_demographics::to_key(state, i);
1177 execute_staggered_blocks(offset, divisions, std::min(state.world.pop_size(), pbuf.size), [&](auto ids) {
1178 auto ttotal = pbuf.totals.get(ids);
1179 auto avalue = pbuf.temp_buffers[i].get(ids) / ttotal;
1180 auto current = state.world.pop_get_demographics(ids, i_key);
1182 state.world.pop_set_demographics(ids, i_key,
1183 ve::select(ttotal > 0.0f, state.defines.alice_ideology_base_change_rate * avalue + (1.0f - state.defines.alice_ideology_base_change_rate) * current, current));
1198 auto new_pop_count = state.world.pop_size();
1199 ibuf.
update(state, new_pop_count);
1205 state.world.for_each_issue_option([&](dcon::issue_option_id iid) {
1206 auto opt = fatten(state.world, iid);
1207 auto allow = opt.get_allow();
1208 auto parent_issue = opt.get_parent_issue();
1213 auto has_modifier = is_social_issue || is_political_issue;
1215 is_social_issue ? sys::national_mod_offsets::social_reform_desire : sys::national_mod_offsets::political_reform_desire;
1219 auto current_issue_setting = state.world.nation_get_issues(owner, parent_issue);
1220 auto allowed_by_owner =
1221 (state.world.nation_get_is_civilized(owner) || ve::mask_vector(is_party_issue))
1222 && (ve::mask_vector(!state.world.issue_get_is_next_step_only(parent_issue)) ||
1223 (ve::tagged_vector<int32_t>(current_issue_setting) == iid.index()) ||
1224 (ve::tagged_vector<int32_t>(current_issue_setting) == iid.index() - 1) ||
1225 (ve::tagged_vector<int32_t>(current_issue_setting) == iid.index() + 1));
1226 auto owner_modifier =
1227 has_modifier ? (state.world.nation_get_modifier_values(owner, modifier_key) + 1.0f) : ve::fp_vector(1.0f);
1229 auto amount = owner_modifier *
ve::select(allowed_by_owner,
1230 ve::apply([&](dcon::pop_id pid, dcon::pop_type_id ptid, dcon::nation_id o) {
1231 if(
auto mfn = state.world.pop_type_get_issues_fns(ptid, iid); mfn != 0) {
1232 using ftype = float(*)(int32_t);
1233 ftype fn = (ftype)mfn;
1234 float llvm_result = fn(pid.index());
1235#ifdef CHECK_LLVM_RESULTS
1236 float interp_result = 0.0f;
1237 if(auto mtrigger = state.world.pop_type_get_issues(ptid, iid); mtrigger) {
1238 interp_result = trigger::evaluate_multiplicative_modifier(state, mtrigger, trigger::to_generic(pid), trigger::to_generic(pid), 0);
1240 assert(llvm_result == interp_result);
1244 if(
auto mtrigger = state.world.pop_type_get_issues(ptid, iid); mtrigger) {
1245 return trigger::evaluate_multiplicative_modifier(state, mtrigger, trigger::to_generic(pid), trigger::to_generic(pid), 0);
1250 }, ids, state.world.pop_get_poptype(ids), owner),
1269 state.world.for_each_issue_option([&](dcon::issue_option_id i) {
1273 auto ttotal = pbuf.totals.get(ids);
1274 auto avalue = pbuf.temp_buffers[i].get(ids) / ttotal;
1275 auto current = state.world.pop_get_demographics(ids, i_key);
1276 auto owner = nations::owner_of_pop(state, ids);
1277 auto owner_rate_modifier =
1278 (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::issue_change_speed) + 1.0f);
1280 state.world.pop_set_demographics(ids, i_key,
1281 ve::select(ttotal > 0.0f,
1282 issues_change_rate * owner_rate_modifier * avalue + (1.0f - issues_change_rate * owner_rate_modifier) * current,
1304 auto loc = state.world.pop_get_province_from_pop_location(ids);
1305 auto owner = state.world.province_get_nation_from_province_ownership(loc);
1307 auto base_life_rating = ve::to_float(state.world.province_get_life_rating(loc));
1308 auto mod_life_rating = ve::min(
1309 base_life_rating * (state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::life_rating) + 1.0f),
1312 ve::max((mod_life_rating - state.defines.min_life_rating_for_growth) * state.defines.life_rating_growth_bonus, 0.0f);
1313 auto province_factor = lr_factor + state.defines.base_popgrowth;
1315 auto ln_factor = state.world.pop_get_life_needs_satisfaction(ids) - state.defines.life_need_starvation_limit;
1316 auto mod_sum = state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::population_growth) +
1317 state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::pop_growth);
1319 auto total_factor = ln_factor * province_factor * 4.0f + mod_sum * 0.1f;
1320 auto old_size = state.world.pop_get_size(ids);
1321 auto new_size = old_size * total_factor + old_size;
1323 auto type = state.world.pop_get_poptype(ids);
1325 state.world.pop_set_size(ids,
1326 ve::select((owner != dcon::nation_id{}) && (type != state.culture_definitions.slaves), new_size, old_size));
1331 auto type = state.world.pop_get_poptype(ids);
1332 if(type == state.culture_definitions.slaves)
1335 auto loc = state.world.pop_get_province_from_pop_location(ids);
1336 auto owner = state.world.province_get_nation_from_province_ownership(loc);
1338 auto base_life_rating = float(state.world.province_get_life_rating(loc));
1339 auto mod_life_rating = std::min(
1340 base_life_rating * (state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::life_rating) + 1.0f), 40.0f);
1342 std::max((mod_life_rating - state.defines.min_life_rating_for_growth) * state.defines.life_rating_growth_bonus, 0.0f);
1343 auto province_factor = lr_factor + state.defines.base_popgrowth;
1345 auto ln_factor = state.world.pop_get_life_needs_satisfaction(ids) - state.defines.life_need_starvation_limit;
1346 auto mod_sum = state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::population_growth) +
1347 state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::pop_growth);
1349 auto total_factor = ln_factor * province_factor * 4.0f + mod_sum * 0.1f;
1350 auto old_size = state.world.pop_get_size(ids);
1352 return old_size * total_factor;
1356 for(
auto prov : state.world.nation_get_province_ownership(n)) {
1357 for(
auto pop : prov.get_province().get_pop_location()) {
1367 for(
auto pop : state.world.province_get_pop_location(prov)) {
1368 t += get_monthly_pop_increase(state, pop.get_pop());
1376 for(
auto pop : state.world.province_get_pop_location(n)) {
1383 pbuf.
update(state.world.pop_size());
1391 pbuf.amounts.set(ids, 0.0f);
1392 auto owners = nations::owner_of_pop(state, ids);
1393#ifdef CHECK_LLVM_RESULTS
1394 auto promotion_chances = trigger::evaluate_additive_modifier(state, state.culture_definitions.promotion_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0);
1395 auto demotion_chances = trigger::evaluate_additive_modifier(state, state.culture_definitions.demotion_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0);
1397 ve::fp_vector promotion_chances;
1398 if(state.culture_definitions.promotion_chance_fn == 0)
1399 promotion_chances = trigger::evaluate_additive_modifier(state, state.culture_definitions.promotion_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0);
1400 ve::fp_vector demotion_chances;
1401 if(state.culture_definitions.demotion_chance_fn == 0)
1402 demotion_chances = trigger::evaluate_additive_modifier(state, state.culture_definitions.demotion_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0);
1405 [&](dcon::pop_id p, dcon::nation_id owner, float promotion_chance, float demotion_chance) {
1426 auto loc = state.world.pop_get_province_from_pop_location(p);
1427 auto si = state.world.province_get_state_membership(loc);
1428 auto nf = state.world.state_instance_get_owner_focus(si);
1429 auto promoted_type = state.world.national_focus_get_promotion_type(nf);
1430 auto promotion_bonus = state.world.national_focus_get_promotion_amount(nf);
1431 auto ptype = state.world.pop_get_poptype(p);
1432 auto strata = state.world.pop_type_get_strata(ptype);
1435 using ftypeb = float(*)(int32_t);
1436 if(state.culture_definitions.promotion_chance_fn) {
1437 ftypeb fn = (ftypeb)(state.culture_definitions.promotion_chance_fn);
1438 float llvm_result = fn(p.index());
1439#ifdef CHECK_LLVM_RESULTS
1440 assert(llvm_result == promotion_chance);
1442 promotion_chance = llvm_result;
1444 if(state.culture_definitions.demotion_chance_fn) {
1445 ftypeb fn = (ftypeb)(state.culture_definitions.demotion_chance_fn);
1446 float llvm_result = fn(p.index());
1447#ifdef CHECK_LLVM_RESULTS
1448 assert(llvm_result == demotion_chance);
1450 demotion_chance = llvm_result;
1454 if(promoted_type == ptype) {
1455 promotion_chance = 0.0f;
1456 } else if(state.world.pop_type_get_strata(promoted_type) >= strata) {
1457 promotion_chance += promotion_bonus;
1458 } else if(state.world.pop_type_get_strata(promoted_type) <= strata) {
1459 demotion_chance += promotion_bonus;
1463 if(promotion_chance <= 0.0f && demotion_chance <= 0.0f)
1466 float current_size = state.world.pop_get_size(p);
1468 bool promoting = promotion_chance >= demotion_chance;
1469 float base_amount = promoting
1470 ? (std::ceil(promotion_chance * state.world.nation_get_administrative_efficiency(owner) * state.defines.promotion_scale * current_size))
1471 : (std::ceil(demotion_chance * state.defines.promotion_scale * current_size));
1474 if(ptype == state.culture_definitions.artisans) {
1475 base_amount *= 10.f;
1481 if(base_amount >= 0.001f) {
1482 auto transfer_amount = std::min(current_size, base_amount);
1483 pbuf.amounts.set(p, transfer_amount);
1486 tagged_vector<float, dcon::pop_type_id> weights(state.world.pop_type_size());
1501 bool is_state_capital = state.world.state_instance_get_capital(state.world.province_get_state_membership(loc)) == loc;
1503 if((promoting && promoted_type && state.world.pop_type_get_strata(promoted_type) >= strata && (is_state_capital || state.world.pop_type_get_state_capital_only(promoted_type) == false))
1504 || (!promoting && promoted_type && state.world.pop_type_get_strata(promoted_type) <= strata && (is_state_capital || state.world.pop_type_get_state_capital_only(promoted_type) == false))) {
1506 float chance = 0.0f;
1507 if(auto mfn = state.world.pop_type_get_promotion_fns(ptype, promoted_type); mfn != 0) {
1508 using ftype = float(*)(int32_t);
1509 ftype fn = (ftype)mfn;
1510 float llvm_result = fn(p.index());
1511#ifdef CHECK_LLVM_RESULTS
1512 float interp_result = 0.0f;
1513 if(auto mtrigger = state.world.pop_type_get_promotion(ptype, promoted_type); mtrigger) {
1514 interp_result = trigger::evaluate_additive_modifier(state, mtrigger, trigger::to_generic(p), trigger::to_generic(p), 0);
1516 assert(llvm_result == interp_result);
1518 chance = llvm_result + promotion_bonus;
1520 if(auto mtrigger = state.world.pop_type_get_promotion(ptype, promoted_type); mtrigger) {
1521 chance = trigger::evaluate_additive_modifier(state, mtrigger, trigger::to_generic(p), trigger::to_generic(p), 0) + promotion_bonus;
1526 pbuf.types.set(p, promoted_type);
1531 float chances_total = 0.0f;
1532 state.world.for_each_pop_type([&](dcon::pop_type_id target_type) {
1533 if(target_type == ptype) {
1534 weights[target_type] = 0.0f;
1535 } else if(!is_state_capital && state.world.pop_type_get_state_capital_only(target_type)) {
1536 weights[target_type] = 0.0f;
1537 } else if((promoting && state.world.pop_type_get_strata(promoted_type) >= strata)
1538 || (!promoting && state.world.pop_type_get_strata(promoted_type) <= strata) ) {
1540 weights[target_type] = 0.0f;
1542 if(auto mfn = state.world.pop_type_get_promotion_fns(ptype, target_type); mfn != 0) {
1543 using ftype = float(*)(int32_t);
1544 ftype fn = (ftype)mfn;
1545 float llvm_result = fn(p.index());
1546#ifdef CHECK_LLVM_RESULTS
1547 float interp_result = 0.0f;
1548 if(auto mtrigger = state.world.pop_type_get_promotion(ptype, target_type); mtrigger) {
1549 interp_result = trigger::evaluate_additive_modifier(state, mtrigger, trigger::to_generic(p), trigger::to_generic(p), 0);
1551 assert(llvm_result == interp_result);
1553 auto chance = llvm_result + (target_type == promoted_type ? promotion_bonus : 0.0f);
1554 chances_total += chance;
1555 weights[target_type] = chance;
1557 if(auto mtrigger = state.world.pop_type_get_promotion(ptype, target_type); mtrigger) {
1558 auto chance = trigger::evaluate_additive_modifier(state, mtrigger, trigger::to_generic(p), trigger::to_generic(p), 0) + (target_type == promoted_type ? promotion_bonus : 0.0f);
1559 chances_total += chance;
1560 weights[target_type] = chance;
1565 weights[target_type] = 0.0f;
1569 if(chances_total > 0.0f) {
1570 auto rvalue = float(rng::get_random(state, uint32_t(p.index())) & 0xFFFF) / float(0xFFFF + 1);
1571 for(uint32_t i = state.world.pop_type_size(); i-- > 0;) {
1572 dcon::pop_type_id pr{dcon::pop_type_id::value_base_t(i)};
1573 rvalue -= weights[pr] / chances_total;
1575 pbuf.types.set(p, pr);
1579 pbuf.amounts.set(p, 0.0f);
1580 pbuf.types.set(p, dcon::pop_type_id{});
1582 pbuf.amounts.set(p, 0.0f);
1583 pbuf.types.set(p, dcon::pop_type_id{});
1586 ids, owners, promotion_chances, demotion_chances);
1591 float total_effective_change = .0f;
1593 for(
auto prov : state.world.nation_get_province_ownership(nation)) {
1594 for(
auto pop : prov.get_province().get_pop_location()) {
1600 auto owner = nation;
1602 auto p = pop.get_pop();
1604 auto loc = state.world.pop_get_province_from_pop_location(pop.get_pop());
1605 auto si = state.world.province_get_state_membership(loc);
1606 auto nf = state.world.state_instance_get_owner_focus(si);
1607 auto promoted_type = state.world.national_focus_get_promotion_type(nf);
1608 auto promotion_bonus = state.world.national_focus_get_promotion_amount(nf);
1609 auto ptype = state.world.pop_get_poptype(pop.get_pop());
1610 auto strata = state.world.pop_type_get_strata(ptype);
1613 if(promoted_type == ptype) {
1614 promotion_chance = 0.0f;
1615 }
else if(state.world.pop_type_get_strata(promoted_type) >= strata) {
1616 promotion_chance += promotion_bonus;
1617 }
else if(state.world.pop_type_get_strata(promoted_type) <= strata) {
1618 demotion_chance += promotion_bonus;
1622 if(promotion_chance <= 0.0f && demotion_chance <= 0.0f)
1625 float current_size = state.world.pop_get_size(p);
1627 bool promoting = promotion_chance >= demotion_chance;
1628 float base_amount = promoting
1629 ? (std::ceil(promotion_chance * state.world.nation_get_administrative_efficiency(nation) * state.defines.promotion_scale * current_size))
1630 : (std::ceil(demotion_chance * state.defines.promotion_scale * current_size));
1632 auto transfer_amount = base_amount >= 0.001f ? std::min(current_size, base_amount) : 0.0f;
1636 bool is_state_capital = state.world.state_instance_get_capital(state.world.province_get_state_membership(loc)) == loc;
1638 if(promoted_type == target_type) {
1639 if(promoting && promoted_type && state.world.pop_type_get_strata(promoted_type) >= strata &&
1640 (is_state_capital || state.world.pop_type_get_state_capital_only(promoted_type) ==
false)) {
1641 auto promote_mod = state.world.pop_type_get_promotion(ptype, promoted_type);
1647 total_effective_change += transfer_amount;
1651 }
else if(!promoting && promoted_type && state.world.pop_type_get_strata(promoted_type) <= strata &&
1652 (is_state_capital || state.world.pop_type_get_state_capital_only(promoted_type) ==
false)) {
1653 auto promote_mod = state.world.pop_type_get_promotion(ptype, promoted_type);
1659 total_effective_change += transfer_amount;
1666 float chances_total = 0.0f;
1668 state.world.for_each_pop_type([&](dcon::pop_type_id t_type) {
1669 if(t_type == ptype) {
1670 weights[t_type] = 0.0f;
1671 }
else if(!is_state_capital && state.world.pop_type_get_state_capital_only(t_type)) {
1672 weights[t_type] = 0.0f;
1673 }
else if(promoting && state.world.pop_type_get_strata(promoted_type) >= strata) {
1674 auto promote_mod = state.world.pop_type_get_promotion(ptype, t_type);
1676 auto chance = std::max(trigger::evaluate_additive_modifier(state, promote_mod, trigger::to_generic(p),
1677 trigger::to_generic(p), 0) +
1678 (t_type == promoted_type ? promotion_bonus : 0.0f),
1680 chances_total += chance;
1681 weights[t_type] = chance;
1683 weights[t_type] = 0.0f;
1685 }
else if(!promoting && state.world.pop_type_get_strata(promoted_type) <= strata) {
1686 auto promote_mod = state.world.pop_type_get_promotion(ptype, t_type);
1688 auto chance = std::max(trigger::evaluate_additive_modifier(state, promote_mod, trigger::to_generic(p),
1689 trigger::to_generic(p), 0) +
1690 (t_type == promoted_type ? promotion_bonus : 0.0f),
1692 chances_total += chance;
1693 weights[t_type] = chance;
1695 weights[t_type] = 0.0f;
1698 weights[t_type] = 0.0f;
1702 if(chances_total > 0.0f) {
1703 total_effective_change += transfer_amount * weights[target_type]/chances_total;
1709 for(
auto prov :
state.world.nation_get_province_ownership(nation)) {
1710 for(
auto pop :
prov.get_province().get_pop_location()) {
1711 if(
pop.get_pop().get_poptype() == target_type) {
1718 return total_effective_change;
1728 auto loc = state.world.pop_get_province_from_pop_location(ids);
1729 auto si = state.world.province_get_state_membership(loc);
1730 auto nf = state.world.state_instance_get_owner_focus(si);
1731 auto promoted_type = state.world.national_focus_get_promotion_type(nf);
1732 auto promotion_bonus = state.world.national_focus_get_promotion_amount(nf);
1733 auto ptype = state.world.pop_get_poptype(ids);
1734 auto strata = state.world.pop_type_get_strata(ptype);
1737 if(promoted_type == ptype) {
1738 promotion_chance = 0.0f;
1739 }
else if(state.world.pop_type_get_strata(promoted_type) >= strata) {
1740 promotion_chance += promotion_bonus;
1741 }
else if(state.world.pop_type_get_strata(promoted_type) <= strata) {
1742 demotion_chance += promotion_bonus;
1746 if(promotion_chance <= 0.0f && demotion_chance <= 0.0f)
1749 float current_size = state.world.pop_get_size(ids);
1751 bool promoting = promotion_chance >= demotion_chance;
1752 return std::min(current_size, promoting
1753 ? (std::ceil(promotion_chance * state.world.nation_get_administrative_efficiency(owner) *
1754 state.defines.promotion_scale * current_size))
1755 : (std::ceil(demotion_chance * state.defines.promotion_scale * current_size)));
1765 auto loc = state.world.pop_get_province_from_pop_location(ids);
1766 auto si = state.world.province_get_state_membership(loc);
1767 auto nf = state.world.state_instance_get_owner_focus(si);
1768 auto promoted_type = state.world.national_focus_get_promotion_type(nf);
1769 auto promotion_bonus = state.world.national_focus_get_promotion_amount(nf);
1770 auto ptype = state.world.pop_get_poptype(ids);
1771 auto strata = state.world.pop_type_get_strata(ptype);
1774 if(promoted_type == ptype) {
1775 promotion_chance = 0.0f;
1776 }
else if(state.world.pop_type_get_strata(promoted_type) >= strata) {
1777 promotion_chance += promotion_bonus;
1778 }
else if(state.world.pop_type_get_strata(promoted_type) <= strata) {
1779 demotion_chance += promotion_bonus;
1783 if(promotion_chance <= 0.0f && demotion_chance <= 0.0f)
1786 float current_size = state.world.pop_get_size(ids);
1788 bool promoting = promotion_chance >= demotion_chance;
1789 return std::min(current_size, promoting
1790 ? (std::ceil(promotion_chance * state.world.nation_get_administrative_efficiency(owner) *
1791 state.defines.promotion_scale * current_size))
1801 auto loc = state.world.pop_get_province_from_pop_location(ids);
1802 auto si = state.world.province_get_state_membership(loc);
1803 auto nf = state.world.state_instance_get_owner_focus(si);
1804 auto promoted_type = state.world.national_focus_get_promotion_type(nf);
1805 auto promotion_bonus = state.world.national_focus_get_promotion_amount(nf);
1806 auto ptype = state.world.pop_get_poptype(ids);
1807 auto strata = state.world.pop_type_get_strata(ptype);
1810 if(promoted_type == ptype) {
1811 promotion_chance = 0.0f;
1812 }
else if(state.world.pop_type_get_strata(promoted_type) >= strata) {
1813 promotion_chance += promotion_bonus;
1814 }
else if(state.world.pop_type_get_strata(promoted_type) <= strata) {
1815 demotion_chance += promotion_bonus;
1819 if(promotion_chance <= 0.0f && demotion_chance <= 0.0f)
1822 float current_size = state.world.pop_get_size(ids);
1824 bool promoting = promotion_chance >= demotion_chance;
1825 return std::min(current_size, promoting
1827 : (std::ceil(demotion_chance * state.defines.promotion_scale * current_size)));
1831 pbuf.
update(state.world.pop_size());
1840 pbuf.amounts.set(ids, 0.0f);
1841 auto loc = state.world.pop_get_province_from_pop_location(ids);
1842 auto owners = state.world.province_get_nation_from_province_ownership(loc);
1843 auto assimilation_chances = ve::max(trigger::evaluate_additive_modifier(state, state.culture_definitions.assimilation_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0), 0.0f);
1846 [&](dcon::pop_id p, dcon::province_id location, dcon::nation_id owner, float assimilation_chance) {
1852 if(state.world.pop_get_poptype(p) == state.culture_definitions.slaves)
1856 if(state.world.pop_get_is_primary_or_accepted_culture(p))
1860 if(state.world.province_get_is_colonial(location) && province::is_overseas(state, location))
1863 if(state.world.province_get_dominant_culture(location) == state.world.pop_get_culture(p))
1872 float current_size = state.world.pop_get_size(p);
1874 state.defines.assimilation_scale *
1875 std::max(0.0f, (state.world.province_get_modifier_values(location, sys::provincial_mod_offsets::assimilation_rate) + 1.0f)) *
1876 std::max(0.0f, (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::global_assimilation_rate) + 1.0f)) *
1877 assimilation_chance * current_size;
1885 auto pc = state.world.pop_get_culture(p);
1887 if(!state.world.culture_group_get_is_overseas(state.world.culture_get_group_from_culture_group_membership(pc))) {
1888 base_amount /= 10.0f;
1896 for(auto core : state.world.province_get_core(location)) {
1897 if(core.get_identity().get_primary_culture() == pc) {
1898 base_amount /= 100.0f;
1908 if(base_amount >= 0.001f) {
1909 auto transfer_amount = std::min(current_size, std::ceil(base_amount));
1910 pbuf.amounts.set(p, transfer_amount);
1913 ids, loc, owners, assimilation_chances);
1918 auto location = state.world.pop_get_province_from_pop_location(ids);
1919 auto owner = state.world.province_get_nation_from_province_ownership(location);
1923 if(state.world.pop_get_poptype(ids) == state.culture_definitions.slaves)
1927 if(state.world.pop_get_is_primary_or_accepted_culture(ids))
1934 float current_size = state.world.pop_get_size(ids);
1936 state.defines.assimilation_scale *
1937 std::max(0.0f, (state.world.province_get_modifier_values(location, sys::provincial_mod_offsets::assimilation_rate) + 1.0f)) *
1938 std::max(0.0f, (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::global_assimilation_rate) + 1.0f)) *
1939 assimilation_chances * current_size;
1947 auto pc = state.world.pop_get_culture(ids);
1948 if(!state.world.culture_group_get_is_overseas(state.world.culture_get_group_from_culture_group_membership(pc))) {
1949 base_amount /= 10.0f;
1958 for(
auto core : state.world.province_get_core(location)) {
1959 if(core.get_identity().get_primary_culture() == pc) {
1960 base_amount /= 100.0f;
1970 if(base_amount >= 0.001f) {
1971 return std::min(current_size, std::ceil(base_amount));
1978 pbuf.
update(state.world.pop_size());
1985 pbuf.amounts.set(ids, 0.0f);
1986 auto loc = state.world.pop_get_province_from_pop_location(ids);
1987 auto owners = state.world.province_get_nation_from_province_ownership(loc);
1988 auto conversion_chances = ve::max(trigger::evaluate_additive_modifier(state, state.culture_definitions.conversion_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0), 0.0f);
1991 [&](dcon::pop_id p, dcon::province_id location, dcon::nation_id owner, float conversion_chance) {
1996 auto state_religion = state.world.nation_get_religion(owner);
1998 if(state_religion == state.world.pop_get_religion(p))
2002 if(state.world.province_get_demographics(location, demographics::to_key(state, state_religion.id)) < 1.f)
2011 float current_size = state.world.pop_get_size(p);
2013 state.defines.conversion_scale *
2014 std::max(0.0f, (state.world.province_get_modifier_values(location, sys::provincial_mod_offsets::conversion_rate) + 1.0f)) *
2015 std::max(0.0f, (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::global_conversion_rate) + 1.0f)) *
2016 conversion_chance * current_size;
2018 if(base_amount >= 0.001f) {
2019 auto transfer_amount = std::min(current_size, std::ceil(base_amount));
2020 pbuf.amounts.set(p, transfer_amount);
2023 ids, loc, owners, conversion_chances);
2028 auto location = state.world.pop_get_province_from_pop_location(ids);
2029 auto owner = state.world.province_get_nation_from_province_ownership(location);
2033 if(state.world.nation_get_religion(owner) == state.world.pop_get_religion(ids))
2036 auto state_religion = state.world.nation_get_religion(owner);
2038 if(state_religion == state.world.pop_get_religion(ids))
2042 if(state.world.province_get_demographics(location,
demographics::to_key(state, state_religion.id)) < 1.f)
2045 float current_size = state.world.pop_get_size(ids);
2047 state.defines.conversion_scale *
2048 std::max(0.0f, (state.world.province_get_modifier_values(location, sys::provincial_mod_offsets::conversion_rate) + 1.0f)) *
2049 std::max(0.0f, (state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::global_conversion_rate) + 1.0f)) *
2050 conversion_chances * current_size;
2052 if(base_amount >= 0.001f) {
2053 return std::min(current_size, std::ceil(base_amount));
2069 auto weights_buffer = state.world.province_make_vectorizable_float_buffer();
2070 float total_weight = 0.0f;
2072 auto pt = state.world.pop_get_poptype(p);
2073 auto modifier = state.world.pop_type_get_migration_target(pt);
2074 auto modifier_fn = state.world.pop_type_get_migration_target_fn(pt);
2076 return dcon::province_id{};
2078 bool limit_to_capitals = state.world.pop_type_get_state_capital_only(pt);
2079 for(
auto loc : state.world.nation_get_province_ownership(n)) {
2080 if(loc.get_province().get_is_colonial() ==
false) {
2081 if(!limit_to_capitals || loc.get_province().get_state_membership().get_capital().id == loc.get_province().id) {
2082 float weight = 0.0f;
2084 using ftype = float(*)(int32_t, int32_t);
2085 ftype fn = (ftype)modifier_fn;
2086 float llvm_result = fn(loc.get_province().id.index(), p.index());
2087#ifdef CHECK_LLVM_RESULTS
2089 assert(llvm_result == interp_result);
2091 weight = llvm_result * (loc.get_province().get_modifier_values(sys::provincial_mod_offsets::immigrant_attract) + 1.0f);
2094 weight = interp_result * (loc.get_province().get_modifier_values(sys::provincial_mod_offsets::immigrant_attract) + 1.0f);
2098 weights_buffer.set(loc.get_province(), weight);
2099 total_weight += weight;
2105 if(total_weight <= 0.0f)
2106 return dcon::province_id{};
2109 for(
auto loc : state.world.nation_get_province_ownership(n)) {
2110 rvalue -= weights_buffer.get(loc.get_province()) / total_weight;
2112 return loc.get_province();
2116 return dcon::province_id{};
2124 auto weights_buffer = state.world.province_make_vectorizable_float_buffer();
2125 float total_weight = 0.0f;
2127 auto modifier = state.world.pop_type_get_migration_target(state.world.pop_get_poptype(p));
2128 auto modifier_fn = state.world.pop_type_get_migration_target_fn(state.world.pop_get_poptype(p));
2130 return dcon::province_id{};
2132 auto overseas_culture = state.world.culture_get_group_from_culture_group_membership(state.world.pop_get_culture(p));
2133 auto home_continent = state.world.province_get_continent(state.world.pop_get_province_from_pop_location(p));
2135 bool limit_to_capitals = state.world.pop_type_get_state_capital_only(state.world.pop_get_poptype(p));
2136 for(
auto loc : state.world.nation_get_province_ownership(n)) {
2137 if(loc.get_province().get_is_colonial() ==
true) {
2138 if((overseas_culture || loc.get_province().get_continent() == home_continent) &&
2139 (!limit_to_capitals || loc.get_province().get_state_membership().get_capital().id == loc.get_province().id)) {
2141 float weight = 0.0f;
2143 using ftype = float(*)(int32_t, int32_t);
2144 ftype fn = (ftype)modifier_fn;
2145 float llvm_result = fn(loc.get_province().id.index(), p.index());
2146#ifdef CHECK_LLVM_RESULTS
2148 assert(llvm_result == interp_result);
2150 weight = llvm_result * (loc.get_province().get_modifier_values(sys::provincial_mod_offsets::immigrant_attract) + 1.0f);
2153 weight = interp_result * (loc.get_province().get_modifier_values(sys::provincial_mod_offsets::immigrant_attract) + 1.0f);
2157 if(!limit_to_capitals || loc.get_province().get_state_membership().get_capital().id == loc.get_province().id) {
2158 weights_buffer.set(loc.get_province(), weight);
2159 total_weight += weight;
2166 if(total_weight <= 0.0f)
2167 return dcon::province_id{};
2170 for(
auto loc : state.world.nation_get_province_ownership(n)) {
2171 rvalue -= weights_buffer.get(loc.get_province()) / total_weight;
2173 return loc.get_province();
2177 return dcon::province_id{};
2192 auto pt = state.world.pop_get_poptype(p);
2193 auto modifier = state.world.pop_type_get_country_migration_target(pt);
2194 auto modifier_fn = state.world.pop_type_get_country_migration_target_fn(pt);
2196 return dcon::nation_id{};
2198 dcon::nation_id top_nations[3] = {dcon::nation_id{}, dcon::nation_id{}, dcon::nation_id{}};
2199 float top_weights[3] = {0.0f, 0.0f, 0.0f};
2201 auto home_continent = state.world.province_get_continent(state.world.pop_get_province_from_pop_location(p));
2203 state.world.for_each_nation([&](dcon::nation_id inner) {
2204 if(state.world.nation_get_owned_province_count(inner) == 0)
2206 if(state.world.nation_get_is_civilized(inner) ==
false)
2210 if(state.world.province_get_continent(state.world.nation_get_capital(inner)) == home_continent &&
2211 !state.world.get_nation_adjacency_by_nation_adjacency_pair(owner, inner)) {
2215 float weight = 0.0f;
2217 using ftype = float(*)(int32_t, int32_t);
2218 ftype fn = (ftype)modifier_fn;
2219 float llvm_result = fn(inner.index(), p.index());
2220#ifdef CHECK_LLVM_RESULTS
2221 float interp_result = trigger::evaluate_multiplicative_modifier(state, modifier, trigger::to_generic(inner), trigger::to_generic(p), 0);
2222 assert( llvm_result == interp_result);
2224 weight = llvm_result * std::max(0.0f, (state.world.nation_get_modifier_values(inner, sys::national_mod_offsets::global_immigrant_attract) + 1.0f));
2226 float interp_result = trigger::evaluate_multiplicative_modifier(state, modifier, trigger::to_generic(inner), trigger::to_generic(p), 0);
2227 weight = interp_result * std::max(0.0f, (state.world.nation_get_modifier_values(inner, sys::national_mod_offsets::global_immigrant_attract) + 1.0f));
2230 if(weight > top_weights[2]) {
2231 top_weights[2] = weight;
2232 top_nations[2] = inner;
2233 if(top_weights[2] > top_weights[1]) {
2234 std::swap(top_weights[1], top_weights[2]);
2235 std::swap(top_nations[1], top_nations[2]);
2237 if(top_weights[1] > top_weights[0]) {
2238 std::swap(top_weights[1], top_weights[0]);
2239 std::swap(top_nations[1], top_nations[0]);
2244 float total_weight = top_weights[0] + top_weights[1] + top_weights[2];
2245 if(total_weight <= 0.0f)
2246 return dcon::nation_id{};
2250 rvalue -= top_weights[i] / total_weight;
2252 return top_nations[i];
2256 return dcon::nation_id{};
2262 pbuf.
update(state.world.pop_size());
2265 pbuf.amounts.set(ids, 0.0f);
2272 auto loc = state.world.pop_get_province_from_pop_location(ids);
2273 auto owners = state.world.province_get_nation_from_province_ownership(loc);
2274 auto pop_sizes = state.world.pop_get_size(ids);
2275 auto amounts = ve::max(trigger::evaluate_additive_modifier(state, state.culture_definitions.migration_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0), 0.0f) * pop_sizes * ve::max((state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::immigrant_push) + 1.0f), 0.0f) * state.defines.immigration_scale;
2278 [&](dcon::pop_id p, dcon::province_id location, dcon::nation_id owner, float amount, float pop_size) {
2283 if(state.world.province_get_is_colonial(location))
2285 if(state.world.pop_get_poptype(p) == state.culture_definitions.slaves)
2288 auto dest = impl::get_province_target_in_nation(state, owner, p);
2293 pbuf.amounts.set(p, std::min(pop_size, std::ceil(amount)));
2295 pbuf.destinations.set(p, dest);
2297 ids, loc, owners, amounts, pop_sizes);
2303 auto loc = state.world.pop_get_province_from_pop_location(ids);
2305 if(state.world.province_get_is_colonial(loc))
2307 if(state.world.pop_get_poptype(ids) == state.culture_definitions.slaves)
2310 auto owners = state.world.province_get_nation_from_province_ownership(loc);
2311 auto pop_sizes = state.world.pop_get_size(ids);
2313 trigger::to_generic(ids),
trigger::to_generic(ids), 0), 0.0f) * pop_sizes * std::max(0.0f, (state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::immigrant_push) + 1.0f)) * state.defines.immigration_scale;
2319 auto pop_size = state.world.pop_get_size(ids);
2320 return std::min(pop_size, std::ceil(amount));
2324 pbuf.
update(state.world.pop_size());
2327 pbuf.amounts.set(ids, 0.0f);
2336 auto loc = state.world.pop_get_province_from_pop_location(ids);
2337 auto owners = state.world.province_get_nation_from_province_ownership(loc);
2338 auto pop_sizes = state.world.pop_get_size(ids);
2339 auto amounts = ve::max(trigger::evaluate_additive_modifier(state, state.culture_definitions.colonialmigration_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0), 0.0f) *
2341 ve::max((state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::immigrant_push) + 1.0f), 0.0f) *
2342 ve::max((state.world.nation_get_modifier_values(owners, sys::national_mod_offsets::colonial_migration) + 1.0f), 0.0f) *
2343 state.defines.immigration_scale;
2346 [&](dcon::pop_id p, dcon::province_id location, dcon::nation_id owner, float amount, float pop_size) {
2351 if(state.world.nation_get_is_colonial_nation(owner) == false)
2353 auto pt = state.world.pop_get_poptype(p);
2354 if(state.world.pop_type_get_strata(pt) == uint8_t(culture::pop_strata::rich))
2356 if(state.world.province_get_is_colonial(location))
2358 if(pt == state.culture_definitions.slaves || pt == state.culture_definitions.primary_factory_worker ||
2359 pt == state.culture_definitions.secondary_factory_worker)
2365 pbuf.amounts.set(p, std::min(pop_size, std::ceil(amount)));
2368 auto dest = impl::get_colonial_province_target_in_nation(state, owner, p);
2369 pbuf.destinations.set(p, dest);
2371 ids, loc, owners, amounts, pop_sizes);
2376 auto loc = state.world.pop_get_province_from_pop_location(ids);
2377 auto owner = state.world.province_get_nation_from_province_ownership(loc);
2379 if(state.world.nation_get_is_colonial_nation(owner) ==
false)
2381 auto pt = state.world.pop_get_poptype(ids);
2384 if(state.world.province_get_is_colonial(loc))
2386 if(pt == state.culture_definitions.slaves || pt == state.culture_definitions.primary_factory_worker ||
2387 pt == state.culture_definitions.secondary_factory_worker)
2391 auto pop_sizes = state.world.pop_get_size(ids);
2395 * std::max((state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::immigrant_push) + 1.0f), 0.0f)
2396 * std::max((state.world.nation_get_modifier_values(owner, sys::national_mod_offsets::colonial_migration) + 1.0f), 0.0f)
2397 * state.defines.immigration_scale;
2402 auto pop_size = state.world.pop_get_size(ids);
2403 return std::min(pop_size, std::ceil(amounts));
2407 pbuf.
update(state.world.pop_size());
2410 pbuf.amounts.set(ids, 0.0f);
2419 auto loc = state.world.pop_get_province_from_pop_location(ids);
2420 auto owners = state.world.province_get_nation_from_province_ownership(loc);
2421 auto pop_sizes = state.world.pop_get_size(ids);
2422 auto impush = (state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::immigrant_push) + 1.0f);
2423 auto trigger_amount = ve::max(trigger::evaluate_additive_modifier(state, state.culture_definitions.emigration_chance, trigger::to_generic(ids), trigger::to_generic(ids), 0), 0.0f);
2424 auto amounts = trigger_amount
2426 * ve::max(impush, 0.0f)
2427 * ve::max(impush, 1.0f)
2428 * state.defines.immigration_scale;
2431 [&](dcon::pop_id p, dcon::province_id location, dcon::nation_id owner, float amount, float pop_size) {
2437 if(state.world.nation_get_is_civilized(owner) == false)
2439 if(state.world.province_get_is_colonial(location))
2441 if(state.world.pop_get_poptype(p) == state.culture_definitions.slaves)
2443 if(state.world.culture_group_get_is_overseas(
2444 state.world.culture_get_group_from_culture_group_membership(state.world.pop_get_culture(p))) == false) {
2451 pbuf.amounts.set(p, std::min(pop_size, std::ceil(amount)));
2454 auto ndest = impl::get_immigration_target(state, owner, p, state.current_date);
2455 auto dest = impl::get_province_target_in_nation(state, ndest, p);
2457 pbuf.destinations.set(p, dest);
2459 ids, loc, owners, amounts, pop_sizes);
2464 auto sz = state.world.nation_size();
2465 national_amounts.resize(sz);
2466 for(
auto& v : national_amounts) {
2470 auto ymd_date = state.current_date.to_ymd(state.start_date);
2475 for(
auto ids : state.world.in_pop) {
2476 auto loc = state.world.pop_get_province_from_pop_location(ids);
2477 auto owners = state.world.province_get_nation_from_province_ownership(loc);
2479 auto section =
uint64_t(ids.id.index()) / 16;
2480 auto tranche = int32_t(section / days_in_month);
2481 auto day_of_month = tranche - 10;
2482 if(day_of_month <= 0)
2483 day_of_month += days_in_month;
2484 int32_t day_adjustment = day_of_month - int32_t(ymd_date.day);
2486 if(est_amount > 0.0f) {
2487 auto target = impl::get_immigration_target(state, owners, ids, state.current_date + day_adjustment);
2489 if(target &&
uint32_t(target.index()) < sz) {
2490 national_amounts[
uint32_t(target.index())] -= est_amount;
2492 }
else if(target == n) {
2493 if(
uint32_t(owners.index()) < sz) {
2494 national_amounts[
uint32_t(owners.index())] += est_amount;
2503 auto loc = state.world.pop_get_province_from_pop_location(ids);
2504 auto owners = state.world.province_get_nation_from_province_ownership(loc);
2506 if(state.world.nation_get_is_civilized(owners) ==
false)
2508 if(state.world.province_get_is_colonial(loc))
2510 if(state.world.pop_get_poptype(ids) == state.culture_definitions.slaves)
2512 if(state.world.culture_group_get_is_overseas(
2513 state.world.culture_get_group_from_culture_group_membership(state.world.pop_get_culture(ids))) ==
false) {
2517 auto pop_sizes = state.world.pop_get_size(ids);
2518 auto impush = (state.world.province_get_modifier_values(loc, sys::provincial_mod_offsets::immigrant_push) + 1.0f);
2520 auto amounts = trigger_result * pop_sizes * std::max(impush, 0.0f) * std::max(impush, 1.0f) * state.defines.immigration_scale;
2525 return std::min(pop_sizes, std::ceil(amounts));
2530 dcon::pop_type_id ptid,
float l) {
2531 bool is_mine = state.world.commodity_get_is_mine(state.world.province_get_rgo(loc));
2532 if(is_mine && ptid == state.culture_definitions.farmers) {
2533 ptid = state.culture_definitions.laborers;
2534 }
else if(!is_mine && ptid == state.culture_definitions.laborers) {
2535 ptid = state.culture_definitions.farmers;
2538 for(
auto pl : state.world.province_get_pop_location(loc)) {
2539 if(pl.get_pop().get_culture() == cid && pl.get_pop().get_religion() == rid && pl.get_pop().get_poptype() == ptid) {
2540 return pl.get_pop();
2543 auto np = fatten(state.world, state.world.create_pop());
2544 state.world.force_create_pop_location(np, loc);
2545 np.set_culture(cid);
2546 np.set_religion(rid);
2547 np.set_poptype(ptid);
2550 auto n = state.world.province_get_nation_from_province_ownership(loc);
2551 if(state.world.nation_get_primary_culture(n) == cid) {
2552 np.set_is_primary_or_accepted_culture(
true);
2554 if(state.world.nation_get_accepted_cultures(n, cid) ==
true) {
2555 np.set_is_primary_or_accepted_culture(
true);
2561 float totals = 0.0f;
2562 state.world.for_each_ideology([&](dcon::ideology_id i) {
2563 if(state.world.ideology_get_enabled(i)) {
2564 auto ptrigger = state.world.pop_type_get_ideology(ptid, i);
2565 auto const i_key = pop_demographics::to_key(state, i);
2566 auto owner = nations::owner_of_pop(state, np);
2567 if(state.world.ideology_get_is_civilized_only(i)) {
2568 if(state.world.nation_get_is_civilized(owner)) {
2569 auto amount = ptrigger ? trigger::evaluate_multiplicative_modifier(state, ptrigger, trigger::to_generic(np.id),
2570 trigger::to_generic(owner), 0) : 0.0f;
2571 state.world.pop_set_demographics(np, i_key, amount);
2575 auto amount = ptrigger ? trigger::evaluate_multiplicative_modifier(state, ptrigger, trigger::to_generic(np.id),
2576 trigger::to_generic(owner), 0) : 0.0f;
2577 state.world.pop_set_demographics(np, i_key, amount);
2583 state.world.for_each_ideology([&](dcon::ideology_id i) {
2585 state.world.pop_get_demographics(np, i_key) /= totals;
2590 float totals = 0.0f;
2591 state.world.for_each_issue_option([&](dcon::issue_option_id iid) {
2592 auto opt = fatten(state.world, iid);
2593 auto allow = opt.get_allow();
2594 auto parent_issue = opt.get_parent_issue();
2599 auto has_modifier = is_social_issue || is_political_issue;
2601 is_social_issue ? sys::national_mod_offsets::social_reform_desire : sys::national_mod_offsets::political_reform_desire;
2604 auto current_issue_setting = state.world.nation_get_issues(owner, parent_issue);
2605 auto allowed_by_owner =
2606 (state.world.nation_get_is_civilized(owner) || is_party_issue) &&
2607 (!state.world.issue_get_is_next_step_only(parent_issue) || (current_issue_setting.id.index() == iid.index()) || (current_issue_setting.id.index() == iid.index() - 1) || (current_issue_setting.id.index() == iid.index() + 1));
2608 auto owner_modifier = has_modifier ? (state.world.nation_get_modifier_values(owner, modifier_key) + 1.0f) : 1.0f;
2609 if(allowed_by_owner) {
2610 if(
auto mtrigger = state.world.pop_type_get_issues(ptid, iid); mtrigger) {
2614 state.world.pop_set_demographics(np, i_key, amount);
2620 state.world.for_each_issue_option([&](dcon::issue_option_id i) {
2622 state.world.pop_get_demographics(np, i_key) /= totals;
2633 [&](dcon::pop_id p) {
2634 if(pbuf.amounts.get(p) > 0.0f && pbuf.types.get(p)) {
2635 auto target_pop = impl::find_or_make_pop(state, state.world.pop_get_province_from_pop_location(p),
2636 state.world.pop_get_culture(p), state.world.pop_get_religion(p), pbuf.types.get(p), state.world.pop_get_literacy(p));
2637 state.world.pop_get_size(p) -= pbuf.amounts.get(p);
2638 state.world.pop_get_size(target_pop) += pbuf.amounts.get(p);
2646 if(
bool(state.defines.alice_nurture_religion_assimilation)) {
2647 auto exec_fn = [&](
auto ids) {
2648 auto locs = state.world.pop_get_province_from_pop_location(ids);
2649 ve::apply([&](dcon::pop_id p, dcon::province_id l, dcon::culture_id dac) {
2650 if(pbuf.
amounts.get(p) > 0.0f) {
2652 auto cul = dac ? dac : state.world.province_get_dominant_culture(l);
2653 auto rel = state.world.pop_get_religion(p);
2654 assert(state.world.pop_get_poptype(p));
2655 auto target_pop = impl::find_or_make_pop(state, l, cul, rel, state.world.pop_get_poptype(p), state.world.pop_get_literacy(p));
2656 state.world.pop_get_size(p) -= pbuf.amounts.get(p);
2657 state.world.pop_get_size(target_pop) += pbuf.amounts.get(p);
2660 ids, locs, state.world.province_get_dominant_accepted_culture(locs));
2664 auto exec_fn = [&](
auto ids) {
2665 auto locs = state.world.pop_get_province_from_pop_location(ids);
2666 ve::apply([&](dcon::pop_id p, dcon::province_id l, dcon::culture_id dac) {
2667 if(pbuf.
amounts.get(p) > 0.0f) {
2669 auto cul = dac ? dac : state.world.province_get_dominant_culture(l);
2671 ? state.world.nation_get_religion(nations::owner_of_pop(state, p))
2672 : state.world.province_get_dominant_religion(l);
2673 assert(state.world.pop_get_poptype(p));
2674 auto target_pop = impl::find_or_make_pop(state, l, cul, rel, state.world.pop_get_poptype(p), state.world.pop_get_literacy(p));
2675 state.world.pop_get_size(p) -= pbuf.amounts.get(p);
2676 state.world.pop_get_size(target_pop) += pbuf.amounts.get(p);
2679 ids, locs, state.world.province_get_dominant_accepted_culture(locs));
2687 auto locs = state.world.pop_get_province_from_pop_location(ids);
2689 [&](dcon::pop_id p, dcon::province_id l) {
2690 if(pbuf.amounts.get(p) > 0.0f) {
2691 auto state_rel = state.world.nation_get_religion(nations::owner_of_pop(state, p));
2692 auto rel = state_rel
2694 : state.world.province_get_dominant_religion(l);
2695 assert(state.world.pop_get_poptype(p));
2696 assert(state.world.pop_get_culture(p));
2697 auto target_pop = impl::find_or_make_pop(state, l, state.world.pop_get_culture(p), rel, state.world.pop_get_poptype(p), state.world.pop_get_literacy(p));
2698 state.world.pop_get_size(p) -= pbuf.amounts.get(p);
2699 state.world.pop_get_size(target_pop) += pbuf.amounts.get(p);
2709 [&](dcon::pop_id p) {
2710 if(pbuf.amounts.get(p) > 0.0f && pbuf.destinations.get(p)) {
2711 assert(state.world.pop_get_poptype(p));
2712 auto target_pop = impl::find_or_make_pop(state, pbuf.destinations.get(p), state.world.pop_get_culture(p),
2713 state.world.pop_get_religion(p), state.world.pop_get_poptype(p), state.world.pop_get_literacy(p));
2714 state.world.pop_get_size(p) -= pbuf.amounts.get(p);
2715 state.world.pop_get_size(target_pop) += pbuf.amounts.get(p);
2716 state.world.province_get_daily_net_migration(state.world.pop_get_province_from_pop_location(p)) -=
2717 pbuf.amounts.get(p);
2718 state.world.province_get_daily_net_migration(pbuf.destinations.get(p)) += pbuf.amounts.get(p);
2728 [&](dcon::pop_id p) {
2729 if(pbuf.amounts.get(p) > 0.0f && pbuf.destinations.get(p)) {
2730 assert(state.world.pop_get_poptype(p));
2731 auto target_pop = impl::find_or_make_pop(state, pbuf.destinations.get(p), state.world.pop_get_culture(p),
2732 state.world.pop_get_religion(p), state.world.pop_get_poptype(p), state.world.pop_get_literacy(p));
2733 state.world.pop_get_size(p) -= pbuf.amounts.get(p);
2734 state.world.pop_get_size(target_pop) += pbuf.amounts.get(p);
2735 state.world.province_get_daily_net_migration(state.world.pop_get_province_from_pop_location(p)) -=
2736 pbuf.amounts.get(p);
2737 state.world.province_get_daily_net_migration(pbuf.destinations.get(p)) += pbuf.amounts.get(p);
2747 [&](dcon::pop_id p) {
2748 auto amount = pbuf.amounts.get(p);
2749 if(amount > 0.0f && pbuf.destinations.get(p)) {
2750 assert(state.world.pop_get_poptype(p));
2751 auto target_pop = impl::find_or_make_pop(state, pbuf.destinations.get(p), state.world.pop_get_culture(p),
2752 state.world.pop_get_religion(p), state.world.pop_get_poptype(p), state.world.pop_get_literacy(p));
2754 state.world.pop_get_size(p) -= amount;
2755 state.world.pop_get_size(target_pop) += amount;
2756 state.world.province_get_daily_net_immigration(state.world.pop_get_province_from_pop_location(p)) -= amount;
2757 state.world.province_get_daily_net_immigration(pbuf.destinations.get(p)) += amount;
2758 state.world.province_set_last_immigration(pbuf.destinations.get(p), state.current_date);
2767 for(
auto last = state.world.pop_size(); last-- > 0;) {
2768 dcon::pop_id m{dcon::pop_id::value_base_t(last)};
2769 if(state.world.pop_get_size(m) < 1.0f) {
2770 state.world.delete_pop(m);
2777 for(
auto last = state.world.pop_size(); last-- > 0;) {
2778 dcon::pop_id m{ dcon::pop_id::value_base_t(last) };
2779 if(state.world.pop_get_size(m) < 20.0f) {
2780 state.world.delete_pop(m);
2803 auto poor_score = (pln + pen + plun) / pp;
2804 auto middle_score = (mln + men + mlun) / mp;
2805 auto rich_score = (rln + ren + rlun) / rp;
2807 auto finalscore = (poor_score * pp + middle_score * mp + rich_score * rp) * 33 / p;
2813 if(state.world.pop_get_size(pop_id) >= amount) {
2814 state.world.pop_get_size(pop_id) -= amount;
2816 state.world.pop_get_size(pop_id) = 0;
#define assert(condition)
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
dcon::province_id get_province_target_in_nation(sys::state &state, dcon::nation_id n, dcon::pop_id p)
dcon::nation_id get_immigration_target(sys::state &state, dcon::nation_id owner, dcon::pop_id p, sys::date day)
dcon::pop_id find_or_make_pop(sys::state &state, dcon::province_id loc, dcon::culture_id cid, dcon::religion_id rid, dcon::pop_type_id ptid, float l)
dcon::province_id get_colonial_province_target_in_nation(sys::state &state, dcon::nation_id n, dcon::pop_id p)
float get_effective_estimation_type_change(sys::state &state, dcon::nation_id nation, dcon::pop_type_id target_type)
constexpr dcon::demographics_key rich_life_needs(13)
constexpr dcon::demographics_key poor_luxury_needs(17)
constexpr dcon::demographics_key middle_life_needs(12)
float get_estimated_colonial_migration(sys::state &state, dcon::pop_id ids)
void estimate_directed_immigration(sys::state &state, dcon::nation_id n, std::vector< float > &national_amounts)
float get_estimated_literacy_change(sys::state &state, dcon::pop_id ids)
void sum_over_demographics(sys::state &state, dcon::demographics_key key, F const &source)
constexpr dcon::demographics_key middle_total(21)
constexpr dcon::demographics_key middle_luxury_needs(18)
float get_estimated_type_change(sys::state &state, dcon::pop_id ids)
float calculate_nation_sol(sys::state &state, dcon::nation_id nation_id)
void remove_small_pops(sys::state &state)
void regenerate_jingoism_support(sys::state &state, dcon::nation_id n)
void update_immigration(sys::state &state, uint32_t offset, uint32_t divisions, migration_buffer &pbuf)
constexpr dcon::demographics_key total(0)
void regenerate_from_pop_data(sys::state &state)
constexpr dcon::demographics_key rich_everyday_needs(16)
constexpr float issues_change_rate
constexpr dcon::demographics_key rich_luxury_needs(19)
void pexecute_staggered_blocks(uint32_t offset, uint32_t divisions, uint32_t max, F &&functor)
void apply_assimilation(sys::state &state, uint32_t offset, uint32_t divisions, assimilation_buffer &pbuf)
constexpr dcon::demographics_key poor_everyday_needs(14)
void update_internal_migration(sys::state &state, uint32_t offset, uint32_t divisions, migration_buffer &pbuf)
void apply_type_changes(sys::state &state, uint32_t offset, uint32_t divisions, promotion_buffer &pbuf)
dcon::demographics_key to_key(sys::state const &state, dcon::pop_type_id v)
constexpr float small_pop_size
float get_estimated_mil_change(sys::state &state, dcon::pop_id ids)
constexpr uint32_t count_special_keys
void update_growth(sys::state &state, uint32_t offset, uint32_t divisions)
void update_issues(sys::state &state, uint32_t offset, uint32_t divisions, issues_buffer &ibuf)
void apply_internal_migration(sys::state &state, uint32_t offset, uint32_t divisions, migration_buffer &pbuf)
float get_estimated_conversion(sys::state &state, dcon::pop_id ids)
constexpr dcon::demographics_key rich_total(22)
constexpr dcon::demographics_key poor_total(20)
void update_type_changes(sys::state &state, uint32_t offset, uint32_t divisions, promotion_buffer &pbuf)
void regenerate_from_pop_data_full(sys::state &state)
void reduce_pop_size_safe(sys::state &state, dcon::pop_id pop_id, int32_t amount)
float get_estimated_internal_migration(sys::state &state, dcon::pop_id ids)
float get_estimated_demotion(sys::state &state, dcon::pop_id ids)
constexpr dcon::demographics_key poor_life_needs(11)
void execute_staggered_blocks(uint32_t offset, uint32_t divisions, uint32_t max, F &&functor)
uint32_t size(sys::state const &state)
void sum_over_single_nation_demographics(sys::state &state, dcon::demographics_key key, dcon::nation_id n, F const &source)
float get_monthly_pop_increase(sys::state &state, dcon::pop_id ids)
float get_estimated_con_change(sys::state &state, dcon::pop_id ids)
dcon::demographics_key to_employment_key(sys::state const &state, dcon::pop_type_id v)
void update_assimilation(sys::state &state, uint32_t offset, uint32_t divisions, assimilation_buffer &pbuf)
void remove_size_zero_pops(sys::state &state)
void update_colonial_migration(sys::state &state, uint32_t offset, uint32_t divisions, migration_buffer &pbuf)
constexpr uint32_t extra_demo_grouping
void apply_conversion(sys::state &state, uint32_t offset, uint32_t divisions, conversion_buffer &pbuf)
void apply_ideologies(sys::state &state, uint32_t offset, uint32_t divisions, ideology_buffer &pbuf)
void update_ideologies(sys::state &state, uint32_t offset, uint32_t divisions, ideology_buffer &ibuf)
constexpr uint32_t executions_per_block
void update_consciousness(sys::state &state, uint32_t offset, uint32_t divisions)
constexpr dcon::demographics_key middle_everyday_needs(15)
float get_estimated_assimilation(sys::state &state, dcon::pop_id ids)
void update_literacy(sys::state &state, uint32_t offset, uint32_t divisions)
void update_militancy(sys::state &state, uint32_t offset, uint32_t divisions)
uint32_t common_size(sys::state const &state)
void apply_colonial_migration(sys::state &state, uint32_t offset, uint32_t divisions, migration_buffer &pbuf)
float get_estimated_emigration(sys::state &state, dcon::pop_id ids)
void regenerate_from_pop_data_daily(sys::state &state)
void update_conversion(sys::state &state, uint32_t offset, uint32_t divisions, conversion_buffer &pbuf)
void apply_immigration(sys::state &state, uint32_t offset, uint32_t divisions, migration_buffer &pbuf)
float get_estimated_promotion(sys::state &state, dcon::pop_id ids)
void apply_issues(sys::state &state, uint32_t offset, uint32_t divisions, issues_buffer &pbuf)
dcon::nation_id owner_of_pop(sys::state const &state, dcon::pop_id pop_ids)
auto nation_accepts_culture(sys::state const &state, T ids, U cul_ids)
uint32_t size(sys::state const &state)
void regenerate_is_primary_or_accepted(sys::state &state)
dcon::pop_demographics_key to_key(sys::state const &state, dcon::ideology_id v)
constexpr uint32_t count_special_keys
bool is_overseas(sys::state const &state, dcon::province_id ids)
void ve_for_each_land_province(sys::state &state, F const &func)
void for_each_province_in_state_instance(sys::state &state, dcon::state_instance_id s, F const &func)
void for_each_land_province(sys::state &state, F const &func)
uint64_t get_random(sys::state const &state, uint32_t value_in)
int32_t days_difference(year_month_day start, year_month_day end)
int32_t to_generic(dcon::province_id v)
float evaluate_additive_modifier(sys::state &state, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
float evaluate_multiplicative_modifier(sys::state &state, dcon::value_modifier_key modifier, int32_t primary, int32_t this_slot, int32_t from_slot)
T select(bool v, T a, T b)
ve::vectorizable_buffer< float, dcon::pop_id > amounts
ve::vectorizable_buffer< float, dcon::pop_id > totals
void update(sys::state &state, uint32_t s)
tagged_vector< ve::vectorizable_buffer< float, dcon::pop_id >, dcon::issue_option_id > temp_buffers
void update(sys::state &state, uint32_t s)
ve::vectorizable_buffer< float, dcon::pop_id > totals