Re: Help With My Game of Black Jack

new topic     » goto parent     » topic index » view thread      » older message » newer message

>David Roach wrote:
>
>> For instance pulling random cards
>> (I am only using cards 2-9 and jack,
>> queen, king, and an ace , four of each
>> of course, just to keep it simple), making
>> it where the computer will not [use] any one
>> card more than one time.
>
>
Lets try this once more from a mathematicians viewpoint:

sequence cards,shuffled,newdeck
atom card
card = 1
cards = repeat(0,52)
shuffled = cards
newdeck = cards

for c = 1 to 52 do
cards[c] = c
end for

newdeck = cards  -- now we have a permanent new deck

for c = 52 to 1 by -1 do        -- shuffle the cards
card = rand(c)                                                     -- select a
card
shuffled[c] = cards[card]                                      -- put it face
down
cards = cards[1..(card - 1)] & cards[(card + 1)..c]  -- put deck back together
end for                                                               -- do it
again

print(1, shuffled)          -- write out the shuffled deck from the first card
to
                                 -- the last

This can easily be made into a procedure and cards can be refreshed from
shuffled and "shuffled" again or cards can be refreshed from newdeck and
a completely different random sequence generated. The difference between
this and a true shuffle algorithm is that the deck must be completely
shuffled before it is valid. At any point other than the exit from the loop,
shuffled is not valid.

Obviously, you might want to put into cards a sequence of an entirely
different nature. It should still work.

Everett L.(Rett) Williams
rett at gvtc.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu