Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 157

GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
06/11/14 07:53 PM (10 years ago)

Difficulty with difficulty levels - Pong

Has anyone had any luck changing the difficulty level for the CPU in the Pong plugin? I've been trying just about everything, but nothing seems to do the trick. Any ideas? Thanks, hope everyone is having a good week! Nicholas
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/11/14 09:44 PM (10 years ago)
Hey Nicholas, I haven't had any luck either, but have not yet asked the author. As you know, MrDavid doesn't have any future plans of returning, and I'm pretty sure it was simply an open source port over anyway, so even he might not know, but if you want to ask him, I can send you his contact info, just shoot me a pm. I used the pong plugin as one of my games in my universal studios app (re-skinned accordingly of course), and soon found the same as you, that adjusting the difficulty to anything never allows the AI to miss even a single shot. Nothing in the code jumps out at me to adjust it either. With game plugins like my shark attack game, I always have the adjstable difficulty easily identifiable in code... But I can't seem to find anything like that in pong.
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
06/12/14 06:17 AM (10 years ago)
Hey Dave, I've tried contacting David a couple of times, but no luck. I've tried just about everything "obvious" that should change the CPU difficulty level, but no dice. Hmm... did you end up keeping Pong in your gaming app? It's just a tad bit frustrating getting it to work - can't beat the AI after all... :P Do you think I might get a response on StackOverflow? Thanks, Dave, and if you figure it out before I do, feel free to share! ;) Nicholas
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/12/14 07:59 AM (10 years ago)
This is exactly my point from a few weeks ago. If people make plugins from otehr peoples code and remove any trace of evidence of where the code came from, then when the developer leaves the site it is not possible to support. Even worse when the plugin maker To say this was ported from the pong project is ridiculous. Really a pong game called the pong project. Full references should be made to the repository the code was from. ie git hub which fork.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
06/12/14 08:44 AM (10 years ago)
Ditto Kittsy
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/13/14 07:09 AM (10 years ago)
Just seen your stack overflow post lol you really want this to work http://stackoverflow.com/questions/24187323/setting-cpu-difficulty-for-pong But as I don't have the plugin and you basically put the whole .m in there I bet I have you a fix. Change this CGFloat movement = MIN((int)cpuSkill, ABS(diff)); to this CGFloat movement = MIN(cpuSkill.integerValue, ABS(diff)); Put this at the bottom of the viewDidLoad method to see what numbers where produced check the log NSLog(@"integerValue == %i",cpuSkill.integerValue); // should be 20 or whatever in cpanel NSLog(@"(int) == %i",(int)cpuSkill); // at least 500000 So it appears you have all been playing against the terminator You see type casting isn't just bad for actors in a television series. you will see stuff like this a lot in coding float bigHairyPlumWeight = 2.234; int plumTotheNearestInteger = (int)bigHairyPlumWeight; //will equal 2 in an nslog The other way int bigHairyPlumWeight = 2; int plumTotheNearestInteger = (float)bigHairyPlumWeight; //will equal 2.000000 as a developer we know that both bigHairyPlumWeight and his mate are numbers The second one we have changed an integer to a float so he can have a cheeky decimal point The problem with this plugins code is that it is telling the compiler that the string @"20" is a number, its not its a string. (int) doesn't convert to an integer it just says this is an integer. so it goes OK and counts the string as a num it looks at the number and @"20" raw data equals half a million Explore the wonderful world of the NSString class
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
06/13/14 10:57 AM (10 years ago)
Kittsy, you sir, are a God! Thank you so much! Changing that one line of code made the CPU difficult, but beatable. Thanks again for taking the time to lend a helping hand!!! Nicholas
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/13/14 10:57 AM (10 years ago)
the lower the number the easier it is I found 12 to be a good number
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.