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 Professional Discussion / Artificial Inteligence in DBP games

Author
Message
david
21
Years of Service
User Offline
Joined: 31st Oct 2002
Location: - Please Select -
Posted: 18th Nov 2002 21:21
I have made a basic FPS game with DarkBasic Pro, but I am wondering how to do any sort of AI for the computer controlled enemies.

For example, how would I go about giving the enemies AI so that they could track you (the player) down if you were within a certain range of them, and make them avoid the walls of the level? I can get the position of the player, and the positions of the walls are saved in an array, but how do I code the AI?

If anyone can help me with this problem, has some example AI code or somewhere where there is information about AI in DarkBasic, I would be very grateful.

Thanks.
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 19th Nov 2002 13:20
http://www.darkbasicpro.com/apollo/view.php?t=924&b=6

Check this out.

This has "Fiasco" written all over it.
QuothTheRaven
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 19th Nov 2002 15:18
The biggest thing is finding the distance between the 2 objects. Remember those geometry courses? A^2+B^2=C^2? You have to use that to find the distance. I'll post code as soon as I get home.
david
21
Years of Service
User Offline
Joined: 31st Oct 2002
Location: - Please Select -
Posted: 19th Nov 2002 21:24
Thanks for all of the help.

Mirthin - I really wanted to know how you would get an enemy to walk around walls - some pathfinding logic, but this seems very hard. Anyway, thanks for the link.

QuothTheRaven - Thanks, but I can do this anyway - this is easy compared to what I want to do (seems very hard to me).

Can anyone else help?
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 19th Nov 2002 23:30
ahh, pathfinding - use collision detection : an invisible, flat box. Then you can get your enemies to turn before they 'bleed' into the wall.

This has "Fiasco" written all over it.
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 19th Nov 2002 23:48
I wrote some code a while ago that made a guy walk around and look about randomly. It was fairly novel for a while, but then soon became useless. I can't seem to do even basic AI, getting something to turn in steps the right way to face something else. They always turn the wrong way or just end up jittering about between two angles. If I could get that sorted, then avoiding walls shouold be easy, just run away from them if the object gets too close to them.
hexGEAR
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 20th Nov 2002 00:53
hmm, i'd suggest you have check points everywhere on your stage, since the bad guy does not know exactly where your man is (unless he has a radar which would just make your programming life hell), he moves from checkpoint to checkpoint, you then use the "get static line of sight command" to check if as he moves he can see you man (no walls blocking view), if he does then he pursues. If the bad guy pursuies and hits a wall (meaning that you have outran him) he then continues his checkpoint to checkpoint journey.

to make it even harder, the bad guy is very fast so once he sees you, he's gonna always follow unless you program your ai to kill slowly, then he attacks for a while then runs away again like in unreal tournament.

you set the checkpoints in a way that the bad guy can move from one to another withough hitting a wall. Then you use the "point object" command to point to the checkpoint and "move object" to move there. when he gets there, he chooses a new one etc. So basically, for example you have 5 checkpoints (all with x and y coordinates), your badguy moves from 1 to 2 to 3 to 4 to 5 to 4 to 3 to 2 to 1 etc and all the while checks to see if he can see the good guy.

if u understood that then i'm sure u could find more complex paths for you a.i to follow.

your birth was a blessing, sent to live and die on earth as a lesson, we each have a star all you have to do is find it, once you do, everyone who sees it will be blinded - DMX
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 20th Nov 2002 01:06
Eugh, not exactly a walk in the park.

This has "Fiasco" written all over it.
hexGEAR
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 20th Nov 2002 01:13
yeah, it is kinda tedious, maybe you should forget about it if your just making a plain old fps.

your birth was a blessing, sent to live and die on earth as a lesson, we each have a star all you have to do is find it, once you do, everyone who sees it will be blinded - DMX
Nikkoz
21
Years of Service
User Offline
Joined: 31st Aug 2002
Location: Sweden
Posted: 20th Nov 2002 16:59
Take a peek at the A* alorithm.

Login to post a reply

Server time is: 2024-03-28 14:56:29
Your offset time is: 2024-03-28 14:56:29