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.

DarkBASIC Discussion / Simple A.I.

Author
Message
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 4th Jul 2008 18:49 Edited at: 4th Jul 2008 18:51
Alright, this post is about two things.

First:
I am creating a zombie shooting top down style game, and I need to create AI so that the zombies can find their way around things like trees, and other zombies.It doesn't need to be pathfinding per say, but the zombies have to know how to find their way around something like a tree, or house, or another zombie, and just try to head towards the player, even if it didn't take into account that it would come to a dead end later on. It needs to be very fast, there will be quite a few zombies, so speed will be an issue, as it already is(explained below).

Second:
As soon as I add collision to the zombies, the game slows down to 20 fps, and if I try setting all their collision types to boxes, it slows to an unplayable 1 fps, could I use a AI system that doesn't use collision?



Picture Attached.

Attachments

Login to view attachments
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 4th Jul 2008 21:04
Can anybody help?

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 4th Jul 2008 21:48
actually, I read a book about game ai a while ago. Unfortunately, I can't find it now, so I can't get the formula. Basically it used a formula that modeled atomic repulsive forces and just applied it to other objects. It was called the Lennard Jones model, should be googleable. Sorry I can't be of more help, but at least it can point you in the right direction.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jul 2008 23:13
@ satchmo

A few things, If you're using collision for the ground, everything that is touching the ground will constantly be collision detecting which will slow things WAY down (I found that out making a room using cubes on a plain - I just wan't thinking! The walls (cubes were always colliding with the floor) )
Either raise things so they don't actually touch the ground, or turn off collision with the ground, or use a matrix.

If all of the zombies aren't in screen at once, turn off the collision of the ones that are off screen and also hide them:



Use respawning to reduce the number of actual objects. In stead of 1000 zombies, use 200 (for example) and as one dies respawn it (reposition it off screen or somewhere) and keep a count until 1000 zombies have been killed.

Use Sparky's Collision DLL for faster collision checking. With large amounts of objects, it makes a big speed difference.

If your environment (trees, houses, rocks) are individual objects try and combine them into fewer or even one object and set collision to polygons. A series of individual objects that add up to a certain number of polygons take more processing power than a single object with the same poly count.

A little tricky to program (not really) but you could create 1 cube that is maybe the size of a zombie. Turn off or don't use any collision on the zombies. Use this one cube and position it in front of each zombie, 1 at a time and detect collision. If collision is detected, turn the zombie randomly left or right 47 degrees and have them walk forward a certain distance before you program them to face the player or whatever direction they want to go. Every iteration or every few iterations, you position the cube in front of each zombie. Combine this with hiding and showing in screen zombies.



Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 5th Jul 2008 01:17 Edited at: 5th Jul 2008 01:19
Alright, I wrote up some code from your idea, and with a bit more time I could get it to work how I want, currently it just looks like a game of zombie pong, lol.

Also, I still don't know why, but whenever I try to use the command set object collision to boxes/sphere/polygons, at max in game I get 4 fps. If I let it use default collision, I get 30-35 fps.

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Jul 2008 01:49 Edited at: 5th Jul 2008 01:53
The idea of the one cube is to use it as the collision detection with the environment - you never use the zombies for collision detection that's why you always put the 1 cube in front of the zombies. And by 1 cube I mean 1 cube - not a cube for each zombie - you just reposition the cube in front of the next available zombie.

Quote: "Also, I still don't know why, but whenever I try to use the command set object collision to boxes/sphere/polygons, at max in game I get 4 fps. If I let it use default collision, I get 30-35 fps."


How many objects are you setting for collision?

Make sure for every object you want collision on you specifically use the command set object collision on <obj> and for every object you don't want collision for set object collision off <obj>.

Also instead of set object collision to boxes etc, try using make object collision box <obj>,<parameters>

And again, using sparky's collision dll should help quite a bit.

Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 5th Jul 2008 02:05 Edited at: 5th Jul 2008 02:06
I am planning to use Sparky's, but I can't find a DBC specific version, and I would have no clue how to use it.


Also, I am only using 1 cube, take a look at my code.



Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Jul 2008 02:20
Off to a bbq. I'll get back to you later. maybe someone else in the interim can help too.

Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 5th Jul 2008 17:22
Alright here is my Sparky's code so far, I can't get it to work, even if in the function I ask it to print out the rays position, it says it's in the right place, but it won't register any collision.



Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Jul 2008 05:34
In your collision code, you have:



Collide is the return value inside the function. You need to set bang=to the function:



Try that out - see if it makes a difference.

Also, if you are detecting collision with each individual zombie, you don't necessarily need the feeler object - but it can help to get the resulting position of the ray.

I made a demo NOT using Sparky's DLL and just using the feeler object. I use a 15x15 matrix, 300 green pillars (boxes) as obstacles, and a total of 200 zombies. The 300 green pillars are actually all one object. I set it to polygon collision and I set the feeler to box collision. The player is the other object that has collision as well. As a result, only three objects are set to collision. For each zombie I use set object collision off.

at setting the sync rate to 0, I get a pretty steady FPS of between 125 and 135. I hide all off screen zombies, and make them respawn at their original locations - and don't update their positions or test the feeler until they are in screen.

Using a similar method with sparky's, I get anywhere from 138 to 220 fps. I originally was going to attach an executable of the Native DBC collision method with a feeler object, but I'm gettings HTTP errors from the TGC server. Oh well.

Enjoy your day.

Login to post a reply

Server time is: 2025-06-05 23:42:33
Your offset time is: 2025-06-05 23:42:33