Advertisement

pong A.I.

Started by August 26, 2006 02:40 PM
5 comments, last by Ultimate_Fusion 18 years, 3 months ago
what AI is used in pong? I have done some more complex games but I am getting into A.I so I am starting from scrath. I remember enemy pong bat shaking alot like he had, had ten pints but always returned the ball. and how to implement the differnt levels of A.I difficulty. easy/hard opponent. any help would be gratefull. thanks for looking
hi!

the simplest AI would be something like that:

The AI looks where the ball is and where his paddle is. If the ball is right from the padle you have to move right, if its left you gotta move left. Because the paddle can only move with a special speed that would look like human.
To make different diffculties try implementing something like reaction time, e.g. the computer needs 1second to react, when the player has played the ball.
Advertisement
Indeed, adequate AI just tries to stay in line with the ball at all times. If the paddle moves faster than the ball, this will usually result in the shaking paddle effect you describe.

A better AI (in fact probably the best AI) would extrapolate the position of the ball:

After the AI has struck the ball, it should return to the centre position (so it can reach any undetermined point in the shortest time). Once the player has made the return shot, a simple piecewise-linear mapping will allow the AI to anticipate exactly where the ball will cross its own line, and should simply set a target there.

Regards
Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
I have done the paddle AI but the paddle just syas at the say y axes as the ball. no shaking, am I updating to slow?
Quote: Original post by Ultimate_Fusion
I have done the paddle AI but the paddle just syas at the say y axes as the ball.


Can you not calculate where the ball will interesect the computer's goal-line? This will allow the computer to predict where the ball is going to go, and allow it to get there earlier, making it look more intelligent. Just tracking the ball's y-axis doesn't look so interesting.

If you want the paddle to shake around -- to make it look like he's going to miss the ball and then actually get it -- all you need to do is to work out not only the place of the intersection but also the time. Then you can create any path you want (e.g. overshooting the point and then going back) so long as you end up at the right place at the right time.

I assume that the paddles and the ball can go at different velocities along the y-axis? The paddle should be able to go faster.
'Shaking' paddle (really this is an occilation problem) can be solved by using a PD-Controller, that takes into account the relative velocity error in addition to the relative position between ball and paddle...
Advertisement
the paddle can go as fast as you can move the mouse. but it doesn't change the velocity of the ball.

This topic is closed to new replies.

Advertisement