Pac Man Ghost AI & Score ?

Hello,
Today I decided that it might be fun to work on a simple PacMan like game in the BGE, however there are 2 things that I am not exactly sure how to do…

1. I want some basic AI on the ghosts that makes them move around the maze randomly and follow the player if they get too close.
2. I need a way to increase a displayed score every time the player eats one of the orbs, and display a win screen if they get all of the orbs, but a lose scene if they get got by a ghost

As I said this is just a simple game so I won’t add an ability to eat the ghosts or anything fancy like that…
Anyways I would REALLY appreciate some help on this, both of the above would be great but if you can only help me with one I would appreciate that as well. Here is my blend file so you can see what I mean:

Thank in advance!!!

               -Tr4nz1uc3nt

p.s. I am open to python, but do not know much so if you suggest it I would appreciate it if you included a script.
p.s.s. I know I used the word appreciate a lot.

Youll probably need python for the AI. They dont move around randomly. they have i think 3 different states and of the four Ghost each has its own “personality” AI command and ruleset. Heres a great article and very technical breakdown of the ghost AI.

Alright, thanks for the info. Any chance there might be some Python tutorials on simple AI anywhere?

AI
AI is just decision making (“what to do next?”). Decision making is behavior. Behavior in the BGE can be described via logic brick and Python and a mix of both.

I recommend you first describe (in natural language) what exactly this “AI” should do. As a help answer this questions: What to do When?

Example:
Ghost -
if hunting:

  • go along the way with the smallest angle towards PAC man’s position.
  • evaluate the decision within the next step

if touching PAC man:

  • eat the touched PAC man.

I hope you see this simple behavior implements a “strategy”. The ghost is not magically smart. It just follows some simple rules. Indeed he needs to know some things: the ways he can choose from. This are usually between 1 (dead end) and 4 ways (cross road).
What else does he need: He need to be able to go one step into one of these ways. He needs to be able to change the way. He needs to be able to perform the decision making.

Counting scores
BTW: counting scores is a complete different topic (but needs a description of the behavior as well). The relation might be the behavior of PAC man:
if touching an orb:

  • remove the orb
  • notify the score counter that an orb was eaten

alternative: the orb:
if touched by a PAC man:

  • notify the score counter that an orb was eaten
  • end itself

Alright, I think I have an idea of how I want the AI to work but I’m not exactly sure how to do it.

  • When the game starts all of the ghosts pick a random orb and use a navmesh to get to the orb, upon touching that orb the script will re-run and pick another orb etc.
    I know that this means that the ghosts will not actually seek Pac man but this game is more of a fun learning project for me than a big Python project

And for the orbs I understand what needs to happen with PacMan eating them, but again I am new to using Python so I am not sure how exactly to program it in Python.

If you know some good ways to accomplish these it would really help (almost used appreciate again :p).

Sounds like a good idea. You should be able to get a “living” ghost as long as there is an orb to eat :D.
(do not forget: what happens if there is no orb left/WHat happens if the ghost collides with Pac man).

You do not need custom code. The native logic bricks can handle this situation very well. It is not that difficult :D.

To display the counted scores have a look at the BGE Guide to Messages incl. Healthbar tutorial

Alrighty! Thanks a million to everyone that has helped with this project :). I will post the game on here when I finish it, probably this weekend.

Alright, I am thoroughly confused here. I started to setup my AI and decided to test it, but for no apparent reason it has decided not to work. This system worked in my test and in the example file Akira_San linked me to. I have absolutely no clue why it is not working.
If someone would take a look at my .blend and point out whatever it is that is wrong I would appreciate it. Here is the file:

When you find what is wrong PLEASE point out to me what I did wrong and how obvious it is…
Thanks,
Tr4nz1uc3nt