🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

new to AI what are basics

Started by
11 comments, last by DirectXXX 21 years, 9 months ago
ok i know what AI is. what are things i need to know before doing AI prog. Technically like DataStructers etc etc and Generally ...
3D Side-Scroller game demo Project-X2 "playable"Lashkar: A 3D Game & Simulation Project demo @ lashkar.berlios.de
Advertisement
buy a good book

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...
Best to have a strong ability in using graph and tree structures and be able to perform AT LEAST basic DFS/BFS. You will need to be fully confident in these in order to really understand some of the decision/search algorithms.
Knowledge of discrete maths helps too for areas like Knowledge representation etc..
AI is quite a wide topic, I dont think one can give a clear answer here. There are several approaches to AI in general, some are based more on planning, some more on reflexes, some on tree searches, whatever you can imagine.

AI cannot be put into several needed data structures or one book. The best thing in my opinion would be a testbed to gain experience, then you can decide on your own whatarea of AI would be interesting to you.
hmmm, I don''t know much about AI but wouldn''t a bunch of else if''s create a fairly good AI?
-----------------------------Language: C++API: Win32, DirectXCompiler: VC++ 2003
What articles/links in the AI section of this site (http://www.gamedev.net/reference/list.asp?categoryid=18) are good to start at??

+++ Corvus +++
+++ Corvus +++
quote: Original post by simon10k
hmmm, I don''t know much about AI but wouldn''t a bunch of else if''s create a fairly good AI?


I created a single player VB tic-tac-toe once using an one dimensional array of size 9. I programmed the game AI with four simple rules:

1. Can I (the computer) make a move to win the game?
2. If I (computer) cannot make a move to win the game, is there a move I can make to stop the human user from winning?
3. If there no move satasfies rule 1 or 2, take the first available corner. The corners were array elements were 0,2,6,8.
4. If no move satasfies rules 1,2 or 3 then take the first available non-corner. Non-corners were array elements were 1,2,4,5 and 7.

Pretty simple but fairly effective. If the computer got first move (deciced by random number generator) then the best the human player could do was to get a draw. If the human had the first move and didn''t use the three corner stratadgy(sp?) the computer would usually get a draw and sometimes even win.

For this very simple game I used if-else statements to program the "AI" and I was surprised by the size of the resulting code.
It was fairly large. Now take into account a game like chess with an 8x8 position playing board, 32 game peices and a (sort of) complex rule set for moving those peices. You would be hard-presed to use if-elses to program the AI for even a decently difficult chess game.

Real AI uses algorithms based on rule sets to make decisions or plan ahead taking into account the possible result of certain actions. eg. The computer "thinks" if I move here, the human can make the following moves, as a result I can react by moving...
The computer will look ahead a prescribed number of moves, pick the one with the best results and make its move accordingly. After the human makes his moves the computer will re-evaluate the situation before making the next move.

The "AI" I used in my tic-tac-toe game isn''t really AI. I pretty much hard coded the way the program could react for every possible player move, there was no decision making on the part of the program.

--------------------------------Screw you guys! I'm going home.
If you don''t have a particular goal, and are therefore wandering around aimlessly hoping for some direction, your best bet (for free) is to go to www.gameai.com, pick a subject that interests you and take it from there.

The internet has a wealth of information related to game AI (and AI in general) but once you get hooked you will almost certainly have to start buying books.

If you do have a goal then tell us what it is and we can point you in the right direction.


As far as data structures and algorithms go, you will be doing yourself a favour if you learn about trees and graphs. In particular, how to search them and how to find the shortest path through them.

Have fun.



ai-junkie.com
Game AI tends to be quite basic due to the large amounts of processor power complex AI can use up. I''m assuming you want to know about the basic AI structures that games use to control the actions of enemies. There are three basic thins you are likely to need.

1. Deterministic Logic: i.e. Your series of if...then statements, it''s called deterministic logic since it''s output is entirely dependent on the input. The main problem with this approach is that it can get very unwieldy very fast, it''s all well and good using it for Tic-Tac-Toe, but can you imagine what it would be like to try and implement it for a chess AI?

2. Finite state machines: A finite state machine is an AI which is similar to deterministic AI, except it uses a different set of logic depending on the values of 1 or more variables within it.

For example look at the following psuedo-c++


  enum STATES{S_ATTACKING, S_RUNNING, S_SEARCHING}class CEnemy{private:   // enemies position, damage level etc...   STATE m_sState;public:   // constructores, destructors and whatever else   void doStuff();};void CEnemy::doStuff(){   switch(m_sState)   {   case S_ATTACKING:      // move towards player, firing if possible      // if the damage level is too high then set m_sState      // to equal S_RUNNING      break;   case S_RUNNING:      // move away from the player      break;   case S_LOOKING:      // Move randomly, if the enemy can ''see'' the player      // then set m_sState to equal S_ATTACKING      break;   }}  


As you can see from the above the enemy acts differently depending on what it''s doing and certain conditions change what it is doing. For example when the enemy is searching for the player it sets it state to attacking when it has found the player.

Finite state machines are great for doing fast and simple AI, they are often used as the basic structure of an AI. Sometijmes you here the phrase "Fuzzy State Machine" - the phrase fuzzy simply means that there is a random element somewhere in the system. In this case you might have a statement which says:


  case S_ATTACKING:   // other stuff   if (m_nDamage>DAMAGE_THRESHHOLD && rand()%2==0)      m_sState=S_RUNNING;   break;  


I.E. there is a 50% chance that an enemy will flee if it takes too much damage.

3. Decision Trees

I have to admit I never fully got my head round these, mainly because all the articles I read on them didn''t provide any syntax explanation to the bizarre math that tends to get used in their creation. On a basic level it works on the principle that an agents action''s (an agent is an AI term for an autonomous AI controlled thing, such as a bot in Quake III) are dependent on a number of conditions and various combinations of actions can be expressed in a single tree.
For example you have a robot arm which can hold an apple. It has three actions it can take: Pick Up The Apple, let go of the apple, hold the apple. Now we say that we want the robot to hold the apple while the sun is up (bear with me here, my imagination for good examples seems to be on holiday). This means there are two conditions that matter: Are we holding the apple and Is the sun out.

So our tree root is simply the question ''Is The Sun Out?'' If it is then the decision maker takes the left child of the root which leads to a node that asks the question ''Am I Holding The Apple?'' if the answer is yes then the node instructs the arm to continue holding the apple otherwise it instructs the arm to pick up the apple. If the sun is not out then the decision maker would move to the other child which would also ask the question ''Am I holding the apple?'' if the answer is yes then the node instructs the arm to put down the apple, otherwise it instructs the arm to do nothing.

Now the more eagle eyed among you will have said "I could do that with a couple of if statements", yes you could, but this example involves a very simple problem with very simple rules and decision trees are used for far more complex pieces of logic than this example is meant to demonstrate.
Maybe you could tell us what the application is for?

------------------http://www.nentari.com

This topic is closed to new replies.

Advertisement