AI help for simple pong game.
I need a way of accurately having a control function represent the movement of the computer's paddle to where the ball is, but not make it 100% perfect. That's the problem. Since I don't do OOP no OOP help would be appreciated, but help in general would. If you also would, I am having small problems with collision detection as well. Thanks!
-Stephanie.
Hope that gets you started without giving away too much :-) Feel free to ask if you'd like anything in deeper detail.
Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]
Well, the simple approach that Pong usually takes is to have the computer paddle move at a limited speed. Each frame, you compute the placement where the paddle should be (to hit the ball), versus the current position of the paddle. You then take the smaller of the difference or the maximum speed of the paddle, and move the paddle by that amount in that frame.
Hope that gets you started without giving away too much :-) Feel free to ask if you'd like anything in deeper detail.
i dont define/work with frame speed or calculate frame speed. i find it unceessary like i just want the global idea not the whole scoop on how to manage and write my own code. i do it my own way
i dont define/work with frame speed or calculate frame speed. i find it unceessary
Then you're doing it wrong.
like i just want the global idea not the whole scoop on how to manage and write my own code. i do it my own way
[/quote]
Then you will never get help no matter how many questions you ask and how many answers we post.
If you want to "do it your own way" then don't ask questions. If you want to learn something, accept the answers you are given.
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!"
[quote name='SWQUEENIFY' timestamp='1319763369' post='4877736']
i dont define/work with frame speed or calculate frame speed. i find it unceessary
Then you're doing it wrong.
like i just want the global idea not the whole scoop on how to manage and write my own code. i do it my own way
[/quote]
Then you will never get help no matter how many questions you ask and how many answers we post.
If you want to "do it your own way" then don't ask questions. If you want to learn something, accept the answers you are given.
[/quote]
umad? lol. i told ya all i do it my way. if you wanna help, go ahead, but if you cant it aint my fault. i do it my way because i dont conform to others shit. go with it or fuck off you aint helping me anymore than i can help myself. and if my way is wrong then explain why i got 50% of a pong game accomplished without any help?
yeah thats waht i thaut.
think outside the box or think in it. im thinking out of it. good luck passing around your horse shit to people tho.
PS: Since when it a crime to give a broad idea rather than a complete personal concept? theres a diferrence between helping someone learn how to walk themself their own way and telling them how YOU walk yourself. everyone walks diferrently.
tho i knoe you cant respond 2 this questin because your wrong!
[quote name='IADaveMark' timestamp='1319765041' post='4877748']
[quote name='SWQUEENIFY' timestamp='1319763369' post='4877736']
i dont define/work with frame speed or calculate frame speed. i find it unceessary
Then you're doing it wrong.
like i just want the global idea not the whole scoop on how to manage and write my own code. i do it my own way
[/quote]
Then you will never get help no matter how many questions you ask and how many answers we post.
If you want to "do it your own way" then don't ask questions. If you want to learn something, accept the answers you are given.
[/quote]
umad? lol. i told ya all i do it my way. if you wanna help, go ahead, but if you cant it aint my fault. i do it my way because i dont conform to others shit. go with it or fuck off you aint helping me anymore than i can help myself. and if my way is wrong then explain why i got 50% of a pong game accomplished without any help?
yeah thats waht i thaut.
think outside the box or think in it. im thinking out of it. good luck passing around your horse shit to people tho.
PS: Since when it a crime to give a broad idea rather than a complete personal concept? theres a diferrence between helping someone learn how to walk themself their own way and telling them how YOU walk yourself. everyone walks diferrently.
tho i knoe you cant respond 2 this questin because your wrong!
[/quote]
I'm a student and hobbyist developer, so take my technical advice with a grain of salt.
Frames are a generally used convention in games - including indie/homebrew/casual games - because it simplifies the developer's work enormously. Updating 30 times a second (or 60, or whatever) means that you can perform time-dependent calculations (for example, movement and acceleration) and scale it across all frame rates by simply multiplying by the time since the last frame.
For example, if your paddle moves 1 pixel per millisecond, and it's been 30 milliseconds since the last update, it'll move 10 pixels this frame. If you experience a lag spike for whatever reason and the next frame comes 50 milliseconds later, your paddle will move 50 pixels that frame - and the beauty of it is that the player doesn't know about the lag. It all looks like smooth motion (barring some insane quirk, which should not happen for a Pong clone). By the way, frame time works even if you're not using a fixed frame rate and you're just updating as fast as your computer will let you. If anything, frame time is MORE useful in that situation since moving your paddle at a constant rate every update could look odd if one frame takes 10 milliseconds to occur and the next one takes 50 milliseconds - the paddle will move the same distance in each frame, even though the second frame lasted five times as long as the first (bad for the player's experience). This doesn't sound too terrible for a handful of frames - I mean, it's only 40 pixels - but if you have a sustained period of slow frames that lasts a second, it can really ruin an otherwise good gaming experience.
Thinking outside the box is great, but it can be unproductive or even counterproductive when asking for advice because the vast majority of people who create games follow certain conventions because they are proven to be efficient and/or productive. The conventions may not be the absolute best solutions, but they are good solutions, and more importantly, they are well-known solutions. In this case, frame time improves the player's experience of the game when a lag spike occurs.
Oh, and one little thing: please try to type with proper English - that is, spelling and grammar. It shows that you are willing to spend a few moments of your time to make sure your question/reply is easily understood, and hopefully others will reciprocate and spend some of their time to answer your question(s).
pretty funny troll
Yeah... he was so funny that he got suspended within hours of making his account.
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!"
[quote name='Olof Hedman' timestamp='1319809588' post='4877865']
pretty funny troll
Yeah... he was so funny that he got suspended within hours of making his account.
[/quote]
I guess my sarcasm didn't show through enough, judging from the -1 I got. (unless it was from the troll)
I mostly meant to point out the obvious to save time for anyone thinking about replying.
[quote name='IADaveMark' timestamp='1319828702' post='4877953']
[quote name='Olof Hedman' timestamp='1319809588' post='4877865']
pretty funny troll
Yeah... he was so funny that he got suspended within hours of making his account.
[/quote]
I guess my sarcasm didn't show through enough, judging from the -1 I got. (unless it was from the troll)
I mostly meant to point out the obvious to save time for anyone thinking about replying.
[/quote]
Yeah... I was a little startled at the people who replied after things became obvious. Oh well.
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!"