Pong AI?

This is a discussion on Pong AI? within the Game Programming forums, part of the General Programming Boards category; Hi, I have a question about some AI I want to put into a little PONG project I'm making to ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    7

    Pong AI?

    Hi, I have a question about some AI I want to put into a little PONG project I'm making to expand my game programming skills.

    I've read a few AI tutorials, and I get lost a few paragraphs in. I want to create a very, very basic AI system for one of the paddles. The only problem is, I don't know how to do this. I've heard of many different types of AI, neural networks, fuzzy logic, etc, but I have no idea which one to use, or how to implement it in my game. If someone could point me in the right direction, that would be great.

  2. #2
    Registered User MathFan's Avatar
    Join Date
    Apr 2002
    Posts
    190
    A very simple way of doing this would have been the following:

    1. When the player has hit the ball, calculate its trajectory and find out the exact location of where the ball is going to reach AI paddle
    2. Now take the newly calculated position and add random values to it (with rand() or something)... The smaller level, the larger the possible value of random can be, and therefore the larger is the chance for the AI paddle to miss the ball. The higher the level, the smaller random value should be, and therefore chance of missing the ball will be smaller
    3. Move the AI paddle to the position you calculated in step 2.

    Or you can do it just like this:
    Code:
    int HitPercentage=30;
     
    if((rand()%100)<HitPercentage)
    //move the paddle to the location where the ball is going to hit
    else
    //move the paddle to some other location (for more realistic visual results somewhere near the ball, but not touching it)
    The OS requirements were Windows Vista Ultimate or better, so we used Linux.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    5
    Or you could have a paddle that goes to where the ball will hit, but moves slower than the ball, giving the player a chance.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple space combat AI
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 01-05-2009, 11:54 PM
  2. chess ai contest
    By Raven Arkadon in forum Contests Board
    Replies: 7
    Last Post: 07-09-2005, 06:38 AM
  3. AI Contest Proposal
    By MadCow257 in forum Contests Board
    Replies: 4
    Last Post: 03-13-2005, 02:27 PM
  4. Game Design Topic #1 - AI Behavior
    By TechWins in forum Game Programming
    Replies: 13
    Last Post: 10-11-2002, 10:35 AM
  5. Technique of all board-like games?
    By Nutshell in forum Game Programming
    Replies: 28
    Last Post: 04-24-2002, 08:19 AM

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