🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #902

Re: Pacman Ghost logic

#902
From: Todd Lehman
Date: Fri, 28 Aug 1992 18:33
126 lines
6851 bytes
jerry@connection.prospect.com (Jerry Shekhel) writes:
   
>I got away with a really fast and really dumb technique in my Chomp game.
>At an intersection, each ghost picks its new direction from an initialized
>16x8 array, where the primary index (0-15) is a bitset of directions in which
>the ghost can go (4 directions = 4 bits), and the secondary index (0-7) is a
>code representing the compass direction of the target relative to the ghost
>(North, Northeast, East, etc).  The game also uses randomness to prevent
>the ghosts from getting into a "formation" and to make the game playable, as
>it was too difficult without it.
>
>As for filling the 16x8 array, most of the cells are obvious -- only one
>way to go.  There are cases where it's ambiguous, for example, if the ghost
>can go North or East, and the target is to the Northeast.  For half of those
>cases, I have the ghost take the horizontal, and for the other half, the
>vertical direction.
>
>This technique is fast, and worked surprisingly well.  An interesting feature
>is that to make the ghosts run away from the target instead of following it,
>all I had to do was supply another array -- no new code had to be written.
   
In my old CGA (puke!) Chomp-Man game, I found that making the ghosts run away
from the target (e.g., when the PacMan eats an energizer) made them easy to
catch.  The best hightail-it-out-of-here algorithm I could come up with was to
choose a random direction when the ghosts are vulnerable (while/purple/red).
Because since the ghosts travel at 1/2 speed in this vulnerable state, the
PacMan can always go out of his way to get them if he knows what they're
thinking.  Choosing a direction purely at random is, I suspect, how the arcade
version worked?
   
I used something like the 16x8 array approach described above (except at the
time I wasn't smart enough to use a multidimensional array so I hardcoded the
data into a gihugic mess of if/else's (yuck!)).  But what I did to make the
ghosts even smarter beyond that was to note the direction the PacMan is
traveling in addtion to the relative position:
   
     [1]        [2]        [3]        [4]
   
     # #        # #       ^#^#       P# #
     # #        # #       |#|#       |# #
    <-G###       G###     P G###     v G###
     # #        #|#        # #        # #
     # #        #v#        # #        # #
    ^# #        # #        # #        # #
    |#          #          #          #
    P#         P#          #          #
               |           
               v           
   
In [1], the ghost should move left, even though dy>dx, since the PacMan is
moving up.  In [2], you probably want to move the ghost down, although
arguably you may want to move it left -- I let the red ghost move left
in this situation and the other ghosts move down.  In [3], you'd think 
the ghost should move right, but you can really dis the PacMan by moving the 
ghost up -- again, not all four ghosts play by the same rules and so for 
instance the red ghost would move right and the cyan ghost would move up.  
In [4], I think there's only one smart move, and that's to move the ghost 
left.  (I guess if there was a ghost below the PacMan moving upwards, then 
the ghost shown should move up if it can, since the PacMan will likely 
reverse directions to run from the ghost below it.)
   
When I first played the game with this increased awareness, the ghosts got me
every time, and I had to slow them down relative to the PacMan by 1-2%.  In
coming months I learned to outsmart them (since I programmed them ;-) so if
I was doing it again I would put more randomness into the near-arbitrary
choices.  I'd also make the ghosts smarter about tunnels -- I learned to trick
them into the tunnels with a quick reverse-reverse-reverse, and this is bad
for the ghosts since they slow to 1/2 speed in the tunnels.  (Can anyone
verify the factor 1/2?)
   
Also, if the ghosts can communicate with one another, rather than hunt the
PacMan autonomously, that would help things.  Has anyone tackled this
problem???
   
   
   
ckincy@mcs213c.cs.umr.edu (Charles Kincy) writes:
   
>I also remember that each of the four ghosts had his own personality.
>
>"Pinky":  The Pink ghost was extremely fast.  Pinky wasn't very smart,
>but if he saw PacMan, PacMan was dead.  However, if he wasn't too close,
>he was pretty easy to shake.
>
>"Blinky":  The Red ghost was slower, but extremely tenacious.  He would
>not ever lose the trail of PacMan once he found it, but he hardly
>ever found it.
>
>"Inky":  The Blue-green ghost was the one Gordon describes.  He had
>a blind spot, and could not tell he was being followed.  Almost as fast
>as Pinky, but not quite.
>
>"Clyde":  The Orange ghost was the smartest, but he was very slow.  
>Clyde would try to lay traps for PacMan by working with the other ghosts.
>
>These descriptions were from what I remember of a "How to beat" book
>on PacMan.  However, it was no less than ten years ago when I read it.
>
>PacMan and the names of the ghosts are copyright by Bally-Midway.  =)

Can anyone verify these names and their color/personalities?  I found an old
sheet yesterday on which I had scribbled:
   
   Inky......."Shadow"     [Red]
   Pinky......"Speedy"     [Pink]
   Blinky....."Bashful"    [Cyan]
   Clyde......"Pokey"      [Orange]
   
And even though the Pink ghost was named "Speedy" I always though the Red
ghost was the fastest, at least in the later levels.

I'm thinking of rewriting my game from scratch in C for the VGA (the old one
was in compiled BASIC and assembly for the CGA, yet it was very fast and very
smooth and had a board/maze editor :-)  Does anyone know of a PacMan
programmer mailing list?

BTW, Has anyone heard of or seen the game "Libble Rabble"?  According to the
book "Programmers at Work:  1st Series, Interviews" (Susan Lammers, Microsoft
Press, 1986), Toru Iwatani, the designer of PacMan, created a game by that
name after completing the Pac Man project.  He said in the interview that it
was his favorite game.

--
Todd Lehman
toddl@county.lmt.mn.org
 
Technical Details
Message-ID: <toddl.73.715026805@county.lmt.mn.org>
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!caen!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!kksys.com!edgar!brainiac!lmt!toddl2.lmt.com!toddl
References: <1992Aug25.163227.4679@ctr.columbia.edu> <1992Aug26.131514.15603@exu.ericsson.se> <27230@life.ai.mit.edu> <1992Aug28.060322.13232@zooid.guild.org>

Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!caen!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!kksys.com!edgar!brainiac!lmt!toddl2.lmt.com!toddl
From: toddl@county.lmt.mn.org (Todd Lehman)
Subject: Re: Pacman Ghost logic
Message-ID: <toddl.73.715026805@county.lmt.mn.org>
Sender: usenet@lmt.mn.org
Nntp-Posting-Host: toddl2.lmt.com
Organization: LaserMaster R&D, Minneapolis, MN  USA
References: <1992Aug25.163227.4679@ctr.columbia.edu> <1992Aug26.131514.15603@exu.ericsson.se> <27230@life.ai.mit.edu> <1992Aug28.060322.13232@zooid.guild.org>
Date: Fri, 28 Aug 1992 18:33:25 GMT
Lines: 126