Game Development Community

(Theory)Enemy AI

by Charlie Malbaurn · in Torque Game Builder · 03/10/2005 (1:17 am) · 19 replies

Hey all,

I am thinking up a game that I want to make somewhere down the road and one of the main things that pops up is Enemy AI. I know that TGE has basic AI implemented but I don't know what the plan is for AI for 2td.

Anyway, I wanted to start a thread and see how people are currently handling AI in there projects.

Basically I am thinking of an overhead play scroller and want to make my enemies run and patterns and be able to detect patterns. I realize that it is going to be a bit ambitious but hoped that maybe someone had a couple of theoretical Ideas on how to go about it.

Thanks in advance

#1
03/10/2005 (2:53 am)
Don't take this the wrong way guys but this kind of stuff is what you need to develop for your games, not us.

Doing AI abstractly, particularly path-finding is extremely difficult. AI can mean a number of things and is a major piece of work to implement so that it's useful to lots of game genres.

It's kinda easy to expect T2D to do it because you can see lots of situations where it would be useful but you are the game developers here. We can give you the engine and the tools and provide documentation but eventually, you have to pull your finger out and do key pieces of tech for your game. Not everything can be done in scripts all the time but that doesn't mean we've naturally got to implement it for you.

If we end up doing that, the end result would be a very complex engine with lots of redundancy and overhead and quite frankly, it'll end up being just another complex engine.

Now I'm not saying that we won't ever have any AI in T2D but rather I'm trying to get across that this kind of stuff, at least initially, will come from the community sharing or yourself.

Really though, A* algorithms and basic AI isn't rocket-science but it is nearly always game specific.

The reason I'm trying to state this here is because you quoted that "this would normally be a feature request" as if it's something you'd expect us to provide. :)

- Melv.
#2
03/10/2005 (3:06 am)
There is a castCollision() function, but I couldn't get it to return anything. It might be that I wan't using it properly though.
#3
03/10/2005 (3:09 am)
Melv, I hope that wasn't geared at me since I niether said A) I expected T2D to have stock anything and B) It was a general request to the public at large at how THEY would go about these types of things
#4
03/10/2005 (4:31 am)
Another way you to go about raycasting would be to use the pickLine function. Worth looking into :)
#5
03/10/2005 (6:35 am)
@Charlie: No, not at all. Sorry, I didn't mean to sound abrasive in that post. I was just trying to be clear on a point in particular.

@Philip: The "castCollision()" function works perfectly and is constantly used in the "Pool" demo to show where the cue-ball will hit.

@Corey: Quite correct.

@Rob: Everything in T2D works in world-coordinates!

There are three types of pick function in T2D, "pickPoint()" (point), "pickArea()" (rectangle) and "pickRay()" (line). These functions use the swept collision-detection system and are very accurate/fast. They detect against the objects collision polygons and return a complete list of all objects (if any) that are picked. Note that the "pickRay()" returns the objects, presorted in the order that they collide along the line.

As mentioned above, "castCollision()" is a powerful function that allows you to sweep any object through forward-time to see if it collides with anything. The advantage here is that the objects collision-polygon is used for the sweep against other objects collision-polygons. The important factor here (as is stated in the reference doco) is that the collision-test is done using the objects' current setup. Typically, this would already been setup but if not, you need to setup the collision masks etc.

