Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1026114 Posts in 41125 Topics- by 32721 Members - Latest Member: bloodmoney0006

July 23, 2014, 08:12:32 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Pong - AI considerations
Pages: [1]
Print
Author Topic: Pong - AI considerations  (Read 513 times)
eyeliner
Level 10
*****


I'm afraid of americans...


View Profile WWW Email
« on: November 09, 2012, 07:56:42 AM »

Hi guys.

Having my head filled with stupid and because of that no completing anything, I decided to follow the advice I give to others and haul ass and do something.

I kind of made Pong. Looks like this:


Whatever. It's not the graphics I need advice about. I already know I can't draw/paint worth a damn.

My thing works ok with a couple people, sharing the keyboard. I'd like to make the AI reactive, but I have tried it once, and managed to make the AI follow the balls' position at all times, with a speed that made it impossible to loose either way, because the player had the same speed, bouncing back was not an issue for any side.

I'd like to articulate a nice system that would make the computer's paddle behave like something remotely intelligent, not a drone that follows the ball.

Would any of you guys have any input about this?

Here's my current build for two players, hardly challenging, but that's not the real point:
Instructions:
P1: Keys A and Z
P2: Keys Up and Down
Launch ball: E
Quit. Escape
https://dl.dropbox.com/u/60029808/ponged.exe
Logged

Yeah.
st33d
Guest
« Reply #1 on: November 09, 2012, 08:12:21 AM »

Shuffle Puck Cafe had some interesting AI back in the day.

Each player had it's own style. Including a kid that just rattled the bat left and right in the hope that they would hit something (which is of course a rookie technique that gets you some way but fails in the end). If you have perfect AI, then all you need to do is introduce eccentricities based on weak player tactics.

The enemy AI should move to anticipate the ball and attempt to do "slices" - difficult moves to catch. Once the ball is hit the point where the ball crosses the bat line is a constant - it cannot change until the bat interferes. Thus you can draw to the screen the predicted path of the ball and create predictive AI.

If the bat speed can always keep up with the ball then your game is broken, logically speaking, two perfect players would always reach a stalemate.
Logged
eyeliner
Level 10
*****


I'm afraid of americans...


View Profile WWW Email
« Reply #2 on: November 09, 2012, 08:26:26 AM »

Fortunately, the paddle cannot keep up with the ball at all times, and you have to predict the rebounds on occasion.

I did not insert "slices" (i.e. making the ball rebound differently regarding the paddle movement) because I wanted to make the movement logic solid for now. I see your point on predicting the ball's way. I'll try to implement that soon.
Logged

Yeah.
st33d
Guest
« Reply #3 on: November 09, 2012, 03:19:51 PM »

Once the ball is hit the point where the ball crosses the bat line is a constant - it cannot change until the bat interferes.

Jesus, I've become Gimmy.
Logged
nikki
Level 10
*****


View Profile Email
« Reply #4 on: November 09, 2012, 04:25:36 PM »

yeah, something like angle of input = angle of output.
billiard ball physics etcera.
and the classic; calculate what the duration will be of some travel at a certain speed.


highschool math ftw

goodluck!

EDIT:
Quote
angle of input = angle of output
should be
angle of incidence and angle of refraction
(I didn't learn this in english, had to look it up)
« Last Edit: November 09, 2012, 04:30:43 PM by nikki » Logged
Archibald
Level 4
****


View Profile WWW Email
« Reply #5 on: November 10, 2012, 02:34:40 AM »

BTW, how they did the original Pong? I mean, the hardware was so extremely primitive back then that the "AI" must have been totally absolutelly simple. Still it worked...
Logged

Europe1300 - Realistic Historical Medieval Sim
st33d
Guest
« Reply #6 on: November 10, 2012, 03:54:15 AM »

constant speed and hard coded angles of reflection - it's pretty easy to plot the entire path of the ball from when it hits the bat, you could simply iterate it ahead of time if you were feeling really lazy
Logged
eyeliner
Level 10
*****


I'm afraid of americans...


View Profile WWW Email
« Reply #7 on: November 12, 2012, 01:17:11 AM »

BTW, how they did the original Pong? I mean, the hardware was so extremely primitive back then that the "AI" must have been totally absolutelly simple. Still it worked...
I believe it was 2 player.
Logged

Yeah.
Archibald
Level 4
****


View Profile WWW Email
« Reply #8 on: November 12, 2012, 02:39:39 AM »

BTW, how they did the original Pong? I mean, the hardware was so extremely primitive back then that the "AI" must have been totally absolutelly simple. Still it worked...
I believe it was 2 player.
Right, that woudl exlain it...


I think the AI should have a speed cap, which means AI can predict the ball movement perfectly, but can't move as fast as the player.
Logged

Europe1300 - Realistic Historical Medieval Sim
randomnine
Level 1
*


View Profile WWW
« Reply #9 on: November 12, 2012, 03:05:23 AM »

Better - give the AI a reaction time, so it takes a fraction of a second to 'calculate' where the ball's going before it responds. Same effect as slowing the AI down but more naturalistic and intuitively becomes more significant as the ball speeds up.
Logged

st33d
Guest
« Reply #10 on: November 12, 2012, 05:58:27 AM »

I'd have to agree. If the computer bat moves slower then the player will figure out a pattern that always beats the computer.

Having a perfect computer opponent isn't a problem - it's what you need. If the computer cannot play perfectly then the player will figure out a cheap trick to win every time - making the game boring. You start with a perfect AI, then cripple it in various ways that encourage a variety of gameplay.
Logged
eyeliner
Level 10
*****


I'm afraid of americans...


View Profile WWW Email
« Reply #11 on: November 12, 2012, 09:50:10 AM »

I agree with that, actually. Seems an obvious choice. Maybe also make the computer, at random, for a tiny fraction of time, move the paddle the other way and then correcting the trajectory?
Logged

Yeah.
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic