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

Better, Faster Scent #4591

Merged
merged 1 commit into from Nov 24, 2013

Conversation

Projects
None yet
3 participants
@phaethonfire
Copy link
Contributor

commented Nov 23, 2013

I have big ideas for how scent could be reworked, but this PR is just a simple, clean improvement on the current system. It does the following:

  • adds diffusivity as a constant that can be tuned
  • adds conservation of mass. In the old system, when scent diffused, it was added to the new square without being subtracted from the old one.
  • improves performance by eliminating some duplicate calls to get scent values and to see if a square is "used" when diffusing out. This is reflected in a new loop that creates intermediate values. New loops are bad, but doing it this way also let me delete a loop that just did a copy step, so the total number of loops in this code stayed the same.

Scent trails aren't as wide as before, and they disappear more slowly (which both address requests from the forums). Scent trails are still limited by the scent radius, which is only 40 squares.

I tested performance of this algorithm (in a different git branch, not in this PR) by editing game.cpp to time how long it took update_scent() to run. The edits for testing performance looked like this:

include

...
clock_t start_time = clock();
update_scent();
clock_t finis_time = clock();
running_total += ((double) (finis_time - start_time)) / CLOCKS_PER_SEC;
if (int(turn) % 100 == 0) {
debugmsg ("updating scent consumed %f seconds thus far", running_total);
}

From testing an early game character, it seems to be ~25% faster.

Note: experimental build doesn't work on Mac right now because of some warning in the JsonSerializer class. I wasn't able to double check these changes by building locally. I did copy this exact code into a slightly older experimental build and it worked. It should be ready to go. We'll see if Jenkins likes it...

@Zireael07

This comment has been minimized.

Copy link
Contributor

commented Nov 23, 2013

Jenkins likes it and so do I :)

@atomicdryad atomicdryad merged commit 1e2b17b into CleverRaven:master Nov 24, 2013

1 check passed

default Merged build finished.
Details

@phaethonfire phaethonfire deleted the phaethonfire:new_scent branch Nov 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.