Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Pong AI Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
funnyface43




PostPosted: Mon Apr 08, 2013 6:20 pm   Post subject: Pong AI Help

What is it you are trying to achieve?
I am trying to make the AI harder but not unbeatable.


What is the problem you are having?
I can't make it harder to beat without making ti unbeatable.


Describe what you have tried to solve this problem
I have tried to change some of the numbers but it makes the AI unbeatable.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>



Pong Game.t
 Description:

Download
 Filename:  Pong Game.t
 Filesize:  12.99 KB
 Downloaded:  113 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Nathan4102




PostPosted: Mon Apr 08, 2013 6:31 pm   Post subject: RE:Pong AI Help

You could have the paddle move towards the x of the ball at a rate slightly slower then the ball. That would make it more difficult the closer the speed of the paddle is to the ball.
funnyface43




PostPosted: Mon Apr 08, 2013 6:59 pm   Post subject: RE:Pong AI Help

Yes that is sort of what I have. This is the AI part:

if paddleremotey1 <= bally - 3 then
paddleremotey1 := paddleremotey1 + 5
paddleremotey2 := paddleremotey2 + 5
end if
if paddleremotey2 >= bally + 3 then
paddleremotey1 := paddleremotey1 - 5
paddleremotey2 := paddleremotey2 - 5
end if
Nathan4102




PostPosted: Mon Apr 08, 2013 7:46 pm   Post subject: RE:Pong AI Help

And whats wrong with it? Is it too easy? Too hard?
Insectoid




PostPosted: Mon Apr 08, 2013 9:11 pm   Post subject: RE:Pong AI Help

What you could do is have the AI come up with a plan to reach the ball. In one frame, have the AI calculate where it thinks the ball will be when it reaches its side of the field (this is just two simple calculations that you should be able to figure out). Once you know where the ball will be, you can introduce mistakes. Add random numbers within a specific range to where it thinks the ball will be. Maybe it thinks it will be slightly high, or slightly low, or hit slightly sooner or slightly later. Based on this, generate a plan. If it's going to reach the wall in 20 frames and it will hit 100 pixels higher than the paddle, move the paddle up at 5 pixels per frame. Once it hits the ball (or the ball hits the wall), scrap the plan and wait for the player to hit the ball before starting again.

This will give you a lot of control over the AI's difficulty, simply by changing the range of random numbers. A range of 0 would make the AI perfect- it always knows exactly where the ball will hit the wall. A range of 20 means the paddle could miss by up to 20 pixels.
funnyface43




PostPosted: Tue Apr 09, 2013 7:56 am   Post subject: RE:Pong AI Help

So make the AI think the ball might be somewhere else but also make it so it still hits the paddle. And before, it was too easy to beat.
funnyface43




PostPosted: Tue Apr 09, 2013 8:30 am   Post subject: RE:Pong AI Help

Thanks
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: