Re: LZ: Random Number making
[Prev][Next][Index][Thread]
Re: LZ: Random Number making
On Mon, 23 Dec 1996 kheikens@owt.com wrote:
[snip]
> Suit: Value : Card: Value:
> Clubs 00 2 00
> Diamonds 01 3 01
> Hearts 02 ... ...
> Spades 03 Jack 09 And so on.
ace -> $#1
2 -> $#2
..
king -> $#D
joker -> $#E /*recycled code compatibility... other games*/
Clubs -> $1#
Diamonds -> $2#
Hearts -> $3#
Spades -> $4#
> Combining these, I'd get:
>
> 4 of Clubs is $0002
4 of clubs is $14
> Jack of Hearts is $0209
Jack of hearts is $3B /* ace=$1, 9=$9, 10=$A, Jack=$B */
> Would this work? Thanks for any help!
Sure, but you're wasting *lots* of space.... a 16 bit number where 6 bits will
do! I mean.... there's 14 possible values of card (4 bits=16) and 4 suits (2
bits=4) so a 6 bit number gives you 64 cards. Jokers are included for
completeness and can be red ($2# or $3#) or black ($1# or $4#) then you still
have 10 cards left to cheat with.... plus, my numbering scheme leaves $00 and
$FF available for wierd stuff to happen... this should cut your mem req'ts and
speed up processing...
--
Chris Kuethe <ckuethe@gpu.srv.ualberta.ca> LPGV Electronics and Controls
http://www.ualberta.ca/~ckuethe/
RSA in 2 lines of PERL lives at http://www.dcs.ex.ac.uk/~aba/rsa/
print pack"C*",split/\D+/,`echo "16iII*o\U@{$/=$z;[(pop,pop,unpack"H*",<>
)]}\EsMsKsN0[lN*1lK[d2%Sa2/d0<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<J]dsJxp"|dc`
References: