Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Pong A.I.?

Author
Message
OneShot
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location:
Posted: 20th Jan 2007 05:05
How would I go about creating a good computer opponent to play with...I have a few ideas but I don\'t think they would work.

Just started! Help!!!!
Dexter_
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location:
Posted: 20th Jan 2007 05:43
honestly, im a noob at AI too, i really have no idea...check Ruccuss's post out tho here:

http://forum.thegamecreators.com/?m=forum_view&t=92746&b=6

gl! =D

<img src='http://www.geocities.com/doodledexterbob/MasterofMedit.jpg' border='0' alt='user posted image'>
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 20th Jan 2007 06:12
Ruccuss's ai is more complex than you need for pong. All you really need is something like:



Where bally is the variable of the y position of the ball and paddley is the yposition of the middle of the paddle being controlled by ai.

OneShot
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location:
Posted: 21st Jan 2007 05:16
Haha...well i've seen some A.I. used on Pong and it's so pathetic that you get bored after about 5 minutes of it. I don't see how 4 lines of code would code an A.I. for pong without making it unbeatable or completely stupid.

Just started! Help!!!!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Jan 2007 22:43
To be honest there's not a lot you really can do AI-wise with such a simple game like pong.

There's only one rule as far as the coputer controlled paddle is concerned - always move the NPC paddle on the Y axis towards the ball's Y position.

Because the computer can do this instantly, the only real control you have is the speed at which this happens. Limiting the speed is more of a 'difficulty level' thing rather than AI though.

As you suggest, not getting the settings right can result in an un-beatable computer opponent. To do this, I think the balance has to be struck in the playability area - not AI.

The key to this is ball speed, paddle speed and ball angle.

As the game progresses, the rate of movement for the ball and both paddles increases gradually, but there also needs to be a method of altering the ball angle and speed according to the speed of the paddle when the ball is struck.

This is the only real way to ensure that it's possible to get the ball moving faster along the Y axis than the computer can reach at it's maximum speed.

This would at least ensure that you don't get an unwinnable game.

Finally, this has told me that I need to update my tutorial to cover this aspect, so thanks for that!

TDK_Man

Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 21st Jan 2007 23:05
Well, if you think you are up to it there is something more complicated that you could do with pong ai. The computer could recognize where the ball is going to be after it has bounced off the walls and then move the paddle there instead of just moving the paddle to the current ball y position. This would be quite a lot more difficult to program, but would result in a much more challenging computer to beat without having to make the computer move the paddle faster.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Jan 2007 23:31
Daemon:

Nice idea, but using that method, you couldn't avoid it being unbeatable.

TDK_Man

Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 22nd Jan 2007 00:30
Sure you could, just make the computer's paddle very slow or make it purposefully miss by a slight amount occasionally. Due to the Eliza effect the player will probably assume that missing the ball was a bad move by the computer, not a perfectly calculated miss.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Jan 2007 01:16
Quote: "The computer could recognize where the ball is going to be after it has bounced off the walls and then move the paddle there"


That's what I was responding to - maybe you didn't mean it to be read the way I read it.

TDK_Man

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 22nd Jan 2007 02:52
I havent read through the responses yet but:

- Using the curvevalue command, make the pong paddle slowly speed up as it moves to the ball's y position.

OneShot
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location:
Posted: 23rd Jan 2007 07:36
Fantastic ideas, unfortunately most of them are too complex for me to code. My friend in game desiging said I should start working on pack-man now...but I don't think it would be such a good idea cause I can't build a good version of pong.

Just started! Help!!!!

Login to post a reply

Server time is: 2024-11-26 03:45:27
Your offset time is: 2024-11-26 03:45:27