The way this call works is that you specify a time and T2D will check for a collision over that time-period. If the object is at rest (zero linear velocity) then it will not collide with anything (unless it's currently overlapping something). If you want to check in a certain direction then simply set the linear velocity (using polar for a specific direction), do the "castCollision()" call and then restore/reset the linear velocity and any other settings you changed. Typically though, you'll probably only specify the time for an object moving in a certain direction already.

The "castCollision()" returns you rich collision-info in the same manner as the "onCollision()" callback. It returns the following:-

- collision time
- position x
- position y
- collision normal x
- collision normal y


Here's "castCollision()" in action in the pool demo...

www.subreal.net/vids/t2dhelp/poolcastcollision.jpg
- Melv.
#6
03/10/2005 (7:01 am)
At this point I'm doing really simple AI for prototyping, basically a hardcoded chase/evade routine.
I'm working hard on my C++ skills at the same time, my plan is to add Opensteer for some nice friend/foe AI.
Combined with some "simple" FSM that should add alot to any type of game..
#7
03/10/2005 (7:01 am)
@Melv: I wasn't trying to imply that it was broken, just that I was doing castCollision() and not getting anything returned.

I tried using small and large numbers for the time (incase it was a seconds/milliseconds) thing and it didn't help.

As I've said in other posts though, I'm not really a programmer, so that's probably accounting for the fact that I can't get most things working first time ;)

Once the extra demos are released and I can see some more code in action, I should be able to figure things out more easily.
#8
03/10/2005 (7:13 am)
@Philip: It must be because I'm rushing today as I seem to be coming across as slaming people. Not doing that dude, it's just that I'm at work and I'm posting concisely as possible. :)

- Melv.
#9
03/10/2005 (8:15 am)
@Melv: No worries :)
#10
03/10/2005 (4:24 pm)
I wasn't upset by the post melv, I was just wondering where it came from :)

I realize that your trying to wear a lot of hats right now. Keep up the great work
#11
03/11/2005 (1:27 am)
Just human, just very tired. :(

Feeling grumpy at the moment. Daughter keeping me up at night. No energy.

Going to have a break this weekend from T2D so I come back fresh next week and ready to go. :)

Thanks for all your support everyone, it's very much appreciated and will be rewarded with some cool stuff to come!

- Melv.
#12
03/11/2005 (3:52 am)
Melv, I remember when my daughter was about the same age as yours. I was working full time and going to school at night and she honestly never stoped crying. She would only sleep when she was in the car. My wife and I would take turns driving back and forth to Miami so that we could each get an hour of sleep.

Now shes four and won't get off the computer. She loves to play the demo that I created from the docs. She even gets mad when I try to make it slower for her.

There really is no acomplishment then making something your child enjoys playing with.

Thank you for that.

They grow up too quick. Enjoy it while it lasts
#13
03/11/2005 (4:22 am)
Thanks. :)

She (Jessica) likes watching David Graces 'cloudburst' demo more than the T2D one (which is definately understandable) but unless Dave puts in the ability to control the ship by repeatedly slamming all the keys simultaneously and dribbling on the spacebar, she's not going to get far.

Looking forward to her playing on the computer for real, at least I think I am!

- Melv.
#14
03/11/2005 (11:20 pm)
My daughter was playing the cloud burst today. She gave up on firing and basically decided to not get her butt shot off.


It really is a fun little game
#15
03/12/2005 (3:24 am)
@Melv: You know what would really be awsome?

A Dribble Input System

Think about it, Sony has Eyetoy, Nintendo has Donkey Konga and T2D could have *tada* The Drool Box

Gaming is all about physics these days, am I right or am I right ?

With the right kind of marketing this could be .... big...... think about it, promise....
#16
03/13/2005 (2:41 am)
My daughter wouldn't disagree. Neither would her 12+ bibs a day. ;)

- Melv.
#17
03/13/2005 (5:48 pm)
I have actually been working a drool + poo flinging input system for T2D. AI and stuff can wait, but I think this new input system is extremely important to the engine's future.
#18
03/14/2005 (12:49 am)
... and don't forget the olfactory nasty-odour ID system. :)

- Melv.
#19
03/14/2005 (4:39 am)
Josh I think it's great to have you onboard for this project.
I feel that we finally have that mature corporate backing this great idea so desperatly need.

I picture this system great for say, handhelds. If you feel a bit "dried" up just ask a friendly bystander/fellow bus passenger to chip in.
How about a party game based on this technology or a old-school decathlon remake...

The possibilities are endless... endless I tell you!

Melv, that odour ID system idea aint bad. I always tend to forget my passwords and codes but I always have my morning breath!! :)