fix: FlexiblePathfinding migration follow-ups#92
Conversation
Formatted `critter`, `doRandomMove`, `hostileCritter`, and `stray` behavior files with indent of 2 spaces.
The structure of having a guarded behavior lookup (`flee`) and a fallback behavior lookup (`stray`) to me looks like we're good with running nodes until we find the first one that is successful.
Applies simple refactorings such as renaming or inversion of return values to make the code defining the action more readable. In addition, added a comment to discuss whether this should be a (complex) action or rather a behavior.
In addition, adds a couple of debug logs to investigate the control flow when running the action. These debug lines revealed that exceptions during the execution of an action are treated as failed actions. The behavior tree runner logs a warning, but it is easy to miss...
Annotate methods of MinionMoveComponent with Javadoc (and questions) to understand the internals of that component better. Improve logging of MoveToAction and SetTargetToNearbyBlockNode.
|
I just noticed that the now pathfinding-based For (1) we need to investigate why it times out after having found what appears to be a valid path (and judging from the debug path visualization actually is a reasonable path). |
- add log messages when entering a behavior: critter (root), doRandomMove, naiveMoveTo, stray
Now prints out messages in the format: ``` 17:43:24.551 [main] DEBUG o.t.m.behaviors.actions.LogAction - Actor 2502: ---- critter ---- ```
…ehavior" This reverts commit f4444b3.
The pathfinding plugins assume that entities are not affected by gravity. To match this assumption, we chose a movement mode that neglects gravity, but works similar to the regular walking mode: FLYING.
Without this check, we can end up with target blocks that are not walkable, screwing up the pathfinding logic. This small addition will fail the behavior action when the target is not walkable, in the hope that we'll just give it another try. Several ideas on how to further improve this behavior action are added as TODO comments.
This is a special movement plugin that will enable gravity on entities while they are using the falling movement mode.
- only accept candidate if it increases the distance to the start block
…x/behavior-follow-ups
|
Locally, there is a single failing test case for me now: All the other (positive) test cases pass nicely, usually in under 3 seconds per test case, summing up to a bit less than 2 minutes of execution time. The result is the same on CI, about 50% slower than running test locally with an execution time of 2min 40s. |
Extract many tests cases from Terasology/Behaviors#92 to tests on the pathfinding itself. Most importantly, this allows us to run these tests as unit tests instead of long-running integration tests using MTE.
| set_target_nearby_block : { moveProbability: 65 } | ||
| }, | ||
| move_to | ||
| { log: { message: "in doRandomMove Behavior"} }, |
There was a problem hiding this comment.
do we want to keep this and similar log messages in behavior trees and also in code in for the time being and clean them up later or should we remove them before merging this so we don't forget about them?
There was a problem hiding this comment.
I'll add some doc comment to LogAction and remove those debug statements.
skaldarnar
left a comment
There was a problem hiding this comment.
Overall, this PR now does the following:
- style: format
.behaviorfiles - chore: add TODO ideas and questions in several places
- chore: add some debug logging
- feature/fix: small adjustments to Behaviors logic
None of the remaining debug log statements does any heavy computation, so it's fine to keep them in (for now) as they are not logged with the default configuration but might prove useful for debugging purposes.
LGTM
| Vector3ic[] allowedBlocks = Iterators.toArray( | ||
| Iterators.transform(Iterators.filter(neighbors.iterator(), | ||
| (candidate) -> plugin.isReachable(currentBlock, candidate)), | ||
| (candidate) -> candidate.distanceSquared(startBlock) > currentDistance |
There was a problem hiding this comment.
This condition is probably not very good as it easily runs into local dead ends, but it at least prevents us from jumping back and forth while searching... We have a TODO below to improve on this.
.behaviorfilesFollow-up PR to #89.
Related PRs (extracted from this): #94, #96, #97, #99.
Contributes to MovingBlocks/Terasology#4981.
Depends on Terasology/FlexiblePathfinding#26 and Terasology/FlexiblePathfinding#27.