The Daily Click ::. Forums ::. Klik Coding Help ::. Pac-Man AI
 

Post Reply  Post Oekaki 
 

Posted By Message

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
5th September, 2006 at 03:16:53 -

I'm trying to make a Pac-Man game with some decent AI (don't worry- it's not nearly as bad as Pac-Man XP- in fact, other than AI it's going pretty well.) I need some help coding some basic ghost AI. I intend on each ghost having their own 4 sensors, so they can have custom engines.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
5th September, 2006 at 03:40:33 -

Google says this:

" * each ghost has its unique behaviour
* the first ghost will move following to a preprogrammed pattern of
movements through the maze (e.g. right, up, left, down, left, ...).
This pattern is always the same for a level.
* the second ghost (the red one) moves using a pathfinder routine, trying
to minimize x/y-distance to the pacman (this we described earlier as
"strategic movement")
* the third ghost moves on pure random
* the forth ghost uses another pathfinder routine, trying to predict the
next movements of the pacman (trying to intercept him)

While this garantees an interesting and quite predictable gameplay, this
approach has some drawbacks: First, for the first ghost, you have to design
carefully an extensive path (movement pattern) per level. Second, the movement
of the forth ghost can only be implemented by defining some key crossings (as
entrances to loops) and by tracking the pacman's movement. So you could
predict the key position the pacman will be likely to be next. But in order to
do this, each level-layout has to tribute to these key positions, meaning that
it has be modelled around these crossings, which will obviously limit the
range of possible designs."
And contains a different method of AI: http://www.masswerk.at/JavaPac/pacman-howto.txt

And these: http://jongy.tripod.com/SoundofEating.htm
http://jongy.tripod.com/GhostPsychology.html
http://www.gamedev.net/reference/articles/article1841.asp

The first (masswerk.at) and last (gamedev) ones should give you a good starting point if you want the ghosts to be authentic. The first one's suggested movement is a universal movement for each ghost that combines pathfinding with randomness.

