Hi,
Ah...the nightmarish array! That, and loops, have  been the things that just
allude me when I read about how to program in this or that language.

Best Regards,
Hayden


-----Original Message-----
From: gamers-boun...@audyssey.org [mailto:gamers-boun...@audyssey.org] On
Behalf Of Thomas Ward
Sent: Friday, November 26, 2010 10:49 AM
To: Gamers Discussion list
Subject: Re: [Audyssey] USA Blackjack 1.0 Released!

Hi Jim,

You wouldn't necessarily have to write 52 if statements to check if a
certain card has been picked before. You can just create an array of
type boolean, and loop through the array to see if a certain card has
been picked before. For example, it might look like this.

picked = True

while picked == True:

    card = random.randrange(0, 51)

    #If this card has been picked before
    #continue looping until we get a new card
    if drawn[card] == True:
        picked = True
    #End if

    #If the card hasn't been picked before
    #select it and exit the loop
    if drawn[card] == False:
        drawn[card] = True
        picked = False
    #End if
#End while

As you can see there are ways of avoiding writing 52 if statements if
you make maximum use of arrays and loops. There are usually ways to
simplify a task if you give it some thought.

Smile.


On 11/26/10, Jim Kitchen <j...@kitchensinc.net> wrote:
> Hi Hayden,
>
> If you have a shuffled deck of cards, you just deal off of the deck and
thus
> do not need to have fifty some if statements to see if you have picked
that
> card before.  And it would be even more checks if you were playing with 2,
> 3, 4, 5 or 6 decks of cards, right?  It is very easy to shuffle the deck
and
> it just makes better programming sense to me.  I set up a true 52 card
deck
> of cards in an array, pick a number, reduce down the array and pick again
> until you have picked the full deck away.  It has always worked out great
in
> all of my card games.
>
> BFN
>
>      Jim
>
> Experience is something you don't get until just after you need it.
>
> j...@kitchensinc.net
> http://www.kitchensinc.net
> (440) 286-6920
> Chardon Ohio USA

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to
gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to