Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message

PostPosted: Wed Apr 21, 2004 9:39 pm   Post subject: AI

Over this last year, I've gained an appreciation for all computer games I've ever played. Even the simplest working games have some nice features, that when you try to replicate, you find to be more complex than you may have realized.

However there is one part i've yet to even begin to understand.


The only way I can understand AI is through a bunch of IF statements. However in games like CS:CZ or chess, the AI must have billions of IF statements. That can't possibly be the case; how can 7 bots respond to my moves (which change many times a second) with out killing my computer speed?

Which brings me to my question.

How does one go about making AI?


PostPosted: Wed Apr 21, 2004 10:11 pm   Post subject: (No subject)

i personaly never made ai so im not sure if this is right, do they so arrays?

PostPosted: Wed Apr 21, 2004 10:13 pm   Post subject: (No subject)

if you're just beginning to understand AI, start by reading my lesson on it Smile
Latest from Tony's programming blog. DWITE - a programming contest.

PostPosted: Wed Apr 21, 2004 11:01 pm   Post subject: (No subject)

very useful tutorial there tony

PostPosted: Thu Apr 22, 2004 2:46 am   Post subject: (No subject)

Z, start with the basic question, "What is Artificial Intellegence?"

At a very basic level it is anything that, if done by a human, would require Intellegence. Of course, we are not talking about basic computations. Getting back to your point of infinite ifs, "How do we make this work in code?"
The answer, as Tony's tutorial has shown you, depends on the problem. More often than not you are dealing with arrays, and/or recursion. Some examples:

Hangman AI
suppose you want to make hangman a program where the computer guesses the word bases on the spaces you give it. The computer needs to know a little something about the human language namely what letters are the most common, and what letters occur together most commonly. The answer is not a whole whack of ifs. The answer is a 2-dim array. Picture a 26 x 26 array with the letters of the alphabet on each axis. Each spot in the array is a counter, a count of how many times each letter appears with another, and letter with itself just how many times the letter has been seen. Now feed a dictionary into your program, or at least a data file of commonly used words. (The second option is cool, because as the computer plays, if it doesn't know a word it can add it to the words it knows.) When it comes to the AI, the computer starts by picking the highest number in the grid, if it hits then it looks only in that row for the next highest, otherwise it looks in the whole grid.

Maze AI
Like a vast number of AI cases mazes lend themselves well to recursion. The maze is stored in a 2-dim array of course. The enemy AI has to figure out what is the shortest path to get to you. The basic Idea is try going one step in each direction, then form each non-dead-end, non-backtrack try each new direction until you reach the player. For a better explanation try [url] [/url]

Make no mistake, real AI is hard and time consuming. Only recently has the game industry stoped treating AI like the unwanted step-son and stered giving it the budget required. For a proper look at AI in general check out [url] [/url]

PostPosted: Thu Apr 22, 2004 7:10 am   Post subject: (No subject)

In response to Hangman AI:

a 2 dim 26x26 array is considered AI?

I used something like that in my risk game...

I've been reading too much Asimov.

The thing with the AI i need to make, would be to have the program solve the puzzle as efficiently as possible (least number of moves).

Similar to the maze but I am not at that level of recursion yet.

I've been told to forget the AI part of my game, but without it my final project will be ~500 lines.

not good considering my minor projects were 1000 and 1600 respectively.

(not using line numbers as true comparisons, but as indicators to how complex the program may be. i.e. crossreferencing 3 tables together)

-bunny (Z)

p.s. if anyone has ever played vexed for Palm, you will understand what my AI must accomplish.

PostPosted: Thu Apr 22, 2004 9:50 am   Post subject: (No subject)

I myself have not played vexed... or ever heard of it for that matter but ya... Either use recursion or a well put together loop that continuously checks for wht you need... but ya... maybe if you posted what you actually needed the program to do you'd get more help... cuz if I knew what you meant I could easily attempt to help you saying that we do absolutely nothing in this course anyways... but ya... have fun Wink post some pics too if you can just don't zip them or else I can't really help you... because our school won't let you download them but whatever.

good luck with your ai

PostPosted: Thu Apr 22, 2004 11:38 am   Post subject: (No subject)

Thats the trick.

For this project I am not allowed to use this site to get code.

I can, however, ask general questions and get general answers.

Pretty much I need to check for every possible move and determine which series of those moves would result in the most efficient solution.

PostPosted: Fri Apr 23, 2004 10:12 am   Post subject: (No subject)

for a simple ai, many if statements will do, however, for a board game, the ai has to be able to predict moves. i suggest you dling my othello in the turing fp section, it has the source code for the ai in it
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to: