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 / help with AI

Author
Message
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Dec 2008 02:17
well of course anyone can make a box come at you when u get close. but what about when have stairs and floors and stuff and things like if there are looking at u they will follow otherwise just ignore u.

pretty much some basic AI help thanx
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Dec 2008 18:46
Quote: "pretty much some basic AI help thanx"


Unfortunately, there isn't really any such thing. AI (or Artificial Intelligence) is - or can be - a very complex subject and not the sort of thing you can expect to be covered to any decent level in a forum post.

With DBC it basically boils down to creating a series of procedures or functions which do AI checking before any object is moved.

Take the game of Pong which has probably the simplest form of AI you can have...

With AI for the CCP, the new position for the paddle is calculated based on the current status of things going on in the game - for example the current ball's Y screen position.

So, if the paddle is at Y=300 and the ball is at Y=40 then the paddle needs to be moved upwards towards the ball's Y position. You therefore need to deduct 5 from the paddle's Y position.

However if the ball was at Y=580 then the AI routine would ADD 5 to the paddle position to move it down the screen.

If this is done each time the ball moves, the paddle appears to have some form of intelligence and be 'playing the game'.

Obviously, this method results in an unbeatable opponent, so you can decrease the CCP's paddle movement speed to give it less chance of actually reaching the ball when it builds up a bit of speed - or increase it to make the game a bit harder to play.

In more complicated games, it's simply more of the same. You need to add routines to check absolutely everything each time the player or any enemy moves...

How far away is each enemy?
Which is closest and can he see me (line of sight)?
What objects are blocking his view of me?
What does he do if he sees me?
Which objects in a character's path do you have to go around rather than climb over (pathfinding)?

The list is endless and each involves a different set of programming skills - often quite complex.

Try checking out the stickies at the top of the board and Google the terms 'AI tutorial' and 'pathfinding tutorial' to start with.

Good luck!

TDK_Man

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th Dec 2008 01:04
Welcome back TDK!
I've always struggled with AI; anything more advanced than pong and I don't know where to start, it's really frustrating and I feel I'm at a stage where I really need to learn some decent AI tricks.
I'll tell you about what I'm trying to do and see if you (or anyone else) can give me a few pointers.

I'm starting a few mini-projects that will eventually help me make my first big game - a Spartan army game - I'm currently trying to make a combat system, I've worked out a pretty good system but I can't think how to make the opponent act.
Here's how the different actions stack up...

Don't think I got it totally right there (don't have my notes with me) it is supposed to be a rock, paper, scissors type option where each action is strong against one and weak against another.
Any tips on how to make the enemy choose what to do?

A small program that works is better than a large one that doesn't.

DBC Challenge Rank: Rookie
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Dec 2008 03:42
wouldn't you need it to be random because if the enemy doesn't know what your choosing then he would just choose some random attack "hoping" that you wouldn't pick the same or something better. thats how i see it
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 6th Dec 2008 05:05
Yes, it does have some randomness. Use the RND() command for that.


"I reveal my trap card, GEORGE DUBYA BUSH!
America loses 2000 Life Points! America loses." -Deucalion2
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Dec 2008 05:31
but back to the AI in other words the best thing for me to do is look over other stuff and figure it out?? haha

thats worked well for me before with sparky's dll lol

Login to post a reply

Server time is: 2025-06-07 17:09:30
Your offset time is: 2025-06-07 17:09:30