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

AI Reachable system #1342

Merged
merged 2 commits into from
Jul 11, 2020
Merged

AI Reachable system #1342

merged 2 commits into from
Jul 11, 2020

Conversation

metalgearsloth
Copy link
Contributor

Like the first third of a hierarchical pathfinder. This system prevents AI from trying to pathfind into areas they can't get to.
Previously it was Grid -> Chunks -> Nodes
Now there's also Grid -> Chunks -> Regions -> Nodes (where regions slot themselves into the existing system).

The reason for this is it's faster to traverse regions rather than nodes because regions are made up of tiles. My first attempt I tried just using the BFS pathfinder on nearby tiles so the AI could tell whether it could access a particular node but even with caching it was too slow.

Regions are created from areas of homogenous pathfinding nodes (i.e. all the same collision mask, all space etc.) within a single chunk, though currently walls are ignored for now.
There's probably a better data structure to use for regions but even this version gives a significant speedup for the AI checking whether it can access an entity or not. Plus some of the chunk update stuff is grossly inefficient.
AI can also re-use existing cached reachable regions as well.

Adds 2 commands for debugging:

  • pathfinder regions shows every region in different colours
  • pathfinder regioncache will show when the AI is checking for accessibility (green means cache is updated, blue means existing cache hit).

I also re-wrote the wander behavior so the idle AI should be SIGNIFICANTLY faster and not spamming out paths to places it can't get to twice a second.

For reference I know Factorio and Rimworld have their own hierarchical systems and this one falls more on the Rimworld side (though rooms aren't generated and the chunk update is inefficient).

Metal Gear Sloth added 2 commits July 10, 2020 22:28
Like the first third of a hierarchical pathfinder.
Previously it was Grid -> Chunks -> Nodes
Now there's also Grid -> Chunks -> Regions -> Nodes
The reason for this is it's faster to traverse regions rather than nodes because regions are made up of tiles.
Regions are created from areas of homogenous pathfinding nodes (i.e. all the same collision mask etc.) within a single chunk.
There's probably a better data structure to use for regions but even this version gives a significant speedup for the AI checking whether it can access an entity or not. My first version just tried using a BFS pathfinder for vision range but it was significantly slower, plus this version is more easily cached and AI can share their cache as well.
Adds 2 commands for debugging:
pathfinder regions shows every region in different colours
pathfinder regioncache will show when the AI is checking for accessibility (green means cache is updated, blue means existing cache hit).
@PJB3005 PJB3005 merged commit 51d08e8 into space-wizards:master Jul 11, 2020
@metalgearsloth metalgearsloth deleted the patriarchy branch October 11, 2020 09:50
rbertoche pushed a commit to rbertoche/space-station-14 that referenced this pull request Mar 16, 2023
TheArturZh referenced this pull request in TheArturZh/space-station-14 Aug 17, 2023
TheArturZh referenced this pull request in SerbiaStrong-220/space-station-14 Aug 17, 2023
Morb0 added a commit to Morb0/space-station-14 that referenced this pull request Sep 24, 2023
rbertoche pushed a commit to rbertoche/space-station-14 that referenced this pull request May 18, 2024
rbertoche pushed a commit to rbertoche/space-station-14 that referenced this pull request May 18, 2024
Erisfiregamer1 pushed a commit to The-Arcadis-Team/arc-station-14 that referenced this pull request Dec 17, 2024
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Ports jackboot slowdown mitigation from [space-wizards
github](space-wizards#30586).
Adds fake version for civilian use.

---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl:
- add: Added slowdown mitigation to jackboots
- add: Added fake jackboots for style outside of sec

---------

Co-authored-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com>
Erisfiregamer1 pushed a commit to The-Arcadis-Team/arc-station-14 that referenced this pull request Dec 17, 2024
rhit-eppersac pushed a commit to Kandiyaki/space-station-14 that referenced this pull request Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants