1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-28 02:50:34 +00:00
hyperrogue/rogueviz/dhrg/dhrg.h

81 lines
1.9 KiB
C
Raw Normal View History

2022-11-04 22:53:13 +00:00
#ifndef _DHRG_H_
#define _DHRG_H_
2022-08-23 19:47:48 +00:00
#define DHRGVER "7.1"
#include "../rogueviz.h"
#define LONG_BRACKETS
namespace dhrg {
using namespace hr;
typedef long long ll;
#ifndef BOXSIZE
static constexpr int BOXSIZE = 32;
2022-08-23 19:47:48 +00:00
#endif
static constexpr int MAXDIST = (2*BOXSIZE);
static constexpr int SETS = 4;
2022-08-23 19:47:48 +00:00
struct segment;
inline cell *croot() { return currentmap->gamestart(); }
extern int M;
extern vector<struct mycell*> vertices;
extern vector<ld> disttable0, disttable1;
void memoryInfo();
void cellcoords();
void origcoords();
void build_disttable();
void dhrg_init();
bool dhrg_animate(int sym, int uni);
/* implemented in loglik.cpp: */
/* for logistic regression */
struct logistic {
ld R, T;
2023-08-22 18:03:17 +00:00
ld yes1(ld d) { return 1/(1 + exp(d)); }
ld no1(ld d) { return 1/(1 + exp(-d)); }
ld nor(ld d) { return (d-R) / 2 / T; }
ld yes(ld d) { return yes1(nor(d)); }
ld no(ld d) { return no1(nor(d)); }
ld lyes(ld d) { d = nor(d); return d > 200 ? -d : log(yes1(d)); }
ld lno(ld d) { d = nor(d); return d < -200 ? d : log(no1(d)); }
2022-08-23 19:47:48 +00:00
logistic() {}
logistic(ld _R, ld _T) : R(_R), T(_T) {}
void setRT(ld _R, ld _T) { R = _R; T = _T; }
};
extern ld llcont_approx_prec;
extern vector<array<ll, 2>> disttable_approx;
using logisticfun = std::function<ld(logistic&)>;
extern logistic current_logistic;
ld loglik_cont_approx(logistic& l = current_logistic);
void fast_loglik_cont(logistic& l, const logisticfun& f, const char *name, ld start, ld eps);
/* greedy routing */
struct iddata {
ld tot, suc, routedist, bestdist;
iddata() { tot = suc = routedist = bestdist = 0; }
};
using neighborhoodfun = std::function<vector<int> (int)>;
using distfun = std::function<ld(int a, int b)>;
void prepare_pairs(int N, const neighborhoodfun& nei);
void greedy_routing(iddata& d, const distfun& distance_function);
}
2022-11-04 22:53:13 +00:00
#endif