News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Random numbers multiples of 4...

Started by felipe, March 28, 2018, 03:48:07 PM

Previous topic - Next topic

aw27

Quote
perhaps you should dedicate more time to your company.
I also like to dedicate some time to you.  :biggrin:

hutch--

JJ,

Set the seed in this proc first before you call the nrandom proc.

nseed proc TheSeed:DWORD

jj2007

Yep, that's it:
  invoke nseed, rv(GetTickCount)
  @@:
    invoke nrandom, cnt     ; get the random number within "cnt" range


felipe

Hey you guys, thanks for your help. I will check those algos tonight! I also want to say to you PEACE!  :idea:
:greensml:  :icon14:

felipe

Ok, i will use your idea hutch, because is much similar with some ideas than i'm using in the program. Thanks. And thanks to the others too.

I feel somehow good knowing that random numbers is a complex issue (in general in maths). Because this little, simple game that i will post soon, doesn't deserve any big debate.  :redface:  :P

:icon14:

felipe

I'm glad to report that hutch's algo worked fully ok with a little adaptation for my needs:

Quote from: hutch-- on March 28, 2018, 04:42:53 PM
  @@:
    invoke nrandom, cnt     ; get the random number within "cnt" range
    mov ecx, [esi+ebx*4]    ; get the incremental pointer
    mov edx, [edi+eax*4]    ; get the random pointer
    mov [esi+ebx*4], edx    ; write random pointer back to incremental location
    mov [edi+eax*4], ecx    ; write incremental pointer back to random location
    add ebx, 1              ; increment the original pointer
    sub lcnt, 1             ; decrement the loop counter
    jnz @B


align 4
gener_tab:
            push        anicount
            call        nrandom                                       
            mov         ecx,questable[ebx*4]                            ; From last element to first.
            mov         edx,questable[eax*4]                            ; Random element.
            mov         questab[ebx*4],edx                              ; Stores the random elements in this table. Order generated for this session.
            mov         questable[ebx*4],edx                            ; Discards
            mov         questable[eax*4],ecx                            ;   the randoms
            dec         ebx                                             ;      used.
            dec         anicount                                     
            jnz         gener_tab                           


I will post the program with the full source code hopefully this afternoon. Thanks again.  :t