diff --git a/src/fucking_shit.cu b/src/fucking_shit.cu index afe0128..e49b124 100644 --- a/src/fucking_shit.cu +++ b/src/fucking_shit.cu @@ -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) diff --git a/src/main_logic.cuh b/src/main_logic.cuh index 23f4b01..9e0e44c 100644 --- a/src/main_logic.cuh +++ b/src/main_logic.cuh @@ -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); } /**