How to make an A.I. computer player in a ping-pong game?

CabacoCabaco Member Posts: 414
edited November -1 in Working with GS (Mac)
I am making a ping-pong game in 2D just like the Pong for Atari and I would like to know how to make the other player play against me

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I would track the balls position and work out something that changes the paddles velocity to move toward the ball based on the difference in the y positions or something.

    Get creative and test different ways. Thats half the fun of making Games.

    ___________________________________________________________________________________
    TEMPLATES AND PROJECT HELP BY TENRDRMER. CLICK HERE!!!

    AppSolute Entertainment on Facebook
    AppSolute Entertainment on iTunes
  • old_kipperold_kipper Member Posts: 1,420
    This a question of how smart you want to make the AI. A simple rule to match the Y position of the ball in player b would probably be too tough to beat unless there was some lag in it or you limited the speed of the paddle. And if you want to it to be progressively hard to beat based on the ability of the play, you have to add a "shandy factor' . This is a the amount of slack in your rules that are adjusted to get tighter as the player gets better and makes it tougher for the player.

    You could perhaps up the speed of reaction of the paddle with each volley, or point won by player A, but if you tighten it too much you can make the game unbeatable and that is no fun. So you will have to test it and see how it works and adjust it accordingly.

    I hope that helps. I don't have time to work it out at the moment but I am sure there are others on here who have put something like this into practice and could advise you. Just bear in mind that to keep things as simple as possible if you have not had experience of this type of thing, and build up the rules slowly and with the ability to modify them easily.

    kipper
  • CabacoCabaco Member Posts: 414
    Thank you guys but I am not very good on doing these type of complex things... Anyone care to do a template?
  • old_kipperold_kipper Member Posts: 1,420
    There are a lot of pong templates already and at least 2 with some AI. Try to understand how they work and modify them.

    kipper

    p.s. search in the GS 'New' browser when you open up the editor.
Sign In or Register to comment.