Skip to content

Commit

Permalink
Moved trail diffusion algorithm to the diffuse_trail global function
Browse files Browse the repository at this point in the history
The functions from fucking_shit.* will be rearranged someday, so the diffusion algorithm will most likely be moved somewhere again, but who knows...
  • Loading branch information
kolayne committed Sep 19, 2020
1 parent 7db6ba5 commit c23152d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 12 additions & 0 deletions src/fucking_shit.cu
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ namespace jc = jones_constants;
}


__host__ __device__ void diffuse_trail(MapNode *node)
{
auto left = node->get_left(), top = node->get_top(), right = node->get_right(), bottom = node->get_bottom();

double sum = top->get_left()->trail + top->trail + top->get_right()->trail +
left->trail + node->trail + right->trail +
bottom->get_left()->trail + bottom->trail + bottom->get_right()->trail;

node->temp_trail = (1 - jc::diffdamp) * (sum / 9.0);
}


__host__ __device__ int count_particles_in_node_window(MapNode *node, int window_size)
{
for(int i = 0; i < window_size / 2; ++i)
Expand Down
8 changes: 1 addition & 7 deletions src/main_logic.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,7 @@ __device__ inline void run_iteration_diffuse_trail(SimulationMap *const simulati
MapNode *self;
RUN_ITERATION_SET_SELF(self, node_index)

auto left = self->get_left(), top = self->get_top(), right = self->get_right(), bottom = self->get_bottom();

double sum = top->get_left()->trail + top->trail + top->get_right()->trail +
left->trail + self->trail + right->trail +
bottom->get_left()->trail + bottom->trail + bottom->get_right()->trail;

self->temp_trail = (1 - jc::diffdamp) * (sum / 9.0);
diffuse_trail(self);
}

/**
Expand Down

0 comments on commit c23152d

Please sign in to comment.