AI: Path finding and learning.

Nov 23, 2010 at 5:31am
Hi everyone, please give me ideas behind path finding. Basically I want make a program that has a maze like pacman with starting and ending point. Then the AI(player/ball) needs to find its way to the ending point. The second problem is that the AI should be more intelligent for the second try meaning bypassing dead ends that it already met.

I just need ideas, and also please tell me what field or subject of mathematics should I understand if it's going to need mathematical calculations. Advance thanks everyone :)
Last edited on Nov 23, 2010 at 5:32am
Nov 23, 2010 at 8:18am
You should check A*, it's an excellent path-finding algorithm that supports adding values per tile of how much "cost" there is to move onto that tile. If you make the cost of a dead-end hallway high enough, he will never pick it.
Nov 23, 2010 at 2:13pm
Thanks, I'll check it out later. This is a self project so I don't have to rush myself. I'll post again later after reading on it. I'm still open for replies though.
Nov 23, 2010 at 2:52pm
A* is the way to go, here's a begginers introduction: http://www.policyalmanac.org/games/aStarTutorial.htm You might also want to read up on Graph Theory.

Some more reading:
http://en.wikipedia.org/wiki/Shortest_path_problem
http://en.wikipedia.org/wiki/A*_search_algorithm
Last edited on Nov 23, 2010 at 2:58pm
Nov 23, 2010 at 3:36pm
@Kyon and Return 0
I took a little read on A* and I'll read more tomorrow and it seems to find the shortest path at one go. I was hoping something that explores the map then find its way to the end. On the second go, it then use its experience (maybe save in a file or something) to do better decision.
Nov 23, 2010 at 3:47pm
A* explores the map until it gets to the ending point. Then it stops.
The power of this algorithm lies in the fact that it often doesn't need to explore the whole map, before it can be sure it has found the shortest path.
Nov 23, 2010 at 3:58pm
Blackcoder, as I said, you can set a value per node that indicates the "cost" to pass that node. Making an earlier visited node have an infinite "cost" will mean that this particular node cannot be visited (because it is dead end).
Nov 23, 2010 at 6:43pm
I was hoping something that explores the map then find its way to the end. On the second go, it then use its experience (maybe save in a file or something) to do better decision.
Well, the closest solution to that is to generate a graph that is more simple than the map. That would make this algorithm slightly faster. Unless your map can change.
But that isn't needed at all. A* isn't as slow as it may seem.
Nov 23, 2010 at 10:54pm
If you want it to learn from experience, you could try a neural network.
Nov 24, 2010 at 4:03pm
@PiMaster
Yeah that's what I want to do but after reading a little about it, it seems like it's more difficult to implement :(

@All
Thanks to you all, at least I was able to learn about A*
Nov 25, 2010 at 5:54am
Right, now a practical game-oriented implementation of some AI would give some room for error by the AI rather than creating an absolute shortest-path solution. How would you put in this error exactly?
Nov 25, 2010 at 2:32pm
I'm not actually making a game. It's just one day I wake up and I wanna do this learning AI thingy. The AI that I was thinking does not necessarily choose the shortest path. Hence it should make better decisions after some learning, that may or may not lead it to the shortest path.

If ever you know some information that could help please let me know. Thanks :)
Nov 25, 2010 at 4:37pm
That would mean an abstract algorithm involving the fact that the AI does not know about potential paths, but does "observations". Rather, he only observes that which he can logically know. A simple way would be something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
AISTEP()
   Look ahead.
   If road ahead contains the exit
       Empty all queues
       Take the exit
   If entire highest-level road queue is impassable
       Remove highest-level road queue and go back one level
   Else if road ahead is dead-end (has no corners or splits)
       Go back and take a different road
       Remove current hallway from checking queue and mark it as impassable
   Else if road ahead is not dead-end
       Add all splits and corners to the potential road queue
       Take the first road
       AISTEP()

A road queue is a n-dimensional container of roads that can contain other road queues.
This is not completely fleshed out, but all I could come up with on the spot.
Last edited on Nov 25, 2010 at 4:39pm
Topic archived. No new replies allowed.