Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the diffuse_trail function, moved its body to run_iteration_diffuse_trail #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/main_logic/simulation_logic.cu
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ 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
13 changes: 0 additions & 13 deletions src/main_logic/simulation_logic.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@
*/
[[nodiscard]] __device__ bool delete_particle(MapNode *node);

/**
* Diffuses trail in the given node
*
* The diffusion algorithm (developed by Jeff Jones) is pretty simple at first sight. We calculate an average
* `trail` value in a 3x3 node window around the given one and multiply it by `(1 - jones_constants::diffdamp)`.
* The new `temp_trail` value in the given node is the value just calculated. This is a natural way to implement the
* smell spread: on each iteration smell moves more far from the source, but becomes less strong, because
* `(1 - jones_constants::diffdamp)` < 1
*
* @param node Pointer to the node to diffuse trail at
*/
__host__ __device__ void diffuse_trail(MapNode *node);

/**
* Returns number of particles in a node window around the given node
*
Expand Down
8 changes: 7 additions & 1 deletion src/main_logic/simulation_motor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ __device__ inline void run_iteration_diffuse_trail(SimulationMap *const simulati
MapNode *self;
RUN_ITERATION_SET_SELF(self, node_index)

diffuse_trail(self);
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);
}

/**
Expand Down