🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Whopper of an A* issue
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
Are you asking what the best way of representing the flight path data is?
If so, then my suggestion would be to create a digraph. Your pathfinding algorithm can use indexes into the graph to do its stuff.
Also, if your passenger''s itineraries have to be designed so that they pass through each of their chosen cities only once according to some criteria, then you have a version of the ol'' Travelling Salesman Problem on your hands. So A* may not be your best option…
ai-junkie.com
Dave Mark - President and Lead Designer
Intrinsic Algorithm - "Reducing the world to mathematical equations!"
RIPPL Sports - NFL Statistical Analysis and Prediction System
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
If this is correct, then I suspect that you will need to add time as a dimension in your tree. Thus, two flights arriving at a city that are more than two hours apart can actually be considered as two paths in the graph that terminate at different nodes in the tree. This should negate the problems of identifying different path costs for the same path (because now they''re not the same path).
As to storage of this information... you have a tree with a variable branching factor... you shouldn''t use arrays for this sort of tree. Rather, use a linked list at each node to represent connectivity to successor nodes.
Cheers,
Timkin
A = Origin
Z = Destination
The flight databasae holds the following:
(Flt#, Origin, Dest, Dep, Arr)
100: A-Z 9-11
200: A-B 8-9
201: A-B 9-10
300: A-C 8-9
301: A-C 9-10
400: B-Z 10-11
401: B-Z 11-12
500: C-Z 10-11
501: C-Z 11-12
Obviously, our pax could take flight 100 (direct). He could also take the following itineraries:
200, 400 = A-B-Z
200, 401 = A-B-Z
201, 400 = A-B-Z
201, 401 = A-B-Z
300, 500 = A-C-Z
300, 501 = A-C-Z
301, 500 = A-C-Z
301, 501 = A-C-Z
Now, conventional map systems would have each city as a different node. If this were the case, node A would be linked to B, C and Z. However, we now have to represent the idea that A-B can be done by either flight 200 or flight 201. As you say, Timkin, this would involve some sort of time dimension... or a "Z" value. The interesting point here is that this new "Z" location is more important than the X, Y location of a city.
The actual final fitness of each leg (and therfore the total itinerary) is based on comparing various properties of the flight with preferences of the passenger. That is, there is no ONE fitness value that can be pre-calculated. I will be having to apply the various properties of the flight combined with the preferences of the pax to determine the fitness level of each leg as we go. One of those preferences applies to the length of the trip - but this is only ONE of the factors and may be the least important for the passenger in question. That makes determining a relevant hueristic kinda nebulous. *shrug*
What I would expect to have to do is recalculate the map every time a flight is either added or deleted to get some sort of network on possibilities. Then once all the possible initial flights are selected (which have a wider time window than the connecting flights), I can itterate through those flights and their pre-calculated available connections. I would have to calculate the fitness values of all the next series of connecting flights before I sorted them, I realize.
I guess the trick to all of this just that there isn''t a fixed number of connections to select from like there are in nice tidy maps.
Dave Mark - President and Lead Designer
Intrinsic Algorithm - "Reducing the world to mathematical equations!"
RIPPL Sports - NFL Statistical Analysis and Prediction System
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
The problem with a simple linked list or tree is that there can be litterally an infinate number of connections from any given node
Maybe I misunderstand, but you only add a city connection to a graph node if the plane can fly directly to it. In your example (because we stay on Earth), even given the scheduling considerations, there will always be a finite amount of connections.
ai-junkie.com
Dave Mark - President and Lead Designer
Intrinsic Algorithm - "Reducing the world to mathematical equations!"
RIPPL Sports - NFL Statistical Analysis and Prediction System
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
It''s how the graph is searched that is problematical.
by the way, what''s a "pax"?
ai-junkie.com
Can you help me out with the hash table concept... I remember looking it up on a conceptual level before, but I didn''t get in too deep on it. How would we apply it here?
Dave Mark - President and Lead Designer
Intrinsic Algorithm - "Reducing the world to mathematical equations!"
RIPPL Sports - NFL Statistical Analysis and Prediction System
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
Each city holds a linked list to all the flights that depart from the city. Each flight has a number of variables, which can be combined in different ways to produce a heuristic function for how good that ride is. Divide your pax in a few distinct categories, each category having a different heuristic (favoring speed or comfort or safety records or time wasted or business facilities etc.) Let''s say each flight has a negative heuristic value and the heuristic value for a travel is the sum of the value of each flight (and of each wait) in the travel. Each passanger wants to get the value as high as possible.
Now, for each city, for each pax category (for each heuristic), do this:
Calculate the best (according to the current heuristic) way to get there in 1, 2, 3, ... hours. Here''s where the dynamic thing enters stage.
Have a 2d array with the city as a dimension and time as another dimension. I assume all flights launch and land only at fixed hours. The meaning of a x/y cell in this table is: "The best way to get to city x in y hours is worth table[y][x] heuristic points"
Fill the array with a _very_ large negative number. Set to 0 the value of current city/time 0 in the table (the passanger is already at the airport). Now you run through all the cells in the table, starting with the present and advancing one hour at a time. At each cell, you consider boarding any flight that departs from that city at that hour or waiting another hour.
The result of each decision is easily calculated: you get a destination city (the same if your passanger waits), a destination hour (current cell time + 1 for waiting, current time + flight time else) and a heuristic specific cost (current cell cost + flight cost/waiting cost). You basically get a new potential value to store in your table. Compare this value against the one already in the table. Update the table only if the new cost is better.
Finding the best paths for each passanger is pretty easy from now on.
Run this algorithm at each hour for each city for each heuristic. Complexity is:
no of cities squared * hours ahead * no of flights departing in a city * number of heuristics. For 200 cities, 24 hours ahead, 10 heuristics and 10 flights for each city, you get something like 100.000.000 of operations.
Actually, this sounds a lot like what Timkin proposed.