Last active
January 7, 2018 19:08
-
-
Save adler3d/c04a2b9efb173cf30077676445818989 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
using std::vector; | |
template<class TYPE,class FUNC>void qap_foreach(TYPE&&arr,FUNC func){auto n=arr.size();for(size_t i=0;i<n;i++)func(arr[i],i);} | |
#define QAP_FOREACH(arr,code)qap_foreach(arr,[&](decltype(arr[0])&ex,int i){code;}) | |
#define qapforeach(arr,code)QAP_FOREACH(arr,code) | |
struct t_env{ | |
struct t_move{/*...*/}; | |
struct t_world{ | |
void use(t_move m){/*...*/} | |
void sim_step(){/*...*/} | |
vector<t_move> get_arr_of_possibles_moves(){vector<t_move> out;/*...*/return out;} | |
static t_world use(t_world w,vector<int> way){ | |
auto out=w; | |
qapforeach(way,out.use(out.get_arr_of_possibles_moves()[ex]);out.sim_step()); | |
return out; | |
} | |
}; | |
t_world w; | |
void visit_all(vector<int> way){ | |
auto cur_w=t_world::use(w,way); | |
if(!ok(cur_w,way))return; | |
auto arr=cur_w.get_arr_of_possibles_moves(); | |
qapforeach(arr,visit_all(add(way,i))); | |
} | |
static vector<int> add(vector<int> inp,int i){auto out=inp;out.push_back(i);return out;}; | |
bool ok(t_world w,vector<int> way){ | |
/*...*/ | |
return true; | |
} | |
}; | |
int main(){ | |
t_env env; | |
//QapLoadFromFile("input_world.qap",env.w); | |
env.visit_all(vector<int>()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment