Add bounded cellular resource perception
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (network) (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (client) (push) Canceled after 1m8s
Foundation / checks (checks) (push) Canceled after 1m13s
Foundation / checks (ecs) (push) Canceled after 1m4s

This commit is contained in:
dingo
2026-10-10 21:16:54 -04:00
parent 1787718383
commit 44732967e7
7 changed files with 135 additions and 1 deletions
+25 -1
View File
@@ -78,6 +78,29 @@ void canonical_snapshot_round_trip() {
CHECK(!CellularHabitat::restore(oversized, 7, 9, 11));
}
void perception_is_bounded_by_body_to_patch_distance() {
CellularHabitatConfig opening{7,
9,
11,
10'000,
10'000,
{{{0, 0}, 51, {{1'000}, {}}},
{{4'000, 4'000}, 52, {{2'000}, {}}},
{{5'000, 5'000}, 53, {{3'000}, {}}},
{{6'000, 0}, 54, {{4'000}, {}}}}};
const auto made = CellularHabitat::create(std::move(opening));
CHECK(made);
const auto visible = (*made)->perceive({0, 0}, 1'000);
CHECK(visible);
CHECK(visible->size() == 3);
CHECK((*visible)[0] == CellularPatchPerception{{0, 0}, {{1'000}, {}}});
CHECK((*visible)[1] == CellularPatchPerception{{4'000, 4'000}, {{2'000}, {}}});
CHECK((*visible)[2] == CellularPatchPerception{{6'000, 0}, {{4'000}, {}}});
CHECK(!(*made)->perceive({9'001, 0}, 1'000));
CHECK(!(*made)->perceive({0, 0}, 0));
}
void invalid_openings_refuse() {
auto invalid = config();
invalid.width_um = 3'001;
@@ -118,8 +141,9 @@ int main() {
try {
create_query_and_propose();
canonical_snapshot_round_trip();
perception_is_bounded_by_body_to_patch_distance();
invalid_openings_refuse();
std::puts("PASS cellular habitat: finite patch opening, lookup and canonical recovery");
std::puts("PASS cellular habitat: finite patches, perception and canonical recovery");
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
return 1;