Advertisement

HOW TO MAKE AI PLAYER FOR PONG GAME

Started by April 17, 2020 01:48 AM
7 comments, last by SuperVGA 4 years, 7 months ago

For some months now , i have been searching for how to make an AI pong game, but i don't get a useful or helpful answer, but now i think i have it now, if you think u have a better idea , about how to make a better AI for a pong game. let me know on the comment.

i will share how i made my, i created a variable that keep track of the ball position, so i will know where the ball is then i assign the y axis position of the tracker to the AI , making it this way make the AI move along with the ball but impossible to get a point from the AI . so i created another variable call speed, then i made the speed variable control how fast the AI will be, then i set the speed lower than the ball speed. this create an idea like, the AI knows where the ball is so it will try to get there so sometimes it looses the ball and we will get a point. but even when the AI play's and the ball is moving towers the Player, it will still try's to move to the y axis of the ball position and i didn't like it, so i created a variable that keeps track of the direction of the ball, if is moving tower the player it stop's moving but when the ball is moving towers it' self , we start tracking the position again.

So it will be simple for you to create how difficult the game will be by adjusting the speed variable, the higher the speed is the more intelligent it will becomes and the lower the speed is the easier to win a point.

THIS IS HOW I MADE MY AI PONG GAME (AI VS PLAYER)

if you have a better idea let me know at the comment

Very good!

Giving the AI a flaw in terms of speed seems sort of unfair to me. ?
If both players were to move their paddles with the same speed (and no handicaps irt. actuation), what do you think would make a reasonable implementation?

Perhaps you could also let the AI target the ball's Y-value with some noise applied, to show that it's not always precise at following the ball?
You could even add a delay, or a delay range, simulating reaction time for the AI?

Advertisement

I don't think we are actually following the ball position, we mostly guestimate where the ball will end up at our end, and directly move to that point (hopefully close enough to catch the ball).

The easiest and most believable solution to most things like this is to simply introduce noise in one or more areas. The most basic of this would be to introduce +/- error in the target location we are moving to. As mentioned above, changing the speed of movement, the reaction time before moving, etc. are all fair game as well. After all, what you are doing is simulating the things that not only make me different than you, but even that each action we take is different than the one before. Various difficulty levels can be achieved by widening the range of those random spreads too. Makes it easy to tune as well.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

IADaveMark said:

changing the speed of movement, the reaction time before moving, etc. are all fair game as well. After all, what you are doing is simulating the things that not only make me different than you…

I agree that it's fair game in terms of changing difficulty and to provide some variety. If you want to pretend that the AI has the same mechanical advantages as yourself, I think altering the speed of the AI paddle is unfair. ?

thank guy , thank u for contributing to the chat, i will also apply noise to the AI, if it will only make the game a lot more interesting. thank for your idea.

Advertisement

@SuperVGA Not if you make it both slower and faster. Sometimes we spin the dial too fast to be accurate, sometimes we spin it too slowly to get there in time.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

IADaveMark said:

@SuperVGA Not if you make it both slower and faster. Sometimes we spin the dial too fast to be accurate, sometimes we spin it too slowly to get there in time.

Ahh - classic controls, alright! I misunderstood, I thought of a momementary action where a keystroke caused the paddle to move at a fixed speed. I'm on board again, thanks for the clarification.

This topic is closed to new replies.

Advertisement