1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

moved binsearch to hyper.h

This commit is contained in:
Zeno Rogue 2020-03-31 20:06:18 +02:00
parent 0446e25ebf
commit af10592616
2 changed files with 12 additions and 9 deletions

12
hyper.h
View File

@ -772,6 +772,18 @@ template <class T> void texture_order(const T& f) {
}
}
/** find the smallest value of x in range [dmin..dmax] such that f(x) returns true */
template<class T> ld binsearch(ld dmin, ld dmax, const T& f) {
for(int i=0; i<200; i++) {
ld d = (dmin + dmax) / 2;
if(dmin == d || dmax == d) break;
if(f(d)) dmax = d;
else dmin = d;
}
return dmin;
}
static const color_t NOCOLOR = 0;
static const int max_vec = (1<<14);

View File

@ -44,15 +44,6 @@ EX namespace reg3 {
/** \brief for adjacent directions a,b, next_dir[a][b] is the next direction adjacent to a, in (counter?)clockwise order from b */
EX int next_dir[16][16];
template<class T> ld binsearch(ld dmin, ld dmax, const T& f) {
for(int i=0; i<200; i++) {
ld d = (dmin + dmax) / 2;
if(f(d)) dmax = d;
else dmin = d;
}
return dmin;
}
EX void generate() {
if(S7 == 4) face = 3;