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

Improved route finding #598

Open
tuomount opened this issue Apr 12, 2023 · 6 comments
Open

Improved route finding #598

tuomount opened this issue Apr 12, 2023 · 6 comments
Labels
AI Game AI related issue enhancement Feature request Game mechanics New game feature to game mechanics
Milestone

Comments

@tuomount
Copy link
Owner

Improved route finding when starmap has been explored around the route. If starmap has explored are where route is being laid and there is blocked sector on way(Black hole, star or gas giant) A* pathing should be used to find best route around it. This is quite challening since it should not work on unexplored parts of star map or if there are cloaked enemy ships those should not be exposed when plotting the route.

@tuomount tuomount added enhancement Feature request AI Game AI related issue Game mechanics New game feature to game mechanics labels Apr 12, 2023
@tuomount tuomount added this to the 0.25.0Beta milestone Apr 12, 2023
@tuomount tuomount modified the milestones: 0.25.0Beta, 0.26.0Beta Nov 25, 2023
@tuomount
Copy link
Owner Author

Moving this to 0.26.0

@tuomount tuomount modified the milestones: 0.26.0, 0.27.0 Dec 21, 2023
@tuomount tuomount modified the milestones: 0.27.0, 0.28.0 Sep 29, 2024
@mauof
Copy link

mauof commented Oct 27, 2024

Hi, I am a CS university student and I would love to try working on this issue for one of my lecture. Would that be okay with you, do you think it this issue is suitable?

@tuomount
Copy link
Owner Author

Of course you can try. Does your course require that you need get it to main branch?

@mauof
Copy link

mauof commented Oct 27, 2024

Thank you. While merge is not technically absolutely necessary, it would make the evaluation quite a bit easier. Of course, considering my contribution is actually working. Do you maybe have some pointers or tips where I should be looking in the code and what to be careful about?

@tuomount
Copy link
Owner Author

Project already has A* algorithm implemented but it never has been used for whole starmap. This would definitely get most optimal way, but it might be heavy on CPU. Specially if you think that player should be able to move mouse cursor quite fast, so calculating route should not take long.

My idea was something like this:
image
So there one wants to move from point A to point B. Direct line is blocked by a star. Algorithm would check route from up and down side of the star and either of those as new point. Then continue from there towards point B. If there is something blocking the way then again check from up or down which route to select.

Problem with this is that routes need to have more points, now they only have single target point. Currently starmap travel is done with org.openRealmOfStars.starMap.Route.java. So I would add array of intermediate points in route class and try to move from there. Calculating the route also requires starmap information and playerinfo in order to get what scanners can actually see while planning the route.

@tuomount
Copy link
Owner Author

What you also need is PlayerInfo.java getSectorVisiblity() method to resolve if sector has been charted or not. If it has been charted then you can StarMap.java isBlocked() method to check if sector is blocked. A* algorithm might not be that suitable also for reason that FTL drives use straight line instead of moving single sector at once.

And in my previous post that straight line from A to B going horizontally is a bit special case since checking the reroute is simply up and down, but I think it would be better to use trigonometry and take 90 degrees off from the original direction and check if reroute is possible on that line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Game AI related issue enhancement Feature request Game mechanics New game feature to game mechanics
Projects
None yet
Development

No branches or pull requests

2 participants