1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 15:40:26 +00:00

precision in binsearch

This commit is contained in:
Zeno Rogue 2022-05-07 15:18:20 +02:00
parent 9c29f39f7e
commit c8e5c3e763

View File

@ -904,8 +904,8 @@ 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++) {
template<class T> ld binsearch(ld dmin, ld dmax, const T& f, int iterations = 200) {
for(int i=0; i<iterations; i++) {
ld d = (dmin + dmax) / 2;
if(dmin == d || dmax == d) break;
if(f(d)) dmax = d;