|
-
Fast path finding for pacman game
Hi there
I have been reading all the posts about path finding and still not sure what is the best solution for a pacman style game.
Basically there will be a maximum of 4 baddies at any time, each which may need to call a path finding function to enable them to chase the player
I have programmed the basic game but currently the baddies just move randomly.
Here is the current version
http://www.mediakitchen.co.uk/chomper1.html
I would like to make it a bit more interesting and challenging by making the baddies chase the player.
What path finding algorithm would you suggest for this game? It has to be programmed in AS1 for Flash Player 7.
Many thanks
Paul Steven
http://www.mediakitchen.co.uk
-
....he's amazing!!!
Don't use a pathfinding algorithm - as such.
There's no point calculating the path from baddie to pacman if pacman has moved by the time baddie gets there, best just to have the baddies make navigation decisions at key points, such as corners and intersections, and base that decision on the position of the pacman. MUCH much quicker.
Also try and find some info in the AI in the original pacman games, if i remember each ghost had its own peculiar style of AI, depending on its colour, and only one of them was 100% aggressive.
-
Senior Member
Here's how I would approach it:
First, the baddies would not use path finding, but normal maze navigation (ie: Baddy encounters a wall. Which directions are unobstructed? Pick random direction and go)
Second, then to add more "intelligence" I would modify the direction choice based on: Which direction is available, and where is the player in relation to the baddie? Is he to the right, left, up or down of baddy?
You can then make the baddy ALWAYS choose a direction that will head towards the player (for a super smart, agressive baddy) or weight the choice with some randomness. For example, make it so one baddy ALWAYS heads toward the player, make one who is completely random, make one who chooses to head toward the player 70% of the time, etc.....
-
Thanks lesli
I have implemented a path finding algorithm based on http://proto.layer51.com/d.aspx?f=998 however I agree with what you are saying and think if I take your suggested approach the game will run alot smoother.
The link for the latest version of game with one intelligent baddie is
http://www.mediakitchen.co.uk/chomper2.html
Thanks
Paul Steven
http://www.mediakitchen.co.uk
-
Thanks Ray Beez
I did originally try to add intelligence by comparing the player location with the baddie location but I found in certain circumstances the baddie got stuck if for example player was directly above the baddie - but that may have been errors in my code
Paul Steven
http://www.mediakitchen.co.uk
-
Senior Member
By the way, one flaw in my method above is that decisions only occur when baddie hits a wall. You need to add an invisible tile at all intersections and make your baddie re-evalluate their path decisions when they hit intersections (thus allowing them to turn if appropriate).
-
-
Senior Member
Smart enemies are not always interesting to play with. For example, how would they know where PacMan is if they cant see it? You could build it so they try to follow PacMan only if it is visible, allowing to hide behind the corners.
-
Wait- what now?
Pathfinding spoils pac-man games. In the old ones only one baddie used path finding, then 2 were dumb and one only chased you went it could see you.
Render, even those example drawings look really good, Me = Jealous once again.
"I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."
-
Hype over content...
Path finding isn't needed for pacman, it's a simple case of working out where the player is in relationship to the ghost, and then working out the best possible method to get there ( I'm currently using this in a game, also used it in Souq Chase in DiS, albeit the other way around so the baddie was running away ).
So the ghosts move a tile at a time, even if it's smoothed out, it's still a tile. When they've moved that whole tile it's then that you let them think.
If playerXPos<ghostXPos then the ghost's preferred horizontal move is left, and if playerYPos>ghostYPos then the best vertical direction for it is down.
Next check all the possible directions the ghost can move in, ie check the tiles around it.
Then just compare. Using the examples above, we want to go left and down. If any of the possible moves allow either of these favourites then we're on to a winner, and he moves in that direction.
If on the other hand he can't move in either of these directions, so he can only move up or right, just pick one of those at random.
Also with pacman ghost ai they can't double back, so that random choice is made even easier, as you remove the chance of it doubling back on itself.
Check Neave's pacman open source, it does it this way too ( Got a hefty chunk of inspiration from that a while back ).
Squize.
-
ism
Neave hadda remove his pacman stuff i think. forkin lawyers eh?
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Heli Attack!
 Originally Posted by Squize
If playerXPos<ghostXPos then the ghost's preferred horizontal move is left, and if playerYPos>ghostYPos then the best vertical direction for it is down.
This is basically my implementation of Pacman pathfinding, with 4 enemies, it got really hard to avoid them.
If you feel like sprucing it up a bit, make a couple work like this, and then a couple work simply by going a random direction. Adds some zest
-
Senior Member
Iopred: Yup. And hence why my description includes some randomness. IN the real pacman, only 1 ghost (the red one) is smart and seeks you out 99% of the time. He's also a slight bit faster than Pacman.
The rest will occasionally head toward you but occasionally head in other directions, thereby at least giving you a chance to escape. And one of them is kind of dumb and rarely heads in Pac's vicinity.
-
M.D.
i wouldn't mind seeing bitmapData pacman, blow your own way through the maze by destroying the walls.
or maybe health conscious pacman, avoid the fatty sausages and eat the health celery... nah, eat the sausages avoid the celery, much cooler
-
Senior Member
I also remember reading a tutorial or something teaching how each gosth was "programmed". I believe the red one was the "evilest". I can´t find it.
-
Same thinking as lesli_felix.
Edit: If you try to make the pathfinding too perfect then player won't have a chance to win at all.
-
Pumpkin Carving 2008
 Originally Posted by iopred
 Originally Posted by Squize
If playerXPos<ghostXPos then the ghost's preferred horizontal move is left, and if playerYPos>ghostYPos then the best vertical direction for it is down.
This is basically my implementation of Pacman pathfinding, with 4 enemies, it got really hard to avoid them.
If you feel like sprucing it up a bit, make a couple work like this, and then a couple work simply by going a random direction. Adds some zest 
I would only do that if every tile in between pacman and ghost were walkables. Given the fact that they are "walls", the ghost can't see pacman.
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
Senior Member
This is going off-topic, but one of the original pathfinding ideas I have read was scent-based. Basically the character smells and his smell spreads aound him in every direction (not through walls of course). The smell is also left behind him and it slowly fades away after he has moved away. Now the enemies have nose and can detect which way the scent of char is stronger to move that way. Have not seen that idea in action, but still liked it because it is more realistic then simply finding path through invisible walls.
-
Pumpkin Carving 2008
Tony how do you think up stuff like that... sheesh lol. It takes me 3 months to think stuff up. I've always been a fan of line-of-sight based pathfinding, but I usually add in the visible distance such that some baddies can "see" farther than others.
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
....he's amazing!!!
 Originally Posted by tonypa
....The smell is also left behind him and it slowly fades away after he has moved away. Now the enemies have nose and can detect which way the scent of char is stronger to move that way.....
Wow, that's a pretty good idea Tony.
And it actually sounds pretty east to implement, if the maze is tilebased for example, you just run a loop through all of the tiles and reduce the amount they smell. The ghosts just move onto the adjacent tiel that smells the strongest.
If not using tiles, you could even apply smell to a bitmapdata object as a particular colour, and fade the whole thing to reduce the smell each frame.
I'm gonna have to try that one sometime...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|