|
|
#pragma once
|
|
|
#include <vector>
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct FungiSoA {
|
|
|
int F = 0;
|
|
|
int H = 0, W = 0;
|
|
|
|
|
|
std::vector<float> x, y;
|
|
|
std::vector<float> sigma;
|
|
|
std::vector<float> alpha;
|
|
|
std::vector<float> theta;
|
|
|
std::vector<float> a_base;
|
|
|
std::vector<float> p_base;
|
|
|
|
|
|
std::vector<float> energy;
|
|
|
std::vector<float> mass;
|
|
|
std::vector<int> age;
|
|
|
|
|
|
void resize(int F_, int H_, int W_);
|
|
|
void init_random(unsigned seed, float sigma_min=1.5f, float sigma_max=5.5f);
|
|
|
void adjust_population(int newF, unsigned seed);
|
|
|
};
|
|
|
|
|
|
|
|
|
void fungi_build_masks_GPU(const FungiSoA& pop,
|
|
|
float* d_A, float* d_P,
|
|
|
int tiles_y=7, int tiles_x=7);
|
|
|
|
|
|
|
|
|
void fungi_evolve_GPU(FungiSoA& pop,
|
|
|
const float* d_grad_map,
|
|
|
int evo_pairs,
|
|
|
float food=0.05f, float decay=0.98f, float death_th=-0.5f,
|
|
|
float cost=1e-3f, unsigned seed=1337);
|
|
|
|
|
|
|
|
|
void download_mask(float* h, const float* d, int HW);
|
|
|
|
|
|
|
|
|
void fungi_export_debug_images(const FungiSoA& pop,
|
|
|
const float* d_A, const float* d_P,
|
|
|
const float* d_grad_map,
|
|
|
const char* prefix = "debug");
|
|
|
|
|
|
void fungi_create_test_pattern(float* h_pattern, int H, int W, int pattern_type = 0);
|
|
|
void fungi_analyze_mask_statistics(const float* d_A, const float* d_P, int HW);
|
|
|
|