mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2026-10-14 21:31:42 +00:00
CA for infinite
This commit is contained in:
+19
-3
@@ -3347,6 +3347,14 @@ EX namespace ca {
|
||||
|
||||
EX eWall wlive = waFloorA;
|
||||
|
||||
EX unordered_set<cell*> changed;
|
||||
|
||||
EX void list_adj(cell *c) {
|
||||
changed.insert(c);
|
||||
for(cell* c1: adj_minefield_cells(c))
|
||||
changed.insert(c1);
|
||||
}
|
||||
|
||||
// you can also do -mineadj
|
||||
|
||||
EX string fillup(string s) {
|
||||
@@ -3401,13 +3409,15 @@ EX namespace ca {
|
||||
|
||||
EX void simulate() {
|
||||
if(cwt.at->land != laCA) return;
|
||||
vector<cell*>& allcells = currentmap->allcells();
|
||||
vector<cell*> allcells;
|
||||
for(cell *c: changed) allcells.push_back(c);
|
||||
changed.clear();
|
||||
int dcs = isize(allcells);
|
||||
std::vector<bool> willlive(dcs);
|
||||
int old = 0, xold = 0;
|
||||
for(int i=0; i<dcs; i++) {
|
||||
cell *c = allcells[i];
|
||||
if(c->land != laCA) return;
|
||||
if(c->land != laCA) continue;
|
||||
int nei = 0, live = 0;
|
||||
for(cell *c2: adj_minefield_cells(c)) {
|
||||
nei++; if(c2->wall == wlive) live++;
|
||||
@@ -3418,9 +3428,15 @@ EX namespace ca {
|
||||
}
|
||||
for(int i=0; i<dcs; i++) {
|
||||
cell *c = allcells[i];
|
||||
auto last = c->wall;
|
||||
c->wall = willlive[i] ? wlive : waNone;
|
||||
if(c->wall != last) {
|
||||
dynamicval<ld> d(prob, 0);
|
||||
setdist(c, 7, nullptr);
|
||||
list_adj(c);
|
||||
}
|
||||
}
|
||||
println(hlog, tie(dcs, old, xold));
|
||||
println(hlog, make_tuple(dcs, old, xold, isize(changed)));
|
||||
}
|
||||
EX }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user