Simple AI Needed!

This is a discussion on Simple AI Needed! within the Game Programming forums, part of the General Programming Boards category; The last 'missing peice' in my project is AI, as in 'CPU' Players in a Simple Mortal-Combat type game. Can ...

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

    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?

    SPH

    P.S. AIM: aGaBoOgAmOnGeR
    Email/MSN: minime6696@hotmail.com

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    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)
    Stand
    else if (RanNumbr <=25)
    Seek
    else if (RanNumbr <= 35)
    Flee
    else if (RanNumbr <= 50)
    Punch
    else if (RanNumbr <= 70)
    Kick
    else if (RanNumbr > 70)
    Block
    end

    **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
    Posts
    210

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

    if(!player(duck))
    {
    cpu(lowKick);
    }
    else if ... ect

    You already have the collision done?
    Last edited by Invincible; 02-15-2002 at 08: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, 05:55 PM
  2. Help needed with a simple programm!!
    By jabrouni1 in forum C Programming
    Replies: 16
    Last Post: 11-21-2004, 08:07 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    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 Cprogramming.com
    Replies: 10
    Last Post: 04-10-2002, 07:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21