Working on Pong AI
Hi!
Im very new on this and im getting crazy trying to create my design on gamesalad.
The beginning of the idea its simple, i need to pass the coordinates from the ball to the AI of the paddel controlled by the program.
As "easy" as this:
-get the coordinates from ball
-leave this coordinates into "ballY"
-get the coordinates from "ballY"
-read it from "move to" in order to move to this coordinate
I think "move to" attribute its the correct one for this case but maybe im wrong.
Thanks in advance
P.D: By the way, there's and example on GameSalad "new" tab called "Pong - Classic" who the AI its inbeateable because get the coordinates from the ball, i try to understand where is the function who made this but i couln´t find it. Any idea?
Im very new on this and im getting crazy trying to create my design on gamesalad.
The beginning of the idea its simple, i need to pass the coordinates from the ball to the AI of the paddel controlled by the program.
As "easy" as this:
-get the coordinates from ball
-leave this coordinates into "ballY"
-get the coordinates from "ballY"
-read it from "move to" in order to move to this coordinate
I think "move to" attribute its the correct one for this case but maybe im wrong.
Thanks in advance

P.D: By the way, there's and example on GameSalad "new" tab called "Pong - Classic" who the AI its inbeateable because get the coordinates from the ball, i try to understand where is the function who made this but i couln´t find it. Any idea?
Comments
I think the key on doing what you said and not making the AI unbeatable is related with the speed you let the paddle move and the speed of the ball.
Instead of moving all the time the paddle to the Y position of the ball, I'll just let the paddle get the Y position while the X linear velocity is positive, and maybe, just after passing the half of the field.
Then if the paddle is too far to get to the ball, you'll win.
Hope it helps!
I'll try this at evening, and i'll let you know the results :P
kipper
When the player hits the ball, it would change the 'AI reaction' attribute )or whatever you wish to call it) to a random number from 1 to 5.
Then the AI paddle could have a rule so that if the number was between 1 and 4 it would 'react' and return the ball. If it was 5 however, it would miss the ball. So this would essentially mean approximately 1 in 5 times the AI would randomly 'miss' the ball. You could obviously tweak the numbers to make misses more or less common.
Hope this makes sense!
I'll start to test all the posibilities this evening and i'll tell u guys how it work.
...but at 22'00 i'll stop, today play Barcelona against Madrid!!! :P
Edit: Censored your post above. This is a family friendly forum
Im having a very basic problem with all this stuff
Im not being able to save the coordinates to the attribute i create
im doing this:
Ball:
(apart of the movement and this stuff)
Save Attribute:
Attribute: self.Position.Y Key: game.BallY (BallY its the Attribute i create to save the ball coord)
And im trying to get this info for the AI's Padel with this:
Accelerate Towards:
Position (x arrow): 0 (y arrow): game.BallY Relative to: Actor
Acceleration: 300
At the same time i put a display text with the content of BallY but i never change!! its always 0!
what im a doing wrong??
Thanks in advance and thanks for your pattience
You have to use instead 'Constrain attribute', constraining the Y coord of the ball to the created Y attribute.
now im getting into it, by the way, im still having a tiny issue, how can i know a coordinate on the screen? i want to lock the x axys of AI's paddel because it still moves by it self by the X coordinate, i try with an invisible wall but it creates some graphic bug at the time of the collision with the ball.
Thanks again!!!
The trouble you're having I think is pretty simple to solve. You just have to constrain the X coord of the paddle to a certain X value.
Just like this:
Constrain Attribute: self.PositionX to: 420 (or whatever X you want)
Hope it helps
im still having some tiny problems, but i'll make a new post next week
thanks for all your help!