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

Allow the creation of recursive HTNs #30138

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

osjarw
Copy link
Contributor

@osjarw osjarw commented Jul 17, 2024

About the PR

Added a limit to the maximum amount of tasks a plan can consider.
Gave the developers a way to exclude their compound tasks from being checked for recursive tasks by the integration test.

Why / Balance

Recursive tasks make the creation of longer plans a lot easier, and solving multiple problems in a single plan becomes more viable.
However, allowing the creation of recursive tasks may lead to cases where the tasks misbehave and continue extending a plan indefinitely. I solved this problem by setting a limit to how many tasks can be considered, and upon exceeding the amount, the NPC will be disabled, alongside throwing an exception to make the developers aware of the existence of a misbehaving NPC.

Technical details

Added AllowRecursion to HTNCompoundPrototype, setting this to true makes the integration test ignore this task being recursive. This being opt-in ensures that unintentionally recursive tasks aren't merged.

Made HTNPlanJob.Process keep track of how many tasks have been considered, and throw an exception upon exceeding the limit set in HTNPlanComponent. If for some reason 1000 tasks isn't enough, it can be overridden on a per-entity basis.

I guess I could've done this a lot better if I had better understanding of how the yml serialization works.

Media

  • I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

Changelog

@osjarw osjarw requested a review from metalgearsloth as a code owner July 17, 2024 21:17
@github-actions github-actions bot added the S: Needs Review Status: Requires additional reviews before being fully accepted label Jul 17, 2024
@metalgearsloth metalgearsloth merged commit 669cc55 into space-wizards:master Jul 30, 2024
13 checks passed
themias pushed a commit to themias/space-station-14 that referenced this pull request Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: Needs Review Status: Requires additional reviews before being fully accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants