M11.1: environmental rules 3 with per-second rates (ADR-0099, segment 3)
Foundation / checks (deploy) (push) Successful in 3m27s
Foundation / checks (ecs) (push) Successful in 1m58s
Foundation / checks (client) (push) Successful in 12m20s
Foundation / checks (network) (push) Successful in 13m53s
Foundation / checks (tsan) (push) Successful in 8m9s
Foundation / checks (checks) (push) Successful in 33m4s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 21m43s
Foundation / checks (deploy) (push) Successful in 3m27s
Foundation / checks (ecs) (push) Successful in 1m58s
Foundation / checks (client) (push) Successful in 12m20s
Foundation / checks (network) (push) Successful in 13m53s
Foundation / checks (tsan) (push) Successful in 8m9s
Foundation / checks (checks) (push) Successful in 33m4s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 21m43s
Rules 3 is rules 2 with irradiance, growth, intake and decay per second. The community derives its per-tick form once at creation and restore (rationals exact via the tick in numerator and denominator, caps rounded down); steps and the snapshot layout are rules 2's; the codec reads formats 1-3. At 50 ms a x20 per-second twin steps identically through feeding, death and decay and across a snapshot; at 25 ms caps halve. Rules 1/2 and the development-v1 opening are unchanged. Development version 1 outputs stay tied to their 50 ms quantum and the tick-abstract M2 fixtures are not migrated (recorded). environmental-qualification's "unknown rules" case moves from 3 to 4. Refresh the dev session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -523,6 +523,83 @@ void interval_boundaries() {
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
// Rules 3 (ADR-0099): rules 2 with every rate per second. At 50 ms a per-second twin of a
|
||||
// rules 2 configuration (rates times 20) steps identically, through feeding, a death and
|
||||
// its decay, and across a snapshot; at another tick the caps scale and round down.
|
||||
void rules3_per_second() {
|
||||
auto two = config();
|
||||
two.rules = 2;
|
||||
two.growth_numerator = 3;
|
||||
two.growth_denominator = 2;
|
||||
two.decay.fill(2);
|
||||
auto three = two;
|
||||
three.rules = 3;
|
||||
three.irradiance_numerator *= 20;
|
||||
three.growth_numerator *= 20;
|
||||
for (auto& v : three.intake)
|
||||
v *= 20;
|
||||
for (auto& v : three.decay)
|
||||
v *= 20;
|
||||
const std::array<std::uint64_t, 10> stock{5, 5, 5, 5, 5, 5, 5, 5, 5, 5};
|
||||
auto made_a = EnvironmentalCommunity::create(
|
||||
two, resources({100, 100, 100, 100, 0, 0, 100, 0, 10, 0}, stock, stock), 8000000);
|
||||
auto made_b = EnvironmentalCommunity::create(
|
||||
three, resources({100, 100, 100, 100, 0, 0, 100, 0, 10, 0}, stock, stock), 8000000);
|
||||
CHECK(made_a && made_b);
|
||||
auto a = std::move(*made_a);
|
||||
auto b = std::move(*made_b);
|
||||
const auto same = [&] {
|
||||
for (std::size_t k = 0; k < 10; ++k)
|
||||
if (*a->resources().fields().read(0, static_cast<Field>(k)) !=
|
||||
*b->resources().fields().read(0, static_cast<Field>(k)))
|
||||
return false;
|
||||
return a->resources().organisms()[0].balances == b->resources().organisms()[0].balances &&
|
||||
a->resources().organisms()[1].balances == b->resources().organisms()[1].balances;
|
||||
};
|
||||
const auto input = [](std::uint64_t tick) {
|
||||
EnvironmentalInput in{290000, tick % 7 == 0 ? 0U : 1U, {}, {}};
|
||||
if (tick == 6)
|
||||
in.bite = {1, 1, 1, 1, 1};
|
||||
if (tick == 20)
|
||||
in.terminal = {0, 1};
|
||||
return in;
|
||||
};
|
||||
for (std::uint64_t tick = 1; tick <= 40; ++tick) {
|
||||
const auto ra = a->advance(tick, input(tick));
|
||||
const auto rb = b->advance(tick, input(tick));
|
||||
CHECK(ra.has_value() == rb.has_value());
|
||||
if (ra)
|
||||
CHECK(*ra == *rb);
|
||||
CHECK(same());
|
||||
}
|
||||
// Rules 3 persists as rules 3 and replays from its snapshot.
|
||||
const auto saved = b->snapshot();
|
||||
CHECK(saved && (*saved)[8] == 3);
|
||||
auto restored = EnvironmentalCommunity::restore(*saved, identity, 8000000);
|
||||
CHECK(restored && (*restored)->snapshot() == saved);
|
||||
b = std::move(*restored);
|
||||
for (std::uint64_t tick = 41; tick <= 60; ++tick) {
|
||||
const auto ra = a->advance(tick, input(tick));
|
||||
const auto rb = b->advance(tick, input(tick));
|
||||
CHECK(ra && rb && *ra == *rb && same());
|
||||
}
|
||||
// At 25 ms a cap of 2000 per second is 50 per tick: 51 is over it, 50 is within it.
|
||||
auto fast = three;
|
||||
fast.tick_microseconds = 25000;
|
||||
auto quick = make(fast);
|
||||
const auto over = quick->advance(1, {290000, 0, {51, 0, 0, 0, 0}, {}});
|
||||
CHECK(!over && over.error() == CommunityError::input);
|
||||
const auto within = quick->advance(1, {290000, 0, {50, 0, 0, 0, 0}, {}});
|
||||
CHECK(!within && within.error() == CommunityError::insufficient); // Past the cap check.
|
||||
// A rate that cannot be converted at the tick is a configuration error.
|
||||
auto huge = three;
|
||||
huge.irradiance_numerator = std::numeric_limits<std::uint64_t>::max();
|
||||
CHECK(!EnvironmentalCommunity::create(huge, resources(), 8000000));
|
||||
auto slow = three;
|
||||
slow.tick_microseconds = 1'000'001;
|
||||
CHECK(!EnvironmentalCommunity::create(slow, resources(), 8000000));
|
||||
}
|
||||
|
||||
int main() {
|
||||
try {
|
||||
vectors();
|
||||
@@ -533,6 +610,7 @@ int main() {
|
||||
decay_continuation();
|
||||
scheduled_intervals();
|
||||
interval_boundaries();
|
||||
rules3_per_second();
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "%s\n", e.what());
|
||||
|
||||
Reference in New Issue
Block a user