Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Pong game AI (https://forums.graalonline.com/forums/showthread.php?t=66460)

wild8900 06-04-2006 09:06 PM

Pong game AI
 
Ok, so I am making a mini pong arcade game. Currently the ball bounces off walls and players and restarts when it goes behind the player- basic pong concept; but the enemy AI is too simple,
if the ball's y is less than its, it moves down and well, you know.

How would I make the enemy predict and possibly be wrong where the ball will be?

by the way, the ball doesnt use a direction to move, I have numbers being added or subtracted from the x and y of the ball.

excaliber7388 06-04-2006 09:27 PM

I would use a random variable for the accuracy, and make the y possition either more or less than the ball y by that much, per movement. This would allow it to move twoard the ball, but it may be off, or move too slow.

ApothiX 06-04-2006 11:09 PM

best AI: paddle.y = ball.y - (paddle.width/2) !!

wild8900 06-05-2006 02:51 AM

Quote:

Originally Posted by ApothiX
best AI: paddle.y = ball.y - (paddle.width/2) !!

Thats what I have and the AI never loses. I think Ill try the variable accuracy.

ApothiX 06-05-2006 03:44 AM

That would screw up because I wasn't thinking. Should be paddleheight :P
anyways, the best way to do AI for pong is to make the paddle at a constant speed, and have it go up at that speed when the ball is higher, and down when the ball is lower, that way it's still possible to score against the AI, but it's not overly easy :P

Polo 06-09-2006 11:32 PM

I made a pong game for Playstation 2, and for the AI I basically said that if the ball is above the paddle, move up, if its below, move down. I then limited the maximum speed at which the paddle could move, so the way to beat it was to hit things at quite a sharp diagonal (so that it cant keep up with tracking), or into the corner opposite from it (so that it cant get there in time).

It worked ok. You could basically vary the difficulty by varying the maximum AI paddle speed. ^^

Bl0nkt 06-10-2006 04:24 AM

The maximum speed the opponent can move and the increasing speed of the ball are the two best factors.


All times are GMT +2. The time now is 09:11 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.