Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
AI
Author Message
TheZsterBunny

Posted: 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.

AI.

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?

-bunny

gamer

Posted: 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?
Tony

Posted: 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
Tony's programming blog. DWITE - a programming contest.
gamer

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

very useful tutorial there tony
McKenzie

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

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]www.mazeworks.com [/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]www.gamasutra.com [/url]
TheZsterBunny

Posted: 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.
Delta

Posted: 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 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.

TheZsterBunny

Posted: 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.

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

Andy

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 9 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: