-
Notifications
You must be signed in to change notification settings - Fork 196
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 new path finding command 2001 #3144
base: master
Are you sure you want to change the base?
Conversation
It seems like Debian's presumably old g++ doesn't like the exact way the hash function looks like. I suppose way way to fix it would be to no longer nest it inside the |
2bba040
to
e161986
Compare
Converting to draft for now since there seems to be a path finding bug remaining where the path isn't found when it should be. jetrotal is helping me debug, should hopefully have a fix in a day or two. |
b7648fc
to
914a46c
Compare
Nope, didn't fix it. I'm actually clueless why the Debian 10 g++ is unhappy then. If anyone knows, happy for pointers. |
@Ghabry Since you commented soon you'll have some time to check this one... |
Regarding lag, you could alternatively for example add a sleep/wait into your parallel event to not run the path finding every frame. Of course that means sometimes it'll set the route with a slight delay but it shouldn't be too bad. (And it would then still react to doors, albeit also with sometimes a delay.) As for Debian, the main reason I haven't done anything about it yet is that I'm simply clueless so far what even the problem is. I tried multiple variants to specify the set hash function, debian 10's g++ doesn't like any of them. I'm really not sure why it doesn't like them, the error suggests a wrong type or wrong function signature for the hash function to me, but I can't really figure out why it claims that. Maybe it's a compiler bug? I'm not sure how to address it. |
914a46c
to
c284ebb
Compare
For what it's worth, @jetrotal suggested some behavioral changes that could make this more intuitive to use and less performance intensive, and there were some pretty good ideas that I still have to test out. But the plan is that I test with the actual 2K3 editor first and compare how other movement route commands behave. Once I got that all checked out and adjusted, I'll undraft this again. (I'm assuming it's better to figure this out now before merging, so that people don't start to use it already and then the behavior suddenly unnecessarily changes with a later update.) However, there shouldn't be any massive changes upcoming anymore, so if anyone wants to have an initial look at the overall code quality now wouldn't be a bad time. |
Hi Ellie, thanks for working and improving this 🙏 But, I'd say your pr is looking good, and I'm willing to keep testing it while its being updated tnx again! |
Hey. Please don't feel discouraged when their is no feedback for a while. We are close to 0.8.1 release and want to get most of the stuff sorted out first before I look at the "lower priority" stuff like your new features. I like this new command but right now cannot look more at it, sorry. |
No problem, no need to rush. I might also be busy for the next 3-4 weeks or so, so the final changes might also take me a bit. I won't be going anywhere if this still takes a bit, no worries. |
bcb7e13
to
0c51b41
Compare
After some discussion I propose a split into two separate commands: "Smart Move Route" (2001):
and this one: "Smart Step Toward" (2002):
|
0c51b41
to
d34a460
Compare
Since I saw this pull request mentioned elsewhere, I'm still interested in helping out with getting it across the finish line once there's a good opportunity. It's mostly a draft since I'm hoping for more input. |
Here's one suggestion (idk if there's time to suggest until 8.1 release)... A parameter to disable diagonal path finding:
|
Co-authored-by: MackValentine <[email protected]> Co-authored-by: Mauro Junior <[email protected]>
d34a460
to
64d6d75
Compare
I like it, I added a first test version but I didn't test if it compiles. Still waiting for liblcf for half an hour or so, then I'll fix it if it doesn't. |
about There are now enums available:
|
049dd2a
to
ed19385
Compare
It should now build again, and I added a description of |
@jetrotal would you be up for testing how the diagonal movement disabling acts like? I remember you having a few useful test maps. |
@ell1e sorry for the slow feedback here. I'm still working on getting this in for 0.8.1. Just to make the meaning of Search steps defines the upper bound of the iterations the pathfinding algorithm can do before it gives up. Reducing this number can improve the performance but can fail to reach the goal. After the pathfinding finishes the route steps defines how many tiles (upper bound) from the current location the event will move towards the target. Reducing this number does not affect the performance as this only truncates after the path finding algorithm finished. |
Yes, that's correct. The main use case for maxRouteSteps is to do a single step e.g. in a parallel event, and the main use case for maxSearchSteps is to configure a performance vs. quality trade-off. Edit: and since there's a separate command for a single step, the normal user probably will never use maxRouteSteps manually. But I thought why not leave it available for some weird use case I'm not thinking of, since the option is needed internally anyway. (And "Smart Step Toward" 2002 won't replace the route if the character is already moving at the time, but "Smart Move Route 2001 with maxRouteSteps=1 would, so I guess there's technically still a different use case possible.) |
Okay while you are around I directly have a second question about the semantics of if (abortIfAlreadyMoving && event->IsMoving())
return false;
CancelMoveRoute(); Based on your implementation: When When its 1 and the Event is not moving: Same as 0 When its 1 and the Event is moving: The code returns Is that intentional? |
No, that's a bug. The command is supposed to act like it completed successfully. Thanks for catching it, I'm not very familiar with how the interpreter works. Would it need to return Edit: it makes me wonder though, if abortIfAlreadyMoving should be renamed doNothingIfAlreadyMoving. And perhaps we should get @jetrotal to test the fixed version just to make sure the parallel use keeps working as intended. |
Okay I thought it's maybe intentional to make the timing for One Step Forward simpler. This way you can just make the command "hang" until the event is ready to be moved again. I'll think about it. |
I'm pretty sure you could still do that by just using the 2001 Smart Route with maxRouteSteps=1 which would replace the route entirely, but effectively this still waits until the current tile movement is completed. This is I think what "One Step Forward" would do if issued as a set movement route. |
hm, you are right. I'll do the further commits as I also relocated some of the code to |
Is now only a single command again that can be configured through an editor plugin.
ed19385
to
e40c1cd
Compare
As already preannounced by Jetrotal I replaced the string parsing with integer parameters as it is now possible to write our own editor plugins. "Smart Move Route" and "Smart Step Forward" were unified into one command "Pathfinder". Instead the values for these two are provided as templates via buttons in the editor interface (with the values you suggested). The pathfinding code itself was relocated to Summary: The argument parsing was replaced, the pathfinding algorithm itself is the same. Thanks. Plugin for latest Maniac Patch Editor |
This adds a new path finding command with initial code by @MackValentine that I fixed up, and @jetrotal helping out coordinating the whole thing. It's based on the new CheckWay command added in #3120 and #3130 and can be used via event command 2001. It has a few special options which are documented in the doc comment that allow ignoring other events in the pathing (they won't be ignored in the actual collision!). The command is intended to both work for a use case where it's used once and then sets a movement route that is just left to execute, as you would in an autorun event, and for a use case where it's used repeatedly in a parallel event to continuously update the route to a moving target.
Behavior quirks: The current algorithm is a breadth first search, so it's not full A* yet. I might update it to an A* later if I get around to that, for now it seemed more relevant to get it to work properly with all the options people may want to use. It uses a search cutoff to avoid huge lag even when used constantly in parallel events by multiple moving things. Whenever a target is too far away to be safely located within that cutoff the command will set a guessed, approximate route. This means if the target is too far away the search might get lost and route into wrong sections of the map, this isn't a bug.
Another edit/additional note: I should be available also in the longer term if something with this code breaks to look into it.