#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
-#define SHADOW 0
+#define SHADOW 1
#if SHADOW
#define printf(a,...)
#endif
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);
}
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){
{
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);