Thread: Simple AI Needed!

  1. #1
    Registered User minime6696's Avatar
    Join Date
    Aug 2001

    Lightbulb Simple AI Needed!

    The last 'missing peice' in my project is AI, as in 'CPU' Players in a Simple Mortal-Combat type game.

    Can anyone help me?


    P.S. AIM: aGaBoOgAmOnGeR

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002

    Fighters' AI

    What you need to do is declare a variable that represents your "CPU" fighter's possible states; ie: punch, kick, block, seek, flee, stand-still - and assign a number (percentage) that represents each of these. Then at each iteration where you check your actions you would generate a random number and check it against the action's number.
    Here's some psuedo code to show you what I mean:

    **start code**

    Stand = 15;
    Seek = 25;
    Flee = 35;
    Punch = 50;
    Kick = 70;
    Block = 99;

    RanNumbr = generate random number here

    if (RanNumbr <= 15)
    else if (RanNumbr <=25)
    else if (RanNumbr <= 35)
    else if (RanNumbr <= 50)
    else if (RanNumbr <= 70)
    else if (RanNumbr > 70)

    **end code**

    Of course this is generalizing it a bit, but you should get the idea. Hope this helps.

  3. #3
    Registered User Invincible's Avatar
    Join Date
    Feb 2002

    Question If you were writing in C++

    Could you also set up some classes and objects and have the CPU check against the Users moves. Something like...

    else if ... ect

    You already have the collision done?
    Last edited by Invincible; 02-15-2002 at 09:41 PM.
    "The mind, like a parachute, only functions when open."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Action Game - AI Contest
    By Queatrix in forum Contests Board
    Replies: 4
    Last Post: 01-18-2007, 06:55 PM
  2. Help needed with a simple programm!!
    By jabrouni1 in forum C Programming
    Replies: 16
    Last Post: 11-21-2004, 09:07 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Technique of all board-like games?
    By Nutshell in forum Game Programming
    Replies: 28
    Last Post: 04-24-2002, 08:19 AM
  5. Simple AI for tic-tac-toe...
    By Nutshell in forum A Brief History of
    Replies: 10
    Last Post: 04-10-2002, 07:49 PM