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

Using A* in SimCity201 #2

Open
dwilczyn opened this issue Nov 11, 2013 · 0 comments
Open

Using A* in SimCity201 #2

dwilczyn opened this issue Nov 11, 2013 · 0 comments

Comments

@dwilczyn
Copy link

There are some complications using my A* restaurant code in SimCity201.

  1. In the restaurant, all waiters share the same grid and have the same locations masked off limits for traversals by the waiters: the tables, the customer waiting area, and the cook's area.
  2. When each waiter computes a walk, A* sees the same grid with the same off limit areas and with grid location occupied by the waiters also unavailable.
  3. They all walk the same grid, resolving conflicts when two waiters want to walk into the same grid location. Remember, at the time of computing the walk, all grid locations in the computed walk WERE available. During runtime when waiters are walking, they could be competing for the same grid location.

SimCity is different in several ways:

  1. There is a shared grid for all agents to move on, just like in the restaurant.
  2. However, each agent has different grid locations on which it can move. A PersonAgent can only walk on sidewalks and street crossings. A vehicle can only move on roads.
  3. So each agent type must move only on squares of the right type I think the best solution is to take my AStarTraversal class, and make its expandFunc(Node n) abstract. ExpandFunc as written works for Restaurants, i.e. any position on the grid and with a permit was available. However, vehicles need and ExpandFunc that only looks at roads, while a person needs an ExpandFunc that only looks at sidewalks and street intersections. So, you will need an AStarTraversalForVehicles class and AStarTraversalPerson class that each extends the now abstract AStarTraversal class. only the ExpandFunc is different.
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

No branches or pull requests

1 participant