Working on Pong AI

DuendeArkanoDuendeArkano Member Posts: 52
edited November -1 in Working with GS (Mac)
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?

Comments

  • latygo60latygo60 Member Posts: 27
    Hi!

    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!
  • DuendeArkanoDuendeArkano Member Posts: 52
    Thanks Latygo!

    I'll try this at evening, and i'll let you know the results :P
  • old_kipperold_kipper Member Posts: 1,420
    you could also add variables to the constrain so it varied as you wished from a very exact position, or you could add delay to the paddle's movement (again with a variable possibly).

    kipper
  • Asobu_GamesAsobu_Games PRO Posts: 261
    You could try having an attribute (integer) with a random function on it. For example:

    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!
  • DuendeArkanoDuendeArkano Member Posts: 52
    So ******* thank u everyone!! :D

    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 ;) JohnPapiomitis
  • DuendeArkanoDuendeArkano Member Posts: 52
    Hi again guys!!! (or girls, i dunno)

    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 :)
  • latygo60latygo60 Member Posts: 27
    You don't have to use the 'Save attribute' behaviour. That's used to save an attribute that you want to LOAD whenever you want to use it, with 'Load attribute'.

    You have to use instead 'Constrain attribute', constraining the Y coord of the ball to the created Y attribute.
  • DuendeArkanoDuendeArkano Member Posts: 52
    Thank u very much!!!

    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!!!
  • latygo60latygo60 Member Posts: 27
    You're welcome :)

    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 :)
  • DuendeArkanoDuendeArkano Member Posts: 52
    letygo60, thank you veryyyyy much! :) i'll try it now, thanks for your help :D
  • DuendeArkanoDuendeArkano Member Posts: 52
    it worked!

    im still having some tiny problems, but i'll make a new post next week :)

    thanks for all your help! :D
Sign In or Register to comment.