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.

Newcomers DBPro Corner / AI...where do we start?

Author
Message
Filmmaker Screenwriter
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 13th Jul 2004 09:16
Hey everyone. It's Ben from Beehive again, with some help needed for 3D PacMan......again...

Anyways, it is coming along quite nicely and we kinda hit a rut. Neither of us knows how to even BEGIN programming AI.

Basically, the AI needs to break down into 3 cones chasing after a sphere (yes, we diligently modelled the characters in this game, lol)



That is a really old screenshot compared to the newer ones we have but that's the only one Jason has on the site. But, it is a good perspective picture, if it helps you to help me.

When I say we have no idea where to begin with AI, i literally mean we have NO idea where to begin.

Thank you for your help. And oh by the way, for everyone who has helped me or Jason previously in any way, your names have been being taken down since Day 1 and we are coming to your homes...lol jk....I mean, expect to see your names in the credits!

Thanks again for your help!

Member of Bee Hive Studios | freewebs.com/beehivestudios
Currently developing: 3D PacMan (tentative title)
GameMaker Jason
20
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 13th Jul 2004 17:03
Yeah we are really stumped here please help

thanx

Filmmaker Screenwriter
21
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 13th Jul 2004 18:04
LOL, hi Jason! As you can see, I'm getting results a-plenty!

Member of Bee Hive Studios | freewebs.com/beehivestudios
Currently developing: 3D PacMan (tentative title)
Macrosii
20
Years of Service
User Offline
Joined: 31st Mar 2004
Location: Essex, UK
Posted: 13th Jul 2004 21:21
I couldnt see your screen shot but if I remember PACMAN then the cones basically chase the sphere around a maze. So I think the main AI would be some sort of path finding algorithm to find the shortest path from cone to sphere. There should be lots of threads around on these sorts of algorithms.

Hope that helps a little.
GameMaker Jason
20
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 14th Jul 2004 02:16
We know what the AI need to do but we don't know where to start making it. sorry if where stupid but starting small and talking to more expeirenced people is the best way to learn.

thanx

SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 14th Jul 2004 04:13
If I remember correctly, the AI in pacman was was simple, one ghost follwed the wall to the right of it, one followed the left, and every X steps (possibly X player turns?) they broke form by choosing the opposite wall so they wouldn't get "stuck" orbiting an island. Other ghosts had similar rules, taking every second left or right turns, etc. Maybe there's still some old source laying around you can look at...

Well, maybe I'm thinking Boulder Dash 2... Aw well.
S.

Any truly great code should be indisguishable from magic.
Ocean Runner
21
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 14th Jul 2004 04:22
Well, what you could do, is make it so that if the x position is less than that of the player go right. Then if it hits a wall, calculate whether the y position is less or more, and make it take the appropriate junction. Then you could have really stupid ghosts. Then only problem is they would get stuck in a dead end path. Also, do what SandraD said to make them take different paths.

"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 14th Jul 2004 04:48
Yeah,
The first thing you need is a "smart movement" section, which allows the ghosts to "follow" the shape of the maze. This is done by testing the paths available to the ghost, minus the direction they are coming from;

x..x..x
x..x..a
x....<-o (ghost is heading left towards the arrow)
xxxxxx

So this when a ghost hits the corner, it knows to "go up" to follow the turn. But when one ghost passes the point of A up above, it is presented an optional turn to the right, or its right to be exact, so that, if memory serves, the red ghost would take that turn every chance it got. However, the red ghost would not make 4 right turns in a row, because that would be orbiting around something. (Like a square.) So on the fourth time a right turn came along the ghost would ignore it and continue straight until it passed one right turn, or found another direction that followed the walls. (As in running through a T hallway for example.)

The other ghosts are programmed in much the same manner, one taking left turns when possible, another going after the player, yet another following the player's direction I think it was. But the basics of it, you might have to ding around a bit to figure out what works best.
S.

