|
|
|
#1 |
|
Senior Member
Join Date: Apr 2002
Location: UK
Posts: 491
|
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 |
|
|
|
|
|
#2 |
|
....he's amazing!!!
Join Date: Nov 2000
Location: London UK
Posts: 1,504
|
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. |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jun 2000
Posts: 2,692
|
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..... |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Apr 2002
Location: UK
Posts: 491
|
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 |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Apr 2002
Location: UK
Posts: 491
|
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 |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jun 2000
Posts: 2,692
|
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).
|
|
|
|
|
|
#7 |
|
Student
Join Date: Apr 2001
Location: -
Posts: 4,756
|
I gave this topic aswell a thought:
if you need pathfinding (the could be valid reason if for example you want to let the bot go to a certain spot as quick as possible, or spawning obstacles/ enemies as nasty as possible [always on the shortest path],...) iŽd be smart to first analyze your environment. imagine given this map ![]() there are already some dead ends,- finding those should be an easy task (fields that have only 1 accessble neighbour- or that have a dead end) ![]() the conventional way finding a path would be solving this with a grid as way points ![]() to decrease however the loops you need to perform within the finding algorithm you can already exclude those fields who have only 2 openings (I still included edges in this illustration but you could leave them as well) ![]() like I said you can even leave out the edges wich would give you ~ 4 nodes on that path to check [all the fields who have at least 3 accessable neighbours]. This way you can simplify and reduce the needed way points/ fields alot and the pathfinding should already run a lot better a little sidewalk: like others already mentioned I would make the enemies all knowledgeable on where you are,- just like human beeings they only should know where the pacman went if they saw him passing them. If pacman for example hides behind a wall... ![]() ... all the enemy then knows is that pacman is somwhere behind that corner- nothing more- so after the enemy reached the backside of that corner he still needs to search (look) again for pacman.
__________________
my new home: polycount old: Curing C. tech | Curing C. designs | tank | ortho. | zelda LTTP | Tile Edit. | scrolling 3d: 3d engine kit | ASE format | 3d binary format |
|
|
|
|
|
#8 |
|
Moderator
Join Date: Jul 2001
Location: Estonia
Posts: 8,138
|
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.
|
|
|
|
|
|
#9 |
|
Wait- what now?
Join Date: Dec 2005
Posts: 1,468
|
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." |
|
|
|
|
|
#10 |
|
Hype over content...
Join Date: Apr 2001
Location: Lost forever in a happy crowd...
Posts: 5,745
|
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.
__________________
![]() www.gamingyourway.com | 651:Announce | Voxel Landscape | Kaleidoscope | Tunnel | Dot vectors | Plasma |
|
|
|
|
|
#11 |
|
ism
Join Date: Aug 2001
Location: , location, location
Posts: 4,945
|
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 |
|
|
|
|
|
#12 | |
|
Heli Attack!
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 923
|
Quote:
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
|
|
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Jun 2000
Posts: 2,692
|
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. |
|
|
|
|
|
#14 |
|
M.D.
Join Date: Dec 2002
Location: Shelter
Posts: 4,039
|
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 |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Dec 2000
Posts: 408
|
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.
__________________
http://www.drakon.com.ar |
|
|
|
|
|
#16 |
|
1 2 3 make way 4 da Indian
Join Date: Jan 2004
Location: :noitacoL
Posts: 1,074
|
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.
__________________
-Aditya |
|
|
|
|
|
#17 | ||
|
Pumpkin Carving 2008
Join Date: Apr 2006
Location: Grand Rapids MI
Posts: 2,165
|
Quote:
__________________
![]() | Windows 7 Professional | Ubuntu 9.10 | San Diego A8N32-SLI Deluxe | AMD64 4000+ OC 2.97GHz | 3GB DDR 3200 | 512MB nVidia 7600 GT | 512MB nVidia 7800 GTX | Quad-Monitors | | CS4 Actionscript 2.0 | CS4 Actionscript 3.0 | Java | Javascript | C++ | Visual Basic/.net | HTML | XML | PHP | MySQL | AutoHotKey | | Working on a project? I'm available for freelance. | |
||
|
|
|
|
|
#18 |
|
Moderator
Join Date: Jul 2001
Location: Estonia
Posts: 8,138
|
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.
|
|
|
|
|
|
#19 |
|
Pumpkin Carving 2008
Join Date: Apr 2006
Location: Grand Rapids MI
Posts: 2,165
|
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.
__________________
![]() | Windows 7 Professional | Ubuntu 9.10 | San Diego A8N32-SLI Deluxe | AMD64 4000+ OC 2.97GHz | 3GB DDR 3200 | 512MB nVidia 7600 GT | 512MB nVidia 7800 GTX | Quad-Monitors | | CS4 Actionscript 2.0 | CS4 Actionscript 3.0 | Java | Javascript | C++ | Visual Basic/.net | HTML | XML | PHP | MySQL | AutoHotKey | | Working on a project? I'm available for freelance. | |
|
|
|
|
|
#20 | |
|
....he's amazing!!!
Join Date: Nov 2000
Location: London UK
Posts: 1,504
|
Quote:
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... |
|
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|