-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add THST and doctest #3534
Open
Linvail
wants to merge
11
commits into
dkfans:master
Choose a base branch
from
Linvail:feature/battlefield-awareness
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add THST and doctest #3534
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The current performance of using ranged buffs is not good. It requires one search for each ranged buff instance. The search results cannot be retained, and they cannot benefit future usages. This change adds scan_nearby_creature(), which runs every turn. For each creatures, it scan nearby area and collect creatures within CREATURE_SCAN_RANGE_MAX, and record found creatures in the CreatureControl.creatures_nearby. This CreatureControl.creatures_nearby is an sorted array by the distance in ascending order. It can be used in many places, especially useful for ranged buffs. It will benefit the combat(searching targets) in the future. Since the allied creatures are also included, so we can extend our ranged buffs to allies. The new property - APPLY_TO_ALLIES is added. Type: New Feature
Add new function: get_nth_creature_with_filter() This is a creature-specialization of get_nth_thing_of_class_with_filter. Instead of the entire map, this one only searches the CreatureControl.creatures_nearby array of the input creature, so the search base is much smaller. Type: Optimization
Linvail
changed the title
Feature/battlefield awareness
Store nearby creatures in GameControl
Oct 8, 2024
This is my preliminary work for the mass/group ranged buffs. |
Still a draft, not tested, but the design is almost fixed. |
Linvail
commented
Oct 9, 2024
This reverts commit d86cd80.
This reverts commit 4d4b08f.
Change-Id: Ibd169e49d01fadab7bb3fe4aca9d0bd104734eff
* THST: Templated hierarchical spatial trees designed for high-performance and hierarchical spatial partitioning use cases. It improves the performance of the handling of ranged buffs. Here are some test reports. https://github.com/Linvail/keeperfx/wiki/Test-THST-on-keeperfx-for-querying-nearby-creatures https://github.com/Linvail/keeperfx/wiki/Test-THST-on-keeperfx-for-querying-nearby-creatures-2 * doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of magnitude) and runtime compared to other feature-rich alternatives. We use it to create test programs. Type: New Feature Change-Id: Ie0857b57cc00badf1ba46c2f589ed0a4f6a6b546
walt253
reviewed
Nov 4, 2024
Change-Id: I838cd7adb4f8e7a34d2ed8c99e8224a2c5bde2cb
Prevent multiple creatures from casting the same spell on the same target. For example, assuming Time Mage can cast the Ranged Speed, if we put 4 Time Mages and 4 Dragons in the same room, 4 Dragons will get the Speed effect. Those Time Mages will not cast the Ranged Speed on the same target. Type: New Feature Change-Id: Ibc408f0ae2cf154db84e51bdf6067fbfefcff0f6
doctest allows us to write test cases in the main program's code without making a new source code file. To facilitate that, I move doctest to the submodule folder. All submodules should be put here in the future. Also add README and LICENSE for THST. Type: Code Improvement Change-Id: I9d2da6a6d5cd7608e7c7872df8313d48bd5cd0fd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add THST and doctest
high-performance and hierarchical spatial partitioning use cases.
It improves the performance of the handling of ranged buffs.
Here are some test reports.
https://github.com/Linvail/keeperfx/wiki/Test-THST-on-keeperfx-for-querying-nearby-creatures
https://github.com/Linvail/keeperfx/wiki/Test-THST-on-keeperfx-for-querying-nearby-creatures-2
both in compile times (by orders of magnitude) and runtime compared
to other feature-rich alternatives.
We use it to create test programs.
With the help of THST, the following improvements are introduced.
For example, assuming Time Mage can cast the Ranged Speed, if
we put 4 Time Mages and 4 Dragons in the same room, 4 Dragons
will get the Speed effect. Those Time Mages will not cast the
Ranged Speed on the same target.
Type: New Feature
Change-Id: Ie0857b57cc00badf1ba46c2f589ed0a4f6a6b546