Wrox Programmer Forums
|
BOOK: Beginning iOS Game Development
This is the forum to discuss the Wrox book Beginning iOS Game Development by Patrick Alessi ; ISBN: 978-1-1181-0732-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS Game Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 25th, 2013, 07:26 PM
Registered User
 
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch. 3 Acey-Deucy game contains error

[edit: I'm an idiot. The shuffle function only shuffles cards 0-51 in the array. Ignore this whole post please!]

So I just finished coding the Acey-Deucy game at the end of Chapter 3. On my first test of the game, I ended up receiving the "sentinel" card as one of my first two cards. Looking back through my code, I realized that in my main do...while loop for the game, I accidentally had it checking the previous 3 cards for the sentinel card instead of the next 3.

Problem solved, right? WRONG.

This highlights a critical error in the way this game works: the sentinel card gets shuffled in with the rest. As I understood from the description, the game should continue until the entire deck is used up, but with the way the sentinel card currently gets shuffled in, the game just ends as soon as the sentinel is in the next 3 cards. I can see how this would be a hard error to catch without having made an error in your code like I did originally, but really guys?

Obviously this can be solved a couple of different ways, one of which would be to modify the initialization of the card deck and a bit of the main code so that the sentinel card gets added after the deck is shuffled.

Last edited by tblank555; February 26th, 2013 at 02:01 AM.. Reason: Realized I was wrong.
 
Old February 25th, 2013, 07:38 PM
Registered User
 
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Suggested Fix

[edit: Again, sorry, I was completely wrong.]

I'm sure there's an easier way to add an element to an array, but this is the only way I could get to work. Also, I'm not sure you can just add an element to an array that's already been defined like this, but it seems to work. Any professional help here would be greatly appreciated.

SUGGESTED FIX:

1. Remove the
Code:
{"sentinel", "null", 0}
object from the end of your initialization of the deck array (in main())

2. after the
Code:
shuffle(deck);
command in your main function, insert the following code:
Code:
// add the sentinel card
deck[52].name = "sentinel";
deck[52].suit = "null";
deck[52].value = 0;

Last edited by tblank555; February 26th, 2013 at 02:02 AM.. Reason: Realized I was wrong.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in Acey-Deucy FlawlessYeh BOOK: Beginning iOS Game Development 1 July 11th, 2012 12:34 AM
Chapter 3: Acey Deucy problem thunderous BOOK: Beginning iOS Game Development 2 May 16th, 2012 11:44 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
CH 9 Error manasa BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 February 23rd, 2007 07:01 PM
ch.4 - I do not get the compilation error dad62896 BOOK: Beginning ASP.NET 1.0 2 February 11th, 2005 04:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.