Re: Help With My Game of Black Jack

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

David,

Just a couple of minor points.
Firstly, you did not properly initialize your deck.
Secondly, in your shuffle, you call rand() twice per iteration. One is
enough, it is an expensive operation.

This is roughly what I have been using for the last 30 years:

-- WARNING! TESTED CODE!

sequence pack

-- initialize pack
pack = {}
for i=1 to 52 do
    pack &= i
end for

procedure shuffle()
    integer dummy, r
    for i = 1 to 52 do
        r = rand(52)
        dummy = pack[r]
        pack[r] = pack[i]
        pack[i] = dummy
    end for
end procedure


Btw, for very obscure theoretical reasons, this is *not* the best
possible shuffle, but it is still far better than what you can get by
hand.

jiri

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

Search



Quick Links

User menu

Not signed in.

Misc Menu