Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

PacMan

Hello Everybody!
I have loggged on after a very looooooong time ...so please cooperate!

I am making a game of PacMan (in 2D graphics) for my school project.
Its almost complete but i am stuck in one place.
I CAN'T DEVISE A STRATEGY TO PROGRAM THE 'EATERS'(i hope you know 'eaters' in Pacman) ....i.e.
How they Chase Them????How They Move Automatically on their own to chase pacman????
How I program its AI??
Please help me out before this vacation ends.....
If you require some useful part of my code ..please reply...
THANK YOU (atleast for 'READING!')


Comments

  • PruyquePruyque Member Posts: 149
    : Hello Everybody!
    : I have loggged on after a very looooooong time ...so please cooperate!
    :
    : I am making a game of PacMan (in 2D graphics) for my school project.
    : Its almost complete but i am stuck in one place.
    : I CAN'T DEVISE A STRATEGY TO PROGRAM THE 'EATERS'(i hope you know 'eaters' in Pacman) ....i.e.
    : How they Chase Them????How They Move Automatically on their own to chase pacman????
    : How I program its AI??
    : Please help me out before this vacation ends.....
    : If you require some useful part of my code ..please reply...
    : THANK YOU (atleast for 'READING!')
    :
    :
    :

    Hmmm, PacMan...

    Well here are just some thoughts:
    Really stupid eaters: Pick a direction, keep walking untill you hit a wall, then choose another direction.
    Greedy eaters: Pick a direction, keep walking untill you hit a wall, then go in the direction of PacMan
    Shortest path eaters: (Hope this isn't too cryptic)
    Think of the PacWorld made up of cells that can contain a number:
    [code]
    Create an empty queue that can contain (cell, number) pairs.
    Push the cell that PacMan is on to the back of the queue, along with the number 1.
    assign the number 1 to the cell PacMan is on.
    while (queue is not empty)
    {
    pop a (cell Q, number N) from the front of the queue.
    for all cells P next to cell Q (that are not wall)
    {
    if (P has not been assigned a number)
    {
    add to back of the queue (P, N + 1)
    assign N+1 to P
    }
    }
    }
    [/code]
    Now all the cells have been assigned the number of steps in the shortest path to PacMan. Now make the eaters go to in the direction of the lowest number and PacMan should have a rather hard time to keep out of their way ;)

    Have fun,
    Pruyque
Sign In or Register to comment.