From 572252b94fb7b52c1806563eed4e74d00f114dd5 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 17 Jul 2018 15:00:18 +0200 Subject: [PATCH] irr:: memorizing relmatrices (no bit performance improvement though --- irregular.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/irregular.cpp b/irregular.cpp index 27cdfd04..8d6ebc49 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -12,6 +12,7 @@ int cellcount; struct cellinfo { cell *owner; + map relmatrices; vector jpoints; hyperpoint p; transmatrix pusher, rpusher; @@ -112,11 +113,13 @@ bool step(int delta) { cells_of_heptagon.clear(); cellindex.clear(); - if(cellcount <= isize(all) * 2) { + if(0) if(cellcount <= isize(all) * 2) { for(auto h: all) { - cellinfo s; s.patterndir = -1; + cells.emplace_back(); + cellinfo& s = cells.back(); + s.patterndir = -1; s.owner = h, s.p = spin(hrand(1000)) * xpush(.01) * C0; - cells.emplace_back(s); + for(auto c0: all) s.relmatrices[c0] = shmup::calc_relative_matrix(c0, s.owner, s.p); } } runlevel++; @@ -126,21 +129,25 @@ bool step(int delta) { case 1: { while(isize(cells) < cellcount) { if(SDL_GetTicks() > t + 250) { make_cells_of_heptagon(); status[0] = its(isize(cells)) + " cells"; return false; } - cellinfo s; s.patterndir = -1; + cells.emplace_back(); + cellinfo& s = cells.back(); + s.patterndir = -1; ld bestval = 0; for(int j=0; j relmatrices; hyperpoint h = randomPointIn(c->type); + for(auto c0: all) relmatrices[c0] = shmup::calc_relative_matrix(c0, c, h); ld mindist = 1e6; for(auto p: cells) { - ld val = hdist(h, shmup::calc_relative_matrix(p.owner, c, h) * p.p); + if(!relmatrices.count(p.owner)) continue; + ld val = hdist(h, relmatrices[p.owner] * p.p); if(val < mindist) mindist = val; } - if(mindist > bestval) bestval = mindist, s.owner = c, s.p = h; + if(mindist > bestval) bestval = mindist, s.owner = c, s.p = h, s.relmatrices = move(relmatrices); } // printf("%lf %p %s\n", bestval, s.owner, display(s.p)); - cells.emplace_back(s); } make_cells_of_heptagon(); runlevel++; @@ -171,7 +178,7 @@ bool step(int delta) { for(int j=0; j