Any truly great code should be indisguishable from magic.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Jul 2004 04:50
or you could have an invisible object at each junction, then when you hit a junction object, pick a direction (up/down/left/right) at random, and try to go that way until you reach a juction with a different object number, if you can`t move (left is a wall for example) then just pick another direction, they should just run around aimlessly changing direction at junctions, you could also make it so that the player leaves an invisible trail of objects, all showing the way he went, then when a ghost hits one of the objects he follows the trail, the player can move faster than the ghosts iirc, so if you run quickly enough the trail will also outrun the ghost, and then he will switch back to wandering about at random, or you could give them fixed paths to follow, if they where long enough and of differing lengths then they would look random since the ghosts would following the paths out of phase with each other, they could even swap to each others paths where they cross, then all you have to do is point and move them to the next waypoint and just check for collision with the player, or you could make them leave a trail of just one block to make sure they never retrace there tracks, so they will always chose another path at every junction, lots of choices, take your pick.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 14th Jul 2004 21:56
That seems to be making it a little too complicated Mentor, because you still have to detect the edges of the maze anyway to keep things moving correctly. (Though you could use array-based movement I suppose, but you can do the path detection too and still not need the extra objects which would still be extra objects.) While junction collisions might be okay in some cases and with the right plug-in, I fail to see the advatage in this particular case.
S.

Any truly great code should be indisguishable from magic.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 15th Jul 2004 05:45
I didn`t think it was complicated, maybe I didn`t explain it properly, and it saved me going into how you would make an image of the maze in an array and what relationship the array had to the visible screen and the way the pacman/ghosts moved, and how you would use the contents of the array to control what happened on screen and scaleing the positions from one to the other, in the hidden objects scenario the only time the ghost would need to check for walls is when choosing the next direction to move, since they go in a straight line they never will need to check for wall collision at any other time, just seemed a good idea and simpler for less experienced users is all, collision objects only need to be miniscule hdden plains, not an fps killing load for a program running pacman with three cones and a sphere IMO.

Mentor.

ps: is a miracle magic?, cos the fact that some of my code runs at all is a miracle, and by your sig that would make it great ??? ROFL (I kill meself )

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 15th Jul 2004 07:45
Well, my concern was that I've had simply LOUSY success using the built-in collision detection routines, and fooling with static objects is often as complex as the maze itself. Using the array method seems to me to be the easiest process, with a few detections per movement that allows a more complex AI to be contructed for each ghost.

As for the PS: Sometimes the fact that any code runs is magic!
(But the quote from Clarke's Third Law of Programming.)
S.

Any truly great code should be indisguishable from magic.
eat much pie
20
Years of Service
User Offline
Joined: 9th Apr 2004
Location: Within the mind of a lowly mortal...
Posted: 16th Jul 2004 23:13 Edited at: 16th Jul 2004 23:15
I'm currently making a Checkpoint Router program that will let you quickly and easily setup AI routing (inculding tactical positioning).

Check out my website (link is in sig), and for more info or Q's, go to the forum page below:

http://forum.thegamecreators.com/?m=forum_view&t=32596&b=5

It should be ready in the next month or so!

Checkpoint Router: my very own AI routing program: http://eatmuchpie.dbspot.com
Teh Go0rfmeister
21
Years of Service
User Offline
Joined: 17th Aug 2003
Location:
Posted: 19th Jul 2004 18:33 Edited at: 19th Jul 2004 18:42
AI, one of the hardest things ever. people study it for lifetimes at unis, fortunately, in games it doesnt have to be so hard.

lesson for ppl in future:

make a list of functions, such as "airun()" and "aishoot()" and in each function make a list of commands that would be done, so that in the game you just have to do:

"if ai_see_enemy()=1 then aishoot()"

Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 21st Jul 2004 05:57
aaarrrggg!
i had perfect ghost AI all worked out that i could have showed you...but i had to wipe my hard drive recently(completely...no chance to get my files off... )



BTW i think in the original PacMan 1 ghost tried to head you off 2 ghost just went straight for you 3 ghost hovered around the jump gates and 4 ghost wandered around in a random corner...


Formerly known as "DarkWing Duck"
Turoid
20
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 21st Jul 2004 07:55
maybe i can help you.

dim enemyx(2)
dim enemyy(2)

make arrays for the enemys positions, in this case there are 2 enemys.

playerx=50
playerz=50

the players position.

ok now the main loop, i supose that you've got already the movement for the player so i'm not going to explain that.

do

for enemy = 1 to 2

the first thing we must do is decide wich direction the enemy should go:

if enemyx(enemy) < playerx then moveright=1
if enemyx(enemy) > playerx then moveleft=1
if enemyy(enemy) < playery then movedown=1
if enemyy(enemy) > playery then moveup=1

next, moving the enemy and defining the old positions for collision

oldx=enemyx(enemy)
oldy=enemyy(enemy)

if moveright=1 then enemyx(enemy)=enemyx(enemy)+10:moveright=0
if moveleft=1 then enemyx(enemy)=enemyx(enemy)-10:moveleft=0
if movedown=1 then enemyy(enemy)=enemyy(enemy)+10:movedown=0
if moveup=1 then enemyy(enemy)=enemyy(enemy)-10:moveup=0

position sprite/object,enemyx(enemy),enemyy(enemy)
if colliding = 1
position sprite/object,oldx,oldy

here is the problem for me, i cant help you any further this fast, but here you need to make what the enemy must do, wich direction he must go etc, try another way... etc,

endif

next enemy

loop

i should it do a bit like this.

good luck,

syntax error??? it isn't an error, it is a feature
Turoid
20
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 22nd Jul 2004 05:44
is my explanation the solution?

syntax error??? it isn't an error, it is a feature
Turoid
20
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 2nd Sep 2004 05:41
no one looked at my ai example ?

syntax error??? it isn't an error, it is a feature

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 4th Sep 2004 06:58
Quote: "no one looked at my ai example ? "


Well, I looked at it!

Looks like it would work to me.


Login to post a reply

Server time is: 2024-09-22 23:22:17
Your offset time is: 2024-09-22 23:22:17