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

Change dot cluster behavior #36

Merged
merged 21 commits into from
Oct 7, 2024
Merged

Conversation

ll-nick
Copy link
Collaborator

@ll-nick ll-nick commented Jul 25, 2024

Closes #26

This should be the final behavior 🥳

I did go for a cluster segmentation algorithm (just a simple breadth first search) as opposed to the quadrant thing we discussed since it seemed more sensible when I started implementing it.

So we now split the dots into clusters (sets of connected dots) using the clustering algorithm in cluster.hpp. I did move the MazeAdapter and Cell class into maze.hpp and generalized it such that both the clustering algorithm and the A* could utilize these classes. For each cluster, we also compute the center by averaging the x and y coordinates and finding the dot closest to that position.

Given the clusters and their respective centers. the new behavior now plans a path from the current position to the center of the closest cluster except for the one that pacman might already be in and commits to it until one of the cluster dots has been reached.

There is one relatively unrelated commit in here:
c27930e Fixes a bug that caused a crash when pacman entered the tunnel while chasing or avoiding a ghost. It was a lot easier to fix on this branch because the positionConsideringTunnel function has been moved out of the A* class.

@ll-nick ll-nick self-assigned this Jul 25, 2024
@ll-nick ll-nick requested a review from orzechow July 25, 2024 13:25
@ll-nick
Copy link
Collaborator Author

ll-nick commented Jul 25, 2024

Ok, this one should be good to go as well. I had to build it on top of #35 therefore I set that as the target branch for now but it should go into the demo branch.

Base automatically changed from eat_closest_dot_behavior to pacman-demo September 24, 2024 09:01
@orzechow
Copy link
Member

orzechow commented Oct 4, 2024

I had to rebase on top of pacman-demo and resolve some minor conflics (introduced by the review changes of the previous PR, I guess)

See also 063ae1e for some more optional use in A* – please check, if that makes sense 😁

Copy link
Member

@orzechow orzechow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, good work!

Some nits, some code improvements, some style suggestions. Feel free to move on after considering my feedback

demo/test/astar.cpp Outdated Show resolved Hide resolved
demo/test/cluster.cpp Outdated Show resolved Hide resolved
demo/include/utils/maze.hpp Show resolved Hide resolved
demo/include/utils/maze.hpp Outdated Show resolved Hide resolved
demo/include/utils/cluster.hpp Outdated Show resolved Hide resolved
demo/src/cluster.cpp Outdated Show resolved Hide resolved
demo/src/cluster.cpp Outdated Show resolved Hide resolved
demo/src/cluster.cpp Outdated Show resolved Hide resolved
demo/include/demo/change_dot_cluster_behavior.hpp Outdated Show resolved Hide resolved
demo/src/change_dot_cluster_behavior.cpp Show resolved Hide resolved
This was referenced Oct 4, 2024
@ll-nick
Copy link
Collaborator Author

ll-nick commented Oct 7, 2024

Thanks for the rebase, the optional Path stuff (which I meant to add but obviously forgot) and the detailed review. I skimmed through it briefly and I'm afraid I agree with pretty much all of your suggestion 😂

@orzechow
Copy link
Member

orzechow commented Oct 7, 2024

Thanks for the rebase, the optional Path stuff (which I meant to add but obviously forgot) and the detailed review. I skimmed through it briefly and I'm afraid I agree with pretty much all of your suggestion 😂

image

@ll-nick ll-nick mentioned this pull request Oct 7, 2024
@ll-nick ll-nick merged commit bcf1f2d into pacman-demo Oct 7, 2024
@ll-nick ll-nick deleted the change_dot_cluster_behavior branch October 7, 2024 10:53
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