mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 14:02:59 +00:00 
			
		
		
		
	irr:: memorizing relmatrices (no bit performance improvement though
This commit is contained in:
		| @@ -12,6 +12,7 @@ int cellcount; | |||||||
|  |  | ||||||
| struct cellinfo { | struct cellinfo { | ||||||
|   cell *owner; |   cell *owner; | ||||||
|  |   map<cell*, transmatrix> relmatrices; | ||||||
|   vector<hyperpoint> jpoints; |   vector<hyperpoint> jpoints; | ||||||
|   hyperpoint p; |   hyperpoint p; | ||||||
|   transmatrix pusher, rpusher; |   transmatrix pusher, rpusher; | ||||||
| @@ -112,11 +113,13 @@ bool step(int delta) { | |||||||
|      cells_of_heptagon.clear(); |      cells_of_heptagon.clear(); | ||||||
|      cellindex.clear(); |      cellindex.clear(); | ||||||
|       |       | ||||||
|      if(cellcount <= isize(all) * 2) { |      if(0) if(cellcount <= isize(all) * 2) { | ||||||
|        for(auto h: all) { |        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; |          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++; |       runlevel++; | ||||||
| @@ -126,21 +129,25 @@ bool step(int delta) { | |||||||
|     case 1: { |     case 1: { | ||||||
|       while(isize(cells) < cellcount) { |       while(isize(cells) < cellcount) { | ||||||
|         if(SDL_GetTicks() > t + 250) { make_cells_of_heptagon(); status[0] = its(isize(cells)) + " cells"; return false; } |         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; |         ld bestval = 0; | ||||||
|         for(int j=0; j<place_attempts; j++) { |         for(int j=0; j<place_attempts; j++) { | ||||||
|           int k = hrand(isize(all)); |           int k = hrand(isize(all)); | ||||||
|           cell *c = all[k]; |           cell *c = all[k]; | ||||||
|  |           map<cell*, transmatrix> relmatrices; | ||||||
|           hyperpoint h = randomPointIn(c->type); |           hyperpoint h = randomPointIn(c->type); | ||||||
|  |           for(auto c0: all) relmatrices[c0] = shmup::calc_relative_matrix(c0, c, h); | ||||||
|           ld mindist = 1e6; |           ld mindist = 1e6; | ||||||
|           for(auto p: cells) { |           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(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)); |         // printf("%lf %p %s\n", bestval, s.owner, display(s.p)); | ||||||
|         cells.emplace_back(s); |  | ||||||
|         } |         } | ||||||
|       make_cells_of_heptagon(); |       make_cells_of_heptagon(); | ||||||
|       runlevel++; |       runlevel++; | ||||||
| @@ -171,7 +178,7 @@ bool step(int delta) { | |||||||
|      |      | ||||||
|         for(int j=0; j<cellcount; j++) { |         for(int j=0; j<cellcount; j++) { | ||||||
|           auto &p2 = cells[j]; |           auto &p2 = cells[j]; | ||||||
|           p1.jpoints.push_back(p1.rpusher * shmup::calc_relative_matrix(p2.owner, p1.owner, p1.p) * p2.p); |           p1.jpoints.push_back(p1.rpusher * p1.relmatrices[p2.owner] * p2.p); | ||||||
|           } |           } | ||||||
|      |      | ||||||
|         int j = 0; |         int j = 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue