File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes How to make Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "How to make "efficient" AI" Watch "How to make "efficient" AI" New topic
Author

How to make "efficient" AI

john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

So I made Pong (by myself). The only part I am stuck on is the AI. I am having trouble between making it unbeatable and too easy. So far it is doing the speed of the ball - 1. That is unbeatable. If you do the speed of the ball - 2, it is too easy. If you do the speed of the ball - 1.25, it is great on fast balls and fails on slow ones (obviously). How do I get this to balance out? Code will be provided on request.
Thanks,
cc11rocks

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 250
    
    1
I didn't know you needed much AI for pong but ...

rather than adjusting the speed of the game could you just adjust where the program wants to stick it's paddle. Assuming it decides where the paddle should be the moment you hit the ball then just adjust this position by a random amount depending on the level - on easy make it a large random amount and on hard don't vary it at all. You could increase the speed by a small fraction at the same time just to make it more "exciting" as well.

Mike


Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make "efficient" AI