mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
gp::loc now better
This commit is contained in:
parent
0cb93afad7
commit
6bb3a076da
64
goldberg.cpp
64
goldberg.cpp
@ -13,7 +13,28 @@ namespace hr {
|
|||||||
EX namespace gp {
|
EX namespace gp {
|
||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
typedef pair<int, int> loc;
|
struct loc : pair<int, int> {
|
||||||
|
loc() {}
|
||||||
|
|
||||||
|
loc(int x, int y) : pair<int,int> (x,y) {}
|
||||||
|
|
||||||
|
loc operator+(loc e2) {
|
||||||
|
return loc(first+e2.first, second+e2.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
loc operator-(loc e2) {
|
||||||
|
return loc(first-e2.first, second-e2.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
loc operator*(loc e2) {
|
||||||
|
return loc(first*e2.first-second*e2.second,
|
||||||
|
first*e2.second + e2.first*second + (S3 == 3 ? second*e2.second : 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
loc operator*(int i) {
|
||||||
|
return loc(first*i, second*i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct local_info {
|
struct local_info {
|
||||||
int last_dir;
|
int last_dir;
|
||||||
@ -25,42 +46,25 @@ EX namespace gp {
|
|||||||
|
|
||||||
EX local_info draw_li;
|
EX local_info draw_li;
|
||||||
|
|
||||||
EX loc operator+(loc e1, loc e2) {
|
|
||||||
return make_pair(e1.first+e2.first, e1.second+e2.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
EX loc operator-(loc e1, loc e2) {
|
|
||||||
return make_pair(e1.first-e2.first, e1.second-e2.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
EX loc operator*(loc e1, loc e2) {
|
|
||||||
return make_pair(e1.first*e2.first-e1.second*e2.second,
|
|
||||||
e1.first*e2.second + e2.first*e1.second + (S3 == 3 ? e1.second*e2.second : 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
loc operator*(loc e1, int i) {
|
|
||||||
return loc(e1.first*i, e1.second*i);
|
|
||||||
}
|
|
||||||
|
|
||||||
EX loc eudir(int d) {
|
EX loc eudir(int d) {
|
||||||
if(S3 == 3) {
|
if(S3 == 3) {
|
||||||
d %= 6; if (d < 0) d += 6;
|
d %= 6; if (d < 0) d += 6;
|
||||||
switch(d) {
|
switch(d) {
|
||||||
case 0: return make_pair(1, 0);
|
case 0: return loc(1, 0);
|
||||||
case 1: return make_pair(0, 1);
|
case 1: return loc(0, 1);
|
||||||
case 2: return make_pair(-1, 1);
|
case 2: return loc(-1, 1);
|
||||||
case 3: return make_pair(-1, 0);
|
case 3: return loc(-1, 0);
|
||||||
case 4: return make_pair(0, -1);
|
case 4: return loc(0, -1);
|
||||||
case 5: return make_pair(1, -1);
|
case 5: return loc(1, -1);
|
||||||
default: return make_pair(0, 0);
|
default: return loc(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else switch(d&3) {
|
else switch(d&3) {
|
||||||
case 0: return make_pair(1, 0);
|
case 0: return loc(1, 0);
|
||||||
case 1: return make_pair(0, 1);
|
case 1: return loc(0, 1);
|
||||||
case 2: return make_pair(-1, 0);
|
case 2: return loc(-1, 0);
|
||||||
case 3: return make_pair(0, -1);
|
case 3: return loc(0, -1);
|
||||||
default: return make_pair(0, 0);
|
default: return loc(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
|||||||
int dm = hs.at->distance;
|
int dm = hs.at->distance;
|
||||||
hs += -1; hs += wstep;
|
hs += -1; hs += wstep;
|
||||||
int d0 = hs.at->distance;
|
int d0 = hs.at->distance;
|
||||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(-1,1)));
|
h->distance = gp::solve_triangle(dm, d0, d1, gp::param * gp::loc(-1,1));
|
||||||
}
|
}
|
||||||
else if(S3 == 4 && GOLDBERG && h->c.spin(0) == S7-1 && among(h->move(0)->c.spin(0), S7-2, S7-3) && h->move(0)->move(0)->s != hsOrigin) {
|
else if(S3 == 4 && GOLDBERG && h->c.spin(0) == S7-1 && among(h->move(0)->c.spin(0), S7-2, S7-3) && h->move(0)->move(0)->s != hsOrigin) {
|
||||||
heptspin hs(h, 0);
|
heptspin hs(h, 0);
|
||||||
@ -155,7 +155,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
|||||||
int dm = hs.at->distance;
|
int dm = hs.at->distance;
|
||||||
hs += 1; hs += wstep;
|
hs += 1; hs += wstep;
|
||||||
int d1 = hs.at->distance;
|
int d1 = hs.at->distance;
|
||||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(1,1)));
|
h->distance = gp::solve_triangle(dm, d0, d1, gp::param * gp::loc(1,1));
|
||||||
}
|
}
|
||||||
else if(S3 == 4 && GOLDBERG && h->c.spin(0) >= 2 && h->c.spin(0) <= S7-2) {
|
else if(S3 == 4 && GOLDBERG && h->c.spin(0) >= 2 && h->c.spin(0) <= S7-2) {
|
||||||
h->distance = parent->distance + gp::dist_2();
|
h->distance = parent->distance + gp::dist_2();
|
||||||
@ -167,7 +167,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
|||||||
int d0 = parent->distance;
|
int d0 = parent->distance;
|
||||||
int d1 = createStep(parent, S7-1)->distance;
|
int d1 = createStep(parent, S7-1)->distance;
|
||||||
int dm = createStep(parent, 0)->distance;
|
int dm = createStep(parent, 0)->distance;
|
||||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(1,1)));
|
h->distance = gp::solve_triangle(dm, d0, d1, gp::param * gp::loc(1,1));
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
h->distance = parent->distance + gp::dist_1();
|
h->distance = parent->distance + gp::dist_1();
|
||||||
@ -178,7 +178,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
|||||||
int d0 = parent->distance;
|
int d0 = parent->distance;
|
||||||
int d1 = createStep(parent, S7-2)->distance;
|
int d1 = createStep(parent, S7-2)->distance;
|
||||||
int dm = createStep(parent, S7-1)->distance;
|
int dm = createStep(parent, S7-1)->distance;
|
||||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(1,1)));
|
h->distance = gp::solve_triangle(dm, d0, d1, gp::param * gp::loc(1,1));
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
h->distance = createStep(h->move(0), (h->c.spin(0)+2)%S7)->distance + gp::dist_3();
|
h->distance = createStep(h->move(0), (h->c.spin(0)+2)%S7)->distance + gp::dist_3();
|
||||||
|
Loading…
Reference in New Issue
Block a user