[color="#000000"]Hello!
[color="#000000"]I'm new to game development, so new I'm green! I have been reading books and doing tutorials. I have a good understanding of C#. I understand I still have tons to learn, but I feel I'm making progress. Currently I have created a Pong clone for the Windows Phone 7 platform using Visual Studio Express 2010 with XNA 4.0. The issue I'm having if creating a great AI for the computer controlled paddle. Currently I have the paddle reacting to the ball based on the balls Y axis position. This works OK, but I'm not happy. I have looked online for samples of AI for pong and haven't really found a good alternative in C#. I am finding it quite difficult to think of another way to code the AI to get that balance of not too hard but not too easy. I know this is mostly due to my inexperience in programming, this is a simple game and it's frustrating not knowing even were to start with this issue, so I turn to the experts here on this forum! I would appreciate some help with this issue.
Below is my code:
[color="#FF0000"][Ed note: tried to wrap your code in code tags but then the forum barfed all over your formatting with font tags and whatnot. Please repaste your code but put it between tags by using the "<>" symbol above.]
Pong AI
www.marshalarnold.com
[email="marshal@marshalarnold.com"]marshal@marshalarnold.com[/email]
[email="marshal@marshalarnold.com"]marshal@marshalarnold.com[/email]
Your AI seems quite reasonable for pong. I see you have paddle speed there, perhaps add a "reaction time" value too. By altering those values you can change the difficulty of the AI. You could use the balls velocity to predict where to move the paddle. pos = currentPos + v*t, solve to find out the y position when x is at the edge then start moving towards that position.
Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.
See note on original post about code.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
See note on original post about code.
Oops, sorry about that. Thanks for the heads up about code.
www.marshalarnold.com
[email="marshal@marshalarnold.com"]marshal@marshalarnold.com[/email]
[email="marshal@marshalarnold.com"]marshal@marshalarnold.com[/email]
Your AI seems quite reasonable for pong. I see you have paddle speed there, perhaps add a "reaction time" value too. By altering those values you can change the difficulty of the AI. You could use the balls velocity to predict where to move the paddle. pos = currentPos + v*t, solve to find out the y position when x is at the edge then start moving towards that position.
Thank you very much for the info! I will see what I can do.
www.marshalarnold.com
[email="marshal@marshalarnold.com"]marshal@marshalarnold.com[/email]
[email="marshal@marshalarnold.com"]marshal@marshalarnold.com[/email]
you can look at previous topic :My AI Is Invincible [SOLVED]
Cool, thanks for the link I will look it over!
www.marshalarnold.com
[email="marshal@marshalarnold.com"]marshal@marshalarnold.com[/email]
[email="marshal@marshalarnold.com"]marshal@marshalarnold.com[/email]
I have created a simple pong game in java and to make the AI more fun I added a couple of features.
- first, the AI paddle would move only after the ball X position would pass the middle of the screen, and as the score difference increases in favor of the player that X position advances towards the player
-second I have done speed progression which increases as the score progresses.
Also, I have plans to make it in such that the AI paddle can anticipate the final position of the ball by measuring the angles the ball bounces from the last edge (I am still working on this one)
- first, the AI paddle would move only after the ball X position would pass the middle of the screen, and as the score difference increases in favor of the player that X position advances towards the player
-second I have done speed progression which increases as the score progresses.
Also, I have plans to make it in such that the AI paddle can anticipate the final position of the ball by measuring the angles the ball bounces from the last edge (I am still working on this one)
I like jocuri cu masini and jocuri barbie
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement