forums

TNT Basic Forums > Programming Q&A
New to AI
< Last Thread     Next Thread >
Author
Thread        Post A Reply

09-16-2002 00:24

Posted by:
Bud

Find more posts by Bud

Hi everyone,
I am new to programming and I want to make an overhead shooter game but I cannot figure out how to do the enemy AI. What I want the enemy to do is when the player approaches the enemy(which would be like a tank or soldier) attacks the player. Does any one have any suggestions or source code i could look at? Thanks Alot
<-------------- Bud

09-16-2002 23:56

Posted by:
Mathew

Find more posts by Mathew

If you want me to do more complicated code, reply.


If you want and ennemy to shoot when you're near it, use something like that:

(X1 is you and X2 the ennemy )

if X1>X2-100 and X1< X2+100
'do actions here
end if

>>this would make the actions you will specify happen when the character gets 100 pixels or less close to the ennemy.


This is a very basic example, so I wouldn't be surprised if you wanted more. I would suggest you that you learn at your speed. Start by doing completely stupid ennemies if you can't do better. When you will become better, you will have no problem making ennemies be a bit smarter than now.

If you need more help, just reply.

12-11-2002 00:32

Posted by:
Zip

Click Here to Email Zip   Find more posts by Zip

listen too the master

I always think that the best approach too doing AI is that presented by Sid Mier(oh my, i think i spelled his name wrong), in your case make a enemy that shoots at you when you come near him, once you defeat it, think about what it did that was stupid, then code it so it doesn't do that, at first the stupidest thing it does will probably be not too run away when you charge it with some 40d3 rocket launcher, so have it automaticly go in the oposite direction, just keep on like this and youll have a good AI in no time.
One good feature that alot of people don't consider is the AI's desire not too die, some AIs naturaly would not have this, like some kamakazie bomb laden cult member, but let it consider its HP too yours, how much damage it can do versus how much you can do, wether or not it has allies etc.

12-11-2002 04:30

Posted by:
Holmes

Location:
Santa Rosa, Ca

Click Here to Email Holmes   Find more posts by Holmes

Zip, I think thats more complicated than what Bud is looking for (even more of a complex technique than I used for Raptor-ASF).

There's a few simple teqniques for AI. You could check out the AI in Raptor, as there is a variety of types of units.

Some units crash straight into the player
Some units steer in to aim, fire, and steer out, avoiding the player
Some units just fly straight and fire well aimed shots.

I didn't code Raptor with the intention of ever releasing the source code, however, so you may (will) find it confusing. Its also VERY long.

http://homepage.mac.com/solidmag/raptor/Raptor-ASF%20Source.sit

If you find Raptor too confusing to be useful, I could write a good tutorial on AI for you and other TNT basic users.

01-05-2003 02:58

Posted by:
Ashlin Aronin

Click Here to Email Ashlin Aronin   Find more posts by Ashlin Aronin

Holmes-
That tutorial sounds very useful. I would be grateful if you did that.

01-06-2003 09:08

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

buggy code download

I don't know why, but when I used the link posted above to download it the file was buggy. Is there any possibility of putting the source code in Simpletext, or something similar to download it? Obviously we won't be able to run it, but it can then easily be copied and pasted into Heirolglyph so the code can at least be analysed.

Thanks,
mark_667

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.