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

rv::som:: improved animation

This commit is contained in:
Zeno Rogue 2022-04-21 12:21:23 +02:00
parent f67d16b0f8
commit 0c71c3724f

View File

@ -1384,14 +1384,27 @@ void neurondisttable(const string &name) {
fclose(f);
}
bool animate = true;
bool animate_loop;
bool animate_once;
void steps() {
if(kohonen::animate && !kohonen::finished()) {
if(kohonen::animate_once && !kohonen::finished()) {
unsigned int t = SDL_GetTicks();
while(SDL_GetTicks() < t+20) kohonen::step();
setindex(false);
}
if(kohonen::animate_loop) {
ld tfrac = frac(1 - ticks * 1. / anims::period);
int t1 = tmax * tfrac;
println(hlog, "got t1 = ", t1, "/", tmax);
if(t1 > t) {
initialize_rv();
set_neuron_initial();
t = tmax;
}
while(t > t1) kohonen::step();
setindex(false);
}
}
void shift_color(int i) {
@ -1784,7 +1797,8 @@ auto hooks4 = addHook(hooks_clearmemory, 100, clear)
-> editable(0, 2, .2, "precise placement", "0 = make all visible, 1 = place ideally, n = place 1/n of the distance from center to ideal placement", 'p')
-> set_reaction([] { if((state & KS_NEURONS) && (state & KS_SAMPLES)) distribute_neurons(); });
param_b(show_rings, "som_show_rings");
param_b(animate, "animate");
param_b(animate_once, "som_animate_once");
param_b(animate_loop, "som_animate_loop");
param_f(dispersion_precision, "som_dispersion")
-> set_reaction([] { state &=~ KS_DISPERSION; });
});