mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	kth-turn product space (via CLI)
This commit is contained in:
		
							
								
								
									
										5
									
								
								cell.cpp
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								cell.cpp
									
									
									
									
									
								
							| @@ -136,6 +136,7 @@ EX cell *newCell(int type, heptagon *master) { | |||||||
|   c->type = type; |   c->type = type; | ||||||
|   c->master = master; |   c->master = master; | ||||||
|   initcell(c); |   initcell(c); | ||||||
|  |   hybrid::will_link(c); | ||||||
|   return c; |   return c; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -194,6 +195,7 @@ EX cell *createMov(cell *c, int d) { | |||||||
|       printf("extend failed to create for %p/%d\n", c, d); |       printf("extend failed to create for %p/%d\n", c, d); | ||||||
|       exit(1); |       exit(1); | ||||||
|       } |       } | ||||||
|  |     hybrid::link(); | ||||||
|     } |     } | ||||||
|   #endif |   #endif | ||||||
|   #if CAP_ARCM |   #if CAP_ARCM | ||||||
| @@ -219,6 +221,7 @@ EX cell *createMov(cell *c, int d) { | |||||||
|   else if(archimedean || PURE) { |   else if(archimedean || PURE) { | ||||||
|     heptagon *h2 = createStep(c->master, d); |     heptagon *h2 = createStep(c->master, d); | ||||||
|     c->c.connect(d, h2->c7,c->master->c.spin(d), c->master->c.mirror(d)); |     c->c.connect(d, h2->c7,c->master->c.spin(d), c->master->c.mirror(d)); | ||||||
|  |     hybrid::link(); | ||||||
|     } |     } | ||||||
|   else if(c == c->master->c7) { |   else if(c == c->master->c7) { | ||||||
|      |      | ||||||
| @@ -235,6 +238,7 @@ EX cell *createMov(cell *c, int d) { | |||||||
|       if(hs.mirrored && (S7%2 == 0)) hs--; |       if(hs.mirrored && (S7%2 == 0)) hs--; | ||||||
|       hs = hs + alt3 + wstep - alt4; |       hs = hs + alt3 + wstep - alt4; | ||||||
|       } |       } | ||||||
|  |     hybrid::link(); | ||||||
|     extern void verifycell(cell *c); |     extern void verifycell(cell *c); | ||||||
|     verifycell(n); |     verifycell(n); | ||||||
|     } |     } | ||||||
| @@ -243,6 +247,7 @@ EX cell *createMov(cell *c, int d) { | |||||||
|     cellwalker cw(c, d, false); |     cellwalker cw(c, d, false); | ||||||
|     cellwalker cw2 = cw - 1 + wstep - 1 + wstep - 1; |     cellwalker cw2 = cw - 1 + wstep - 1 + wstep - 1; | ||||||
|     c->c.connect(d, cw2); |     c->c.connect(d, cw2); | ||||||
|  |     hybrid::link(); | ||||||
|     } |     } | ||||||
|   return c->move(d); |   return c->move(d); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -242,12 +242,18 @@ template<class T, class U> | |||||||
| void virtualRebase(cell*& base, T& at, const U& check) { | void virtualRebase(cell*& base, T& at, const U& check) { | ||||||
|  |  | ||||||
|   if(prod) { |   if(prod) { | ||||||
|     auto w = hybrid::get_where(base); |  | ||||||
|     auto d = product_decompose(check(at)).first; |     auto d = product_decompose(check(at)).first; | ||||||
|  |     while(d > cgi.plevel / 2)  {  | ||||||
|  |       at = currentmap->iadj(base, base->type-1) * at;  | ||||||
|  |       base = base->cmove(base->type-1); d -= cgi.plevel; | ||||||
|  |       } | ||||||
|  |     while(d < -cgi.plevel / 2) {  | ||||||
|  |       at = currentmap->iadj(base, base->type-2) * at;  | ||||||
|  |       base = base->cmove(base->type-2); d += cgi.plevel; | ||||||
|  |       } | ||||||
|  |     auto w = hybrid::get_where(base); | ||||||
|     at = mscale(at, -d); |     at = mscale(at, -d); | ||||||
|     PIU( virtualRebase(w.first, at, check) ); |     PIU( virtualRebase(w.first, at, check) ); | ||||||
|     if(d > cgi.plevel / 2) { w.second++; d -= cgi.plevel; } |  | ||||||
|     if(d < -cgi.plevel / 2) { w.second--; d += cgi.plevel; } |  | ||||||
|     at = mscale(at, +d); |     at = mscale(at, +d); | ||||||
|     base = hybrid::get_at(w.first, w.second); |     base = hybrid::get_at(w.first, w.second); | ||||||
|     return; |     return; | ||||||
|   | |||||||
| @@ -160,6 +160,7 @@ namespace mapstream { | |||||||
|       } |       } | ||||||
|     if(geometry == gProduct && VERNUM_HEX >= 0xA80C) { |     if(geometry == gProduct && VERNUM_HEX >= 0xA80C) { | ||||||
|       f.write(product::csteps); |       f.write(product::csteps); | ||||||
|  |       f.write(product::cspin); | ||||||
|       } |       } | ||||||
|     if(hybri && VERNUM_HEX >= 0xA80C) { |     if(hybri && VERNUM_HEX >= 0xA80C) { | ||||||
|       hybrid::in_underlying_geometry([&] { save_geometry(f); }); |       hybrid::in_underlying_geometry([&] { save_geometry(f); }); | ||||||
| @@ -243,6 +244,7 @@ namespace mapstream { | |||||||
|       } |       } | ||||||
|     if(geometry == gProduct && VERNUM_HEX >= 0xA80C) { |     if(geometry == gProduct && VERNUM_HEX >= 0xA80C) { | ||||||
|       f.read(product::csteps); |       f.read(product::csteps); | ||||||
|  |       if(VERNUM_HEX >= 0xA80D) f.read(product::cspin); | ||||||
|       } |       } | ||||||
|     if(hybri && VERNUM_HEX >= 0xA80C) { |     if(hybri && VERNUM_HEX >= 0xA80C) { | ||||||
|       auto g = geometry; |       auto g = geometry; | ||||||
|   | |||||||
							
								
								
									
										103
									
								
								nonisotropic.cpp
									
									
									
									
									
								
							
							
						
						
									
										103
									
								
								nonisotropic.cpp
									
									
									
									
									
								
							| @@ -1039,6 +1039,9 @@ EX namespace hybrid { | |||||||
|      |      | ||||||
|     hrmap *underlying_map; |     hrmap *underlying_map; | ||||||
|      |      | ||||||
|  |     int space_spin; | ||||||
|  |     map<cell*, pair<cellwalker, cellwalker>> spins; | ||||||
|  |      | ||||||
|     map<pair<cell*, int>, cell*> at; |     map<pair<cell*, int>, cell*> at; | ||||||
|     map<cell*, pair<cell*, int>> where; |     map<cell*, pair<cell*, int>> where; | ||||||
|      |      | ||||||
| @@ -1055,6 +1058,14 @@ EX namespace hybrid { | |||||||
|       } |       } | ||||||
|      |      | ||||||
|     cell *getCell(cell *u, int h) { |     cell *getCell(cell *u, int h) { | ||||||
|  |       if(space_spin) { | ||||||
|  |         if(!spins.count(u)) | ||||||
|  |           println(hlog, "link missing: ", u); | ||||||
|  |         else { | ||||||
|  |           while(h >= cgi.steps) h -= cgi.steps, u = spins[u].first.at; | ||||||
|  |           while(h < 0) h += cgi.steps, u = spins[u].second.at; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|       h = zgmod(h, cgi.steps); |       h = zgmod(h, cgi.steps); | ||||||
|       cell*& c = at[make_pair(u, h)]; |       cell*& c = at[make_pair(u, h)]; | ||||||
|       if(!c) { c = newCell(u->type+2, u->master); where[c] = {u, h}; } |       if(!c) { c = newCell(u->type+2, u->master); where[c] = {u, h}; } | ||||||
| @@ -1064,6 +1075,7 @@ EX namespace hybrid { | |||||||
|     cell* gamestart() override { return getCell(underlying_map->gamestart(), 0); } |     cell* gamestart() override { return getCell(underlying_map->gamestart(), 0); } | ||||||
|    |    | ||||||
|     hrmap_hybrid() { |     hrmap_hybrid() { | ||||||
|  |       space_spin = 0; | ||||||
|       in_underlying([this] { initcells(); underlying_map = currentmap; }); |       in_underlying([this] { initcells(); underlying_map = currentmap; }); | ||||||
|       for(hrmap*& m: allmaps) if(m == underlying_map) m = NULL; |       for(hrmap*& m: allmaps) if(m == underlying_map) m = NULL; | ||||||
|       } |       } | ||||||
| @@ -1200,6 +1212,32 @@ EX namespace hybrid { | |||||||
|     return in_actual([&] { return hr::do_draw(hybrid::get_at(c, get_where(centerover).second), T); }); |     return in_actual([&] { return hr::do_draw(hybrid::get_at(c, get_where(centerover).second), T); }); | ||||||
|     } |     } | ||||||
|    |    | ||||||
|  |   vector<cell*> to_link; | ||||||
|  |    | ||||||
|  |   EX void will_link(cell *c) { if(pmap && ((hrmap_hybrid*) pmap)->space_spin) to_link.push_back(c); } | ||||||
|  |    | ||||||
|  |   EX void link() { | ||||||
|  |     auto pm = (hrmap_hybrid*) pmap; | ||||||
|  |     if(!pm) return; | ||||||
|  |     auto& ss = pm->spins; | ||||||
|  |     int success = -1; | ||||||
|  |     while(success) { | ||||||
|  |       vector<cell*> xlink = std::move(to_link); | ||||||
|  |       success = 0; | ||||||
|  |       for(cell *c: xlink) { | ||||||
|  |         bool success_here = ss.count(c); | ||||||
|  |         if(!success_here) forCellIdEx(c2, i, c) if(ss.count(c2)) { | ||||||
|  |           ss[c].first = ss[c2].first + c->c.spin(i) + wstep - i; | ||||||
|  |           ss[c].second = ss[c2].second + c->c.spin(i) + wstep - i; | ||||||
|  |           success++; | ||||||
|  |           success_here = true; | ||||||
|  |           break; | ||||||
|  |           } | ||||||
|  |         if(!success_here) to_link.push_back(c); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
| EX } | EX } | ||||||
|    |    | ||||||
| EX namespace product { | EX namespace product { | ||||||
| @@ -1212,6 +1250,20 @@ EX namespace product { | |||||||
|       } |       } | ||||||
|  |  | ||||||
|     transmatrix adj(cell *c, int i) override { |     transmatrix adj(cell *c, int i) override { | ||||||
|  |       if(space_spin && i == c->type-1 && where[c].second == cgi.steps-1) { | ||||||
|  |         auto b = spins[where[c].first].first; | ||||||
|  |         transmatrix T = mscale(Id, cgi.plevel); | ||||||
|  |         T = T * spin(2 * M_PI * b.spin / b.at->type); | ||||||
|  |         if(b.mirrored) T = T * Mirror; | ||||||
|  |         return T; | ||||||
|  |         } | ||||||
|  |       if(space_spin && i == c->type-2 && where[c].second == 0) { | ||||||
|  |         auto b = spins[where[c].first].second; | ||||||
|  |         transmatrix T = mscale(Id, -cgi.plevel); | ||||||
|  |         T = T * spin(2 * M_PI * b.spin / b.at->type); | ||||||
|  |         if(b.mirrored) T = T * Mirror; | ||||||
|  |         return T; | ||||||
|  |         } | ||||||
|       if(i == c->type-1) return mscale(Id, cgi.plevel); |       if(i == c->type-1) return mscale(Id, cgi.plevel); | ||||||
|       else if(i == c->type-2) return mscale(Id, -cgi.plevel); |       else if(i == c->type-2) return mscale(Id, -cgi.plevel); | ||||||
|       c = where[c].first; |       c = where[c].first; | ||||||
| @@ -1225,9 +1277,30 @@ EX namespace product { | |||||||
|       dynamicval<cell*> co(centerover, hybrid::get_where(centerover).first); |       dynamicval<cell*> co(centerover, hybrid::get_where(centerover).first); | ||||||
|       in_underlying([=] { currentmap->draw(); }); |       in_underlying([=] { currentmap->draw(); }); | ||||||
|       } |       } | ||||||
|  |      | ||||||
|  |     hrmap_product() { | ||||||
|  |       if(cspin) { | ||||||
|  |         space_spin = cspin; | ||||||
|  |         in_underlying([&] { | ||||||
|  |           auto ugs = currentmap->gamestart(); | ||||||
|  |           spins[ugs] = make_pair( | ||||||
|  |             cellwalker(ugs, gmod(+space_spin, ugs->type)), | ||||||
|  |             cellwalker(ugs, gmod(-space_spin, ugs->type)) | ||||||
|  |             ); | ||||||
|  |           manual_celllister cl; | ||||||
|  |           cl.add(ugs); | ||||||
|  |           for(int i=0; i<isize(cl.lst); i++) { | ||||||
|  |             cell *c = cl.lst[i]; | ||||||
|  |             hybrid::will_link(c); | ||||||
|  |             forCellIdEx(c2, i, c) cl.add(c2); | ||||||
|  |             } | ||||||
|  |           hybrid::link(); | ||||||
|  |           }); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   EX int cwall_offset, cwall_mask, actual_view_level, csteps; |   EX int cwall_offset, cwall_mask, actual_view_level, csteps, cspin; | ||||||
|    |    | ||||||
|   EX void drawcell_stack(cellwalker cw, transmatrix V) { |   EX void drawcell_stack(cellwalker cw, transmatrix V) { | ||||||
|     cell *c = cw.at; |     cell *c = cw.at; | ||||||
| @@ -1250,12 +1323,22 @@ EX namespace product { | |||||||
|       cwall_mask |= (2<<c->type); |       cwall_mask |= (2<<c->type); | ||||||
|       int flat_distance = hdist0(product_decompose(tC0(V)).second); |       int flat_distance = hdist0(product_decompose(tC0(V)).second); | ||||||
|       int max_z = flat_distance > sightranges[gProduct] ? 0 : sqrt(sightranges[gProduct] * sightranges[gProduct] - flat_distance * flat_distance) + 1; |       int max_z = flat_distance > sightranges[gProduct] ? 0 : sqrt(sightranges[gProduct] * sightranges[gProduct] - flat_distance * flat_distance) + 1; | ||||||
|       for(int z=-max_z; z<=max_z; z++) { |       for(int si: {0, 1}) { | ||||||
|         if(z == 0) cwall_mask ^= (2<<c->type); |         cell *c1 = hybrid::get_at(c, z0); | ||||||
|         if(z == 1) cwall_mask ^= (1<<c->type); |         int dir = c1->type-1-si; | ||||||
|         cell *c1 = hybrid::get_at(c, actual_view_level+z); |         int z1 = z0; | ||||||
|         setdist(c1, 7, NULL); |         auto V0 = V; | ||||||
|         drawcell(c1, V * mscale(Id, cgi.plevel * (z+actual_view_level - z0)));  |         for(int z=0; z<=max_z; z++) { | ||||||
|  |           if(((hybrid::hrmap_hybrid*)currentmap)->space_spin) cwall_mask = -1; | ||||||
|  |           cwall_mask &= ~(3<<c->type); | ||||||
|  |           if(z1 > actual_view_level) cwall_mask |= (1<<c->type); | ||||||
|  |           if(z1 < actual_view_level) cwall_mask |= (2<<c->type); | ||||||
|  |           setdist(c1, 7, NULL); | ||||||
|  |           if(z || !si) drawcell(c1, V0);  | ||||||
|  |           V0 = V0 * currentmap->adj(c1, dir); | ||||||
|  |           c1 = c1->cmove(dir); | ||||||
|  |           z1 += (si ? -1 : 1); | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
| @@ -1960,6 +2043,12 @@ EX namespace nisot { | |||||||
|       hybrid::reconfigure(); |       hybrid::reconfigure(); | ||||||
|       return 0; |       return 0; | ||||||
|       } |       } | ||||||
|  |     else if(argis("-prodturn")) { | ||||||
|  |       PHASEFROM(2); | ||||||
|  |       if(prod) stop_game(); | ||||||
|  |       shift(); product::cspin = argi(); | ||||||
|  |       return 0; | ||||||
|  |       } | ||||||
|     return 1; |     return 1; | ||||||
|     }); |     }); | ||||||
|      |      | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue