Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-17-2011, 05:04 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 1
Bambus42 is on a distinguished road
Default Pong AI - help

Hi im trying to make an basic pong app and i am trying to make 3 different ai's
Right now im struggling with making an AI where the paddle of the computer returns to it's base point = the middle of the x axis.

i have an AI where the computer follows the ball when its on his half of the gaming set and an AI where it follows the ball all the time.

and i just cant figure out how to get it to return to its base point everytime the ball passes to my side of the gaming set.

my code looks like this at the time.

Code:
if(mic.center.y <= self.view.center.y) {
        if(mic.center.x < plosina_b.center.x) {
            CGPoint compLocation = CGPointMake(plosina_b.center.x - ObtiznostPocitace, plosina_b.center.y);
            plosina_b.center = compLocation;
        }
        
        if(mic.center.x > plosina_b.center.x) {
            CGPoint compLocation = CGPointMake(plosina_b.center.x + ObtiznostPocitace, plosina_b.center.y);
            plosina_b.center = compLocation;
        }
    }
this is the ai which follows the ball on his side.

i figured out that i have to make another if with condition set on
Code:
if(mic.center.y >= self.view.center.y) {
please help.
Bambus42 is offline   Reply With Quote
Old 10-18-2011, 12:43 AM   #2 (permalink)
Registered Member
 
Join Date: Jun 2011
Location: Sydney, Australia
Posts: 44
new2objectivec is on a distinguished road
Default

Just my 2c
I guess you want a few different levels of difficulty: beginner, intermediate, expert or something like that.

how about adding some random "noises" (random value? different direction instead?) for the lower levels, so that the computer isn't as smart, or use different/smaller value (when updating the position at each cycle), so that the computer player doesn't response as quickly as the higher levels.

hope this helps
new2objectivec is offline   Reply With Quote
Reply

Bookmarks

Tags
pong ai game development

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 389
10 members and 379 guests
7twenty7, apatsufas, comicool, Creativ, Dalia, dansparrow, Duncan C, Murphy, pbart, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:57 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0