Lifelesspeople.com

 Forum FAQsForum FAQs  Knowledge BaseKnowledge Base  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   HostingHosting   RegisterRegister 
 DonateDonate   WikiWiki   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Making Game AI

 
Lifelesspeople.com Forum Index -> Web Architects' Abode
Post new topic   Reply to topic View previous topic :: View next topic  
Author Message
Scott
tutorialtoday.com


Joined: 24 Mar 2005
Posts: 2599
Location: Mississauga, Ontario

PostPosted: Thu Mar 13, 2008 7:53 am    Post subject: Making Game AI Reply with quote

I'm just messing around with OpenGL and making a simple pong game and I am wondering how you would make AI for a game using C++, specifically the other paddle in a pong game.
_________________
Tutorial Management Script - Version 1.3 Released
TutorialToday - Up and running, submit your tutorials!
Linux Tutorials - Coming Soon
Back to top
 
Pie32
Not Banned


Joined: 17 Mar 2005
Posts: 1420
Location: Lost in 84

PostPosted: Thu Mar 13, 2008 9:35 am    Post subject: Reply with quote

AI I think is really tricky business, and even harder to program well. But, something for Pong is actually really simple. Back when I made a simple Pong clone, my AI was simply, "if the center of the ball is above the center of your paddle, move up; else if the center of the ball is below the center of your paddle, move down."

I would start with something like that. If your Pong game is as bad as mine was, that will make an impossible to beat AI. However, if your ball physics are better than constant speed and bounces that don't change the angle of the ball, then you may want to make some tweaks, such as maybe moving the paddle to the center when the ball is going away from it and then trying to keep in level with ball if it moves beyond x pixels of the center.
_________________
[img]http://luneknight.com.ru/counter.jpg[/img]
Random Battle: [img]http://luneknight.com.ru/l.jpg[/img] vs. [img]http://luneknight.com.ru/r.jpg[/img]
Back to top
 
Scott
tutorialtoday.com


Joined: 24 Mar 2005
Posts: 2599
Location: Mississauga, Ontario

PostPosted: Thu Mar 13, 2008 12:00 pm    Post subject: Reply with quote

Well I basically used what you said but made it a bit more beatable. I made the paddle (moves at 0.20f) move slower than the ball (moves at 0.25f).

I also made it so the paddle only moves when the ball is coming towards it.

Also, it only moves if the ball is above 60% of the paddle or below 40% of the paddle. So if it is in the middle 20% of the paddle then it won't move. If that made sense...
_________________
Tutorial Management Script - Version 1.3 Released
TutorialToday - Up and running, submit your tutorials!
Linux Tutorials - Coming Soon
Back to top
 
Pie32
Not Banned


Joined: 17 Mar 2005
Posts: 1420
Location: Lost in 84

PostPosted: Thu Mar 13, 2008 5:05 pm    Post subject: Reply with quote

Yeah, that was what I was trying to get across at the end when I said to only move the paddle if the ball is x pixels away from the center. Silly
_________________
[img]http://luneknight.com.ru/counter.jpg[/img]
Random Battle: [img]http://luneknight.com.ru/l.jpg[/img] vs. [img]http://luneknight.com.ru/r.jpg[/img]
Back to top
 
LP-SolidRaven
Dictator of the Dump


Joined: 06 Jun 2004
Posts: 7036
Location: The cheese is made out of moon

PostPosted: Sat Mar 15, 2008 3:16 am    Post subject: Reply with quote

You should also make the pad move a bit randomly while the ball is at the other side Smile
_________________
Quote:

<bart416> I just realized something
<bart416> we celebrate the fact that this piece of rock made one rotation around a glowing ball of plasma that is kept together due to its own gravity well
<njsg> HAPPY NEW YEAR
<Easter> ^^
Back to top
 
flaran
Master Poster


Joined: 03 Aug 2005
Posts: 178


PostPosted: Sat Apr 19, 2008 11:30 am    Post subject: Reply with quote

It seems that there are two practical limiters for AI at this level.

One is to make certain cases where it is impossible for the AI to win. In this case you can make it so that if the paddle is, say, at the bottom of the screen and you hit it towards the top it is incapable of moving it up fast enough. This way can work but players soon figure out patterns that will beat the AI every time. That makes this method a lot less effective.

There is also the choice of randomizing the effectiveness of the AI. This way, the bot will occasionally make mistakes (ex: hesitating or misjudging the location of the ball). As difficulty progresses, that chance of mistakes can lower.

I've thought about other ways of approaching AI for different games but these are the ones that really apply to pong from my point of view.
Back to top
 
Display posts from previous:   
Post new topic   Reply to topic    Lifelesspeople.com Forum Index -> Web Architects' Abode All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Home | Hosting | News | Forum | Links | System Status | About | Archive | Donate ]
Powered by phpBB © 2001, 2002 phpBB Group
All trademarks and copyrights on this page are owned by their respective owners. Posts and comments are owned by the poster. Everything else © 2001 - 2007 Lifelesspeople.com