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 / i need some AI help

Author
Message
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 24th Nov 2005 00:44
hi guys i need some more help because im still learning and i want to know how to use AI so i can use it on a object so it will move around by itsself like an enemy in a game can some one please give me some very detaild instructions and some code please it woul be really nice if you could thanks guys.

ATI mobility radeon X600 graphics card
AMD 64 Bit processor
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 24th Nov 2005 00:59
You know, you can search in the codebase, and on these forums. You will get thousands of results...

I, myself, am horrible at AI. I could never do it. It's one of my greatest weaknesses...

Good Luck!
devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 24th Nov 2005 02:30
lots and lots of if-thens and some code to figure positions out

u can see how I did it in the source code for a demo I made

http://www.verydevastating.com/dmhsource.zip

verydevastating.com
x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 24th Nov 2005 03:11
Actually, I wanted to comment on that,Devastation.

Doubt ill ever use any of it,but was admirable for you to have
made it OpenSource like that. Good job man.

- Do it, Do it Right, Do it right now..
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 24th Nov 2005 03:45
ok thanx alot verydevestating ill look at that and ill search the code base!

ATI mobility radeon X600 graphics card
AMD 64 Bit processor
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 24th Nov 2005 17:00
i meen well if its not to much can someone kinda teach me how to make AI!

ATI mobility radeon X600 graphics card
AMD 64 Bit processor
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 24th Nov 2005 20:57
Quote: "i meen well if its not to much can someone kinda teach me how to make AI!"


the trouble is, it is too much trouble, sorry but it takes a lot of work to get a decent AI beyond the blindingly obvious monster follows player code, and for every game you can think of theres a specific way to impliment it, not only is the AI for chess totaly different from the AI for Quake, but the AI for Quake and the AI for HalfLife are totaly different too, there is no one fixed universal bit of code that does AI, add ladders to your game and you may well need to re-write the whole AI, add doors and you need to add more AI to get the NPC to open them (or not), even something as simple as adding another weapon means you need to alter the AI to allow for it (no AI in it`s right mind is going to melee a player with a sawn off shotgun).

for every option theres a dozen-hundreds-thousands of ways you could code the AI to respond, it just isn`t as easy as asking for an example, any example will be trivial and no real use in a game, try breaking it down into stages and then code those, read up on state engines and fuzzy logic, genetic learning algorythms etc, from simple state engines to elaborate branching scripts or learning bots, you need to decide exactly what to do and how to do it in easy stages, then impliment them one by one.

for example, for a fps bot that is going to attack the player...

is player visible
what weapon has player
weaker than mine...attak
stronger than mine...move to cover, fire from cover
am I hurt too bad
if yes then move to medical pack
if not then continue to fire
am I low on ammo
if yes then move to ammo pack
if not then fire
is player still visible
if yes then fire
if not then move to last seen position

run that in a loop and you have a basic AI that will do more than just shoot, the specifics are up to you, if you play and study commercial games then you will notice that they have cheats, "vision" is just proximity in some games, approach from behind and the instant you get x close they respond, even when they cant see you directly, be as tricky as you like hiding, they make a path straight too you, all indications the AI is fudged to make it seem more powerful, just play some games and work out how they do the AI, after playing about for while in god mode then you can start to see how the AI actualy works.



Do parachute manufacturers have a refunds policy?
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 24th Nov 2005 21:23
wow!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ATI mobility radeon X600 graphics card
AMD 64 Bit processor
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 24th Nov 2005 23:33
Basically what I do is use arrays and states. You cannot make multiple enemies without arrays. with the array you can store data for every enemy, i.e.



the word "dim" will make an array, so say enemies=10, you can have say: state(1)=whatever, state(2)=whatever.. etc.

the, using distances, healths, angle differences, scores, whatever you want you enemy to react on, then change the state. Don't change the action of the enemy, it wont work out.

so, say the enemies state is 1, it would attack, if it was 2, it would retreat, so, if state(1)=1 and state(2)=2 then enemy 1 would attack, and enemy 2 would retreat.

If state(1)=2 and state(2)=1 then the opposite would happen, enemy 1 would retreat, and enemy 2 would attack.

DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 24th Nov 2005 23:43
can someone make a small example useing primitive objects say a box and a sphere! and make it so if the box is visible then have the sphere some to it and use fog with it for the visible thing

ATI mobility radeon X600 graphics card
AMD 64 Bit processor
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 25th Nov 2005 05:25
can someone help

ATI mobility radeon X600 graphics card
AMD 64 Bit processor
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 25th Nov 2005 15:38 Edited at: 25th Nov 2005 15:38
Just do something like:

If the sphere object is a certain distance away from the cube
Point object sphere at the cube object
Move object sphere
endif

Not actual code
Red Ocktober
21
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 25th Nov 2005 16:13 Edited at: 25th Nov 2005 16:13
first of all... what you want to do isn't something that's gonna automatically happen with a few lines of code, or something that a paragraph or two here will teach you...

you're really gonna have to know exactly what you want your ai object to do... how you want it to move, what to do when it 'sees' the player... how its supposed to die... stuff like that...

once you decide on these things, you're gonna have to figure out how to implement its behavior using the commands available in DB... how to tie in the behavior with animations, sounds, and a few other things...

there are many posts in the forums that touch upon this topic... and there web has many sites that discuss pathfinding and a* and state machines... to get you going...

you've chosen one of the more difficult subjects to explore... my advice, start simple... make simple ai examples first... like an object that react to another...

having an enemy evade and hunt a player is an advanced example of ai... if it were easy, everyone would be doing it...

good luck

--Mike
DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 25th Nov 2005 16:57
ok ill try thanx evryone!

ATI mobility radeon X600 graphics card
AMD 64 Bit processor
devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 25th Nov 2005 17:12
good luck db newbie

and a word of advice: if you keep your levels squre, it's easier to get hte coordinates and decide if enemies and players are in the rooms, hallways, etc.

verydevastating.com
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 25th Nov 2005 17:18 Edited at: 25th Nov 2005 17:23


simple example that allows you move about, when you get too close to the patroling sphere it shouts HALT! and chases you, if you manage to put enough distance between you and it then it stops and patrols the current location, you could change the chase to firing, or get it to chase you and when it gets much closer then you can get it to fire, thats all down to how you impliment the AI and what you want characters to do.



Do parachute manufacturers have a refunds policy?
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Nov 2005 18:19
I think you should slow down, people have been giving you lots of tips, try making some code yourself, then you will progress much faster, besides, if people give you code then you don't understand what it all means unless you read through it 1,000,000,000,000 times, if you make it, you will understand it all.

Here's the AI I made for an fps, it wont work just by placing it into db, (it's dbpro code anyway), but it's just to show you what you could do if you tryed coding yourself, and what you couldn't do by taking code.



DB newbie
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 25th Nov 2005 18:25
ill try evrything u guys put up thanx for the help~

ATI mobility radeon X600 graphics card
AMD 64 Bit processor

Login to post a reply

Server time is: 2025-05-22 21:36:39
Your offset time is: 2025-05-22 21:36:39