For the pathfinding, because pacman levels are relatively simple (assuming, again, you're attempting to be authentic), it would be possible simply to build an array that has each intersection (because ghosts only need to make decisions on intersections) on one axis, and each 'tube' (or whatever, the confined sections between two intersections) on the other axis. Each cel in the array would indicate which node the ghost should move towards at any intersection depending on the current 'tube' pacman is in at the time.

That covers Blinky.

Pinky though also uses pathfinding, but tries to predict pacman's movement. For him use could use a similar table, but double the size, because pacman can move one of two directions in each tube. So instead of Tube A, Tube B, Tube C etc. on one axis you would have Tube A heading towards Intersection A, Tube A heading towards Intersection B, Tube B heading towards Intersection B, Tube B heading towards Intersection C, ...

On second thought you could in fact use the double-sized array for both ghosts (Inky and Clyde move randomly or follow a set path), and simply swap the 'heading towards' lookup for Blinky. That way Blinky seeks the intersection behind pacman, and Pinky seeks the intersection aftwerwards.

Then to finish off, when either of those two are on an intersection attached to the tube pacman is currently on, the simply move towards him (you'd have that in the array, so the cel at [Intersecion A, Tube A] would direct the ghost towards Intersection B because that would pass through pacman on the way).

Easy.

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
5th September, 2006 at 09:16:46 -

If you're lazy, you could try the pathfinding object. It's grid-based and stuff, so that's kind of good. Never figured out how to use it though.

 
n/a

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
5th September, 2006 at 11:05:46 -

'" * each ghost has its unique behaviour
* the first ghost will move following to a preprogrammed pattern of
movements through the maze (e.g. right, up, left, down, left, ...).
This pattern is always the same for a level.
* the second ghost (the red one) moves using a pathfinder routine, trying
to minimize x/y-distance to the pacman (this we described earlier as
"strategic movement")
* the third ghost moves on pure random
* the forth ghost uses another pathfinder routine, trying to predict the
next movements of the pacman (trying to intercept him) '

I actually know that the first ghost, on the top of the list, does not move preprogrammed, but they all move weird-like. The cyan one, for example, will do what the red one does if the red one is closer than pac-man, but if he's close to pac-man, he'll try to follow him.

I'm not trying to be authentic; I need an AI that will work in a custom maze. I'll try the pathfinding object.

Image Edited by the Author.

 
n/a

danjo



Registered
  15/01/2002
Points
  741

Acoders MemberGOTM NOVEMBER - 2009 - 3RD PLACEI am an April FoolVIP Member
6th September, 2006 at 03:23:21 -

i could tell you, but id have to kill you afterwards

 
n/a

Werbad



Registered
  18/09/2002
Points
  235
6th September, 2006 at 06:23:50 -

I can do a simple grid based movement so that the ghosts will try to follow the player... But as Radix said all ghosts isn't supposed to act this way...

 
n/a

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
6th September, 2006 at 21:47:56 -

"i could tell you, but id have to kill you afterwards "

I still have 3 lives left, BRING IT ON!

 
n/a

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
6th September, 2006 at 21:48:59 -

I noticed that in the origional game, the ghosts follow a set path until about 7 or so seconds into the level (depends on the round) then they try to get Pac-Man. They keep alternating every 7 seconds or so

 
n/a

danjo



Registered
  15/01/2002
Points
  741

Acoders MemberGOTM NOVEMBER - 2009 - 3RD PLACEI am an April FoolVIP Member
6th September, 2006 at 22:08:49 -

nope not really - each ghost in pacman has its own specific AI routine.
i found out what each were, and did something similar in pacz, apart from that i added abilities to each one. the basic AI routines are more or less what they're supposed to do.

 
n/a

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
6th September, 2006 at 22:52:33 -

I know they're each different- but for a while at the start of the level they do go in certain areas- Blinky goes to the top-right corner, pinky the top-left, inky the lower-right and clyde the lower left. Then after a while the AI gains control. Then once many dots have been eaten, they temporarily go back to this set movement, then go back to AI.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
7th September, 2006 at 03:43:06 -

I noticed that in the origional game, the ghosts follow a set path until about 7 or so seconds into the level (depends on the round) then they try to get Pac-Man. They keep alternating every 7 seconds or so
They alternate between scatter and normal mode. I think it's something like evey 7 seconds, 4 seconds, 7 seconds. One of those links I posted goes into depth on the AI.

 
n/a

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
7th September, 2006 at 18:14:46 -

They alternate between scatter and normal mode. I think it's something like evey 7 seconds, 4 seconds, 7 seconds. One of those links I posted goes into depth on the AI.

Yeah, that's what I meant. I saw an article on Wikipedia.

 
n/a

Deleted User
8th September, 2006 at 14:46:44 -

The apoptotic index (AI) was significantly higher in emphysematous lungs compared to the control group (p ≤ 0.01), particularly if only lungs with AAT-deficiency emphysema were considered (p ≤ 0.01 vs p = 0.09). The proliferation index was similar in patients and controls (1.9 ± 2.2 vs 1.7 ± 1.1). An increased number of T lymphocytes was observed in AAT-deficiency lungs than smoking-related cases (p ≤ 0.05). TGF-β1 expression in the alveolar wall was higher in patients with smoking-associated emphysema than in cases with AAT-deficiency emphysema (p ≤ 0.05). A positive correlation between TGF-βRII and AI was observed only in the control group (p ≤ 0.005, r2 = 0.8 ). A negative correlation was found between the TGF-β pathway (particularly TGF-βRII) and T lymphocytes infiltrate in smoking-related cases (p ≤ 0.05, r2 = 0.99)

Image Edited by the Author.

 

Reno



Registered
  11/01/2005
Points
  906
8th September, 2006 at 16:09:36 -

did that just come from Brandon?!

 
Reborn Again
   

Post Reply



 



Advertisement

Worth A Click