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

Eat closest dot behavior #35

Merged
merged 12 commits into from
Sep 24, 2024
Merged

Eat closest dot behavior #35

merged 12 commits into from
Sep 24, 2024

Conversation

ll-nick
Copy link
Collaborator

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

Closes #25

This adds the EatClosestDotBehavior.

The behavior itself is pretty simple as the heavy lifting is done within the A* class. Here's a brief summary of the changes:

  • There is now a getter for the TileType in the maze class. Before, it was only possible to check for walls, not for dots.
  • Add a predecessor to the cell class allowing to generate a path by traversing from the goal to the start via the predecessor property
  • Add a shortestPath function. computeDistance is now simply a wrapper that returns the length of the returned path
  • Add another interface to the A* class computing the path to the closest dot reusing most of the existing A* logic
  • Continuously update the maze withing the A* class since we now need the dynamic info about dot positions. It's just a pointer so it shouldn't be a big issue.
  • Add the closestDotBehavior to the Pacman Agent. For now I just added it to the main priority arbitrator. We need to change that after adding Add cost estimator #27
  • Yet another rename for clarity: the A* distance is now called mazeDistance because I replaced the function that used to return the euclidean distance by the manhattan distance since it's a better heuristic for A*.

I think that's about it. A couple of points I'm unsure about:

  • Should we also consider power pellets here or do we do that separately or not at all?
  • Is there a sensible heuristic for the closest dot path? Right now I just use 0 which is obviously a crappy heuristic but I couldn't think of anything else and I'm not sure if there is a better solution.

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

ll-nick commented Jul 29, 2024

About the heuristic: Using the manhattan distance from the start to the cell we are about to expand next might be slightly more useful than setting it to 0. With the 0, we basically have a breadth first search. It works but might be a little confusing.

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.

Thanks! Looks good!

Some minor suggestions, feel free to consider them and merge right away

demo/include/utils/astar.hpp Show resolved Hide resolved
demo/include/utils/astar.hpp Outdated Show resolved Hide resolved
demo/include/utils/maze.hpp Outdated Show resolved Hide resolved
demo/include/utils/astar.hpp Outdated Show resolved Hide resolved
demo/include/utils/maze.hpp Outdated Show resolved Hide resolved
demo/src/astar.cpp Outdated Show resolved Hide resolved
demo/test/astar.cpp Show resolved Hide resolved
@ll-nick ll-nick merged commit 980303a into pacman-demo Sep 24, 2024
@ll-nick ll-nick deleted the eat_closest_dot_behavior branch September 24, 2024 09:01
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