[A83] Re: shuffle code help please


[Prev][Next][Index][Thread]

[A83] Re: shuffle code help please



 





this isn't for a calc, but i was wondering if anyone had a really good
randomalgo 

anyone? >From: Djr2cool@aol.com >Reply-To: assembly-83@lists.ticalc.org >To:
assembly-83@lists.ticalc.org >Subject: [A83] shuffle code help please >Date:
Wed, 18 Sep 2002 09:27:33 EDT >>>this isnt the worlds most elegant code but
it works, somewhat. I am trying to >shuffle 52 cards ranging from 0..51. the
method i am trying is takeing 2 >random slots and swapping them, then
repeating the process 255 times. after i >run this code and check it i am
getting repeates in the sequence. >>shuffle: >;new idea take two random
slotsand swap them >ld b,255 >again: >push bc ;save the main loop var >ld
b,52 >call irandom ;get random number 0-51 >ld (slot1),a >ld b,52 >call
irandom ;another random number 0-51 >ld (slot2),a >ld hl,carddeck ;start to
put slot1 into slot2 >ld a,(slot2) >ld b,0 >ld c,a >add hl,bc ;get address
ofdeck+slot number >ld a,(slot1) >ld (hl),a >ld hl,carddeck ;start to put
slot2 into slot1 >ld a,(slot1) >ld b,0 >ld c,a >add hl,bc >ld a,(slot2) >ld
(hl),a >pop bc >djnz again >ret >>carddeck: >.db 0,1,2,3,4,5,6,7,8,9,10 >.db
11,12,13,14,15,16,17,18,19,20 >.db 21,22,23,24,25,26,27,28,29,30 >.db
31,32,33,34,35,36,37,38,39,40 >.db 41,42,43,44,45,46,47,48,49,50 >.db 51
>>slot1: >.db 0 >slot2: >.db 0 

----------------------------------------------------------------------------
Join the world’s largest e-mail service with MSN Hotmail. Click Here[1]


--- Links ---
   1 'http://g.msn.com/1HM1ENUS/c157??PI=44364'



Follow-Ups: