From: Randy McShandy Date: Sat, 27 Apr 2024 21:51:03 +0000 (-0500) Subject: Adding more stuff lmao, maybe barrow crawler time X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=b95485bd6bada565fbe36aba2591c6698edf5c21;p=barrow_crawler Adding more stuff lmao, maybe barrow crawler time --- diff --git a/main.c b/main.c index 6efd62d..7397f42 100755 --- a/main.c +++ b/main.c @@ -3,20 +3,20 @@ int main(int argc, char** argv) { - - RD_Opts meiosis_2 = + RD_Opts barrow_circ = { .max_iterations = 1e4, .diff_a = 0.8f, - .diff_b = 0.4f, - .feed = 0.0367f, - .kill = 0.0649f, - .delta_t = 1.0f, + .diff_b = 0.3f, + .feed = 0.058f, + .kill = 0.066f, + .delta_t = 0.6f, - .name = "meiosis_2" + .name = "puffer", + .shape = eCircle }; - generate_rd(4, puffer); + generate_rd(8, barrow); return 0; } diff --git a/structs.c b/structs.c index fa2591f..3cc769c 100644 --- a/structs.c +++ b/structs.c @@ -12,7 +12,22 @@ RD_Opts puffer = .kill = 0.062f, .delta_t = 0.6f, - .name = "puffer" + .name = "puffer", + .shape = eCircle +}; + +// diff values influence tightness, delta between them shouldn't get wider than ~0.5 or narrower than ~0.4 +RD_Opts barrow = +{ + .max_iterations = 1e4, + .diff_a = 0.8f, + .diff_b = 0.3f, + .feed = 0.055f, + .kill = 0.062f, + .delta_t = 0.6f, + + .name = "puffer", + .shape = eBarrow }; RD_Opts worms = @@ -24,7 +39,8 @@ RD_Opts worms = .kill = 0.06f, .delta_t = 0.6f, - .name = "worms" + .name = "worms", + .shape = eSquare }; RD_Opts meiosis = @@ -36,7 +52,8 @@ RD_Opts meiosis = .kill = 0.0649f, .delta_t = 1.0f, - .name = "meiosis" + .name = "meiosis", + .shape = eSquare }; const Mat3 laplacian_kernel = diff --git a/structs.h b/structs.h index 50153bb..0673129 100644 --- a/structs.h +++ b/structs.h @@ -6,6 +6,13 @@ #define GRID_X 128 #define GRID_Y GRID_X +typedef enum +{ + eSquare = 0, + eCircle, + eBarrow +} Shape; + typedef struct { double v[3][3]; @@ -16,6 +23,7 @@ typedef struct { float a; float b; + float c; } FVec2; typedef struct @@ -28,6 +36,8 @@ typedef struct double delta_t; char name[32]; + + Shape shape; } RD_Opts; typedef struct @@ -46,6 +56,7 @@ typedef struct int worker_id; } worker_arg; +extern RD_Opts barrow; extern RD_Opts puffer; extern RD_Opts worms; extern RD_Opts meiosis; diff --git a/utils.c b/utils.c index 28664a1..c58bda4 100644 --- a/utils.c +++ b/utils.c @@ -6,7 +6,7 @@ #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" -#define SHADOW 0 +#define SHADOW 1 #if SHADOW #define printf(a,...) #endif @@ -100,6 +100,8 @@ void* iterator(void* _arg) for (int y = start_y; y < h + start_y && y < GRID_Y; y++) { FVec2 each = grid[x][y]; + if (each.c >= 0.5f) + each.b = 1.0f; grid_prime[x][y].a = rd_a_prime(grid, opts, x, y, laplacian_kernel, each.a, each.b); grid_prime[x][y].b = rd_b_prime(grid, opts, x, y, laplacian_kernel, each.a, each.b); } @@ -157,19 +159,73 @@ int initialize(int worker_count, RD_Opts active_opt) srand(time(NULL)); + float radius = GRID_X/2.1f; + int center_x = GRID_X/2; + int center_y = GRID_Y/2; for (int x = 0; x < GRID_X; x++) { for (int y = 0; y < GRID_Y; y++) { grid[x][y].a = 1.0f; grid[x][y].b = 0.0f; + + switch (active_opt.shape) + { + case eCircle: + { + if ((sqrtf(((x-center_x)*(x-center_x))+((y-center_y)*(y-center_y))) < radius)) + { + grid[x][y].c = 0.0f; + } + else { + grid[x][y].c = 1.0f; + } + } break; + + case eSquare: + default: + { + grid[x][y].c = 0.0f; + } break; + + case eBarrow: + { + if ((sqrtf(((x-center_x)*(x-center_x))+((y-center_y)*(y-center_y))) < radius)) + { + grid[x][y].c = 0.0f; + } + else { + grid[x][y].c = 1.0f; + } + + // Slap in an entrance or something here + // or add support for post-processing + + } break; + } } } - const int max_rand = sqrt(GRID_X); - for (int n = 0; n < max_rand; n++) + const int seed_count = sqrt(GRID_X) * 1; + const int width = 4 * (GRID_X/128); + const int height = width * 1; + for (int n = 0; n < seed_count; n++) { - grid[rand() % GRID_X][rand() % GRID_Y].b = 1.0f; + int rand_x = rand() % GRID_X; + int rand_y = rand() % GRID_Y; + grid[rand_x][rand_y].b = 1.0f; + grid[rand_x][rand_y].c = 0.0f; + + for (int x = rand_x-(width/2); x < rand_x+(width/2); x++) + { + for (int y = rand_y-(height/2); y < rand_y+(height/2); y++) + { + if (y >= GRID_Y || x >= GRID_X || y < 0 || x < 0) + continue; + // Third parameter for permanent presence of B chemicals (black) + grid[x][y].c = 1.0f; + } + } } warg = (worker_arg){ @@ -216,7 +272,6 @@ int generate_rd(int worker_count, RD_Opts active_opt) { initialize(worker_count, active_opt); - // Would be smart to set up a semaphore and move per-workload processing here while(!should_quit) {} printf("Opts: {\nIterations: %d\nTime delta: %f\nDiffA: %f\nDiffB: %f\nFeed: %f\nKill: %f\n\n}\n", active_opt.max_iterations, active_opt.delta_t, active_opt.diff_a, active_opt.diff_b, active_opt.feed, active_opt.kill);