Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / A.I. Help

Author
Message
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 15th Aug 2006 23:32
I'm currently working on PacMan like game and was looking for a simple Artificial Intellegence Tutorial. If anyone knows were I can find one, or just knows A.I. and would like to share some information please reply.

Cocacola and Pepsi aren't that differnt. Deal with it.
Richard Davey
Retired Moderator
23
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 15th Aug 2006 23:37
It's not an article, but here is an idea for you (just to get you started). When I wrote my very first pacman game (back on the ST) it worked as such:

When the red ghost got to a junction, it always went left.
When the blue ghost hit a junction, it always went right.
When the pink ghost hit a junction, it went either way.

Now it's hardly the most complex of things, and not even close to 'AI', but it proved to make for a rather interesting game, something you can then work on with player zoning and grids.

"Bite my shiny metal ass" - Bender, Futurama
No pixels were harmed in the making of this post
"Don't ping my cheese with your bandwidth"
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 16th Aug 2006 02:21 Edited at: 16th Aug 2006 02:21
Thanks for the advice, It will be useful, but i'm thinking about more on the lines of A.I. that will make a specific sprite, say move toward a object while dodgeing obstacles. Any one know about any tutorials, or have advice about that please reply.

Cocacola and Pepsi aren't that differnt. Deal with it.
sadsack
21
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 16th Aug 2006 04:18
here see download:

Attachments

Login to view attachments
Whisper Wind
22
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 16th Aug 2006 07:47
What you want to do is break up the map into a graph (grid) and use A* pathfinding to find a path from the ghost to the player. Save the path and every frame have the ghost continue on the path. It seems to me you don't really need any other techniques than pathfinding (finding the optimal path from point A to B while avoiding obstacles) for a pacman game, and A* is the tried and true method for this. Just go find a good tutorial and start coding! You'll need to learn it eventually.

Searching for files named 'sanity'...
No files were found.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 16th Aug 2006 17:36
If you are making a pacman game then the ghosts have no AI. All they do is choose a random direction when they meet a junction. So, if your ghost arrives at a 'T' then:
X=rnd(1)
if X = 0 then Go Left
if X = 1 then Go Right

If the ghost meets a '+' your random number should be RND(2) to allow for the extra direction - straight on.

If you insist on giving the ghost pathfinding abilites to 'home-in' on the player then it will be incredibly difficult to play, if not impossible. Your player will have a choice of two or three directions but with four ghosts homing in on him I would be suprised if the game was even possible to win.


Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 16th Aug 2006 19:05
I understand it would be impossible if all 4 ghosts homed in on the player, but I wasn't going to make all 4 ghosts home in, just maybe 1 or 2 as the levels go by to make it challenging.

Cocacola and Pepsi aren't that differnt. Deal with it.
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 16th Aug 2006 19:07 Edited at: 16th Aug 2006 19:44
sadsack, is the tutorial for DarkBASIC Classic?

Cocacola and Pepsi aren't that differnt. Deal with it.
Richard Davey
Retired Moderator
23
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 16th Aug 2006 19:11
Unless you had a particuarly large maze to move around, I don't think you'd ever ever notice any single ghost operating more under AI than vs. those moving randomly. There are such a low number of paths / routes that it will be hard to tell the difference imho. Ghosts (traditionally) should never just 'turn around', they should always go left/right, so by the time they've done this you'll have moved out of their path anyway

If you want to learn path finding, I'd pick a different style game imho.

"Bite my shiny metal ass" - Bender, Futurama
No pixels were harmed in the making of this post
"Don't ping my cheese with your bandwidth"
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 16th Aug 2006 19:43
I guess your right, Random moving is probably better(and easier), unfortunately though I'm not sure how to make random movement for my ghost sprites.

Cocacola and Pepsi aren't that differnt. Deal with it.
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 16th Aug 2006 22:34
You know what, maybe it's not how to make random movements I want to learn, as Scraggle had pretty much already explained this, maybe the thing I should ask how to do is create a grid, like the ones people say you need in PacMan, which I never really learned how to do (Sadsack your tut explained how, but i'm pretty sure only for DBPro).

Cocacola and Pepsi aren't that differnt. Deal with it.
sadsack
21
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 18th Aug 2006 22:01 Edited at: 18th Aug 2006 22:04
It is for DBP

edit
It is not my tut. I found it some place on the net. You should be able to conver it to DBC very easy.
renny
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 18th Aug 2006 22:13
Thanks

Cocacola and Pepsi aren't that differnt. Deal with it.
Zergei
20
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 18th Aug 2006 23:12
How about if the ghosts move randomly until they have you in sight, so they start chasing you until you escape. I think that was how it really was, because i remeber they chased me when they were too close, else they would move randomly.

Further on my stuff at...
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 19th Aug 2006 15:47
Your right, noww that i remember the game the ghosts would always start chasing you when they saw you, but any other time they would roam freely.

Cocacola and Pepsi aren't that differnt. Deal with it.

Login to post a reply

Server time is: 2025-05-15 05:16:24
Your offset time is: 2025-05-15 05:16:24