# Paddle AI: For Pong game

**URL:** <https://forum.kirupa.com/t/paddle-ai-for-pong-game/68460>\
**Category:** flash\
**Created:** [October 26, 2004, 4:27am UTC](https://forum.kirupa.com/t/paddle-ai-for-pong-game/68460 "2004-10-26T04:27:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chockybickyman](https://avatars.discourse-cdn.com/v4/letter/c/7bcc69/32.png) [@chockybickyman](https://forum.kirupa.com/u/chockybickyman)\
**Post date:** [October 26, 2004, 4:27am UTC](https://forum.kirupa.com/t/paddle-ai-for-pong-game/68460/1 "2004-10-26T04:27:04Z")

</div>

I have created a multiplayer version of pong now i want to make a single player version with AI for the 2nd paddle to function.

The computers paddle movieclip is called **paddle2**  
The ball movieclip is called **ball**  
and the stage size is set to **1024\*768px**

How could i make the comuters paddle follow the y position of the ball so it can return the ball?

I also want to do some more advanced code so the ball will be more random when it hits the paddle. Also the computer needs some kind of random function on the y axis so player 1 has the ability to beat the computer.  
**(Maybe when the xspeed of the ball reaches a certain speed the computer starts being more random. DUNNO???)**

If anyone can atleast help me with the code above that would be great. Because I was also interested to know how you can tweak the code above so that the compuer is more difficult to beat, so i can have a difficulty setting.

**If i can atleast get some code to get me started that would be great!!!**  
But it would definetely be more helpful if i can get some idea of how to code the other tasks.

Cheers  
Peter.D
