From c6bf25b5b6cdd428ea496e8effb2df4683c28672 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 22 Nov 2019 16:29:53 +0100 Subject: [PATCH] location:: movei structure --- locations.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/locations.cpp b/locations.cpp index 4fcd634f..6818ce44 100644 --- a/locations.cpp +++ b/locations.cpp @@ -436,4 +436,26 @@ inline cellwalker operator+ (heptspin hs, cth_t) { return cellwalker(hs.at->c7, #endif +#if HDR +/** a structure for representing movements + * mostly for 'proper' moves where s->move(d) == t, + * but also sometimes for other moves + */ + +struct movei { + cell *s; + cell *t; + int d; + bool proper() const { return d >= 0 && d < s->type && s->move(d) == t; } + movei(cell *_s, int _d) : s(_s), t(_s->move(_d)), d(_d) {} + movei(cell *_s, cell *_t, int _d) : s(_s), t(_t), d(_d) {} + movei rev() const { return movei(t, s, d >= 0 && d < s->type ? s->c.spin(d) : d); } + }; +#endif + +EX movei match(cell *f, cell *t) { + for(int i=0; itype; i++) if(f->move(i) == t) return movei(f, t, i); + return movei(f, t, -1); + } + }