ios - How random is arc4random (mac os x)? (or what am I doing wrong?) -


i'm playing optimized game of life implementation in swift/mac_os_x. first step: randomize big grid of cells (50% alive).

code:

for(var i=0;i<768;i++){   for(var j=0;j<768;j++){     let r = int(arc4random_uniform(100))     let alive = (aliveodds > r)     self.setstate(alive,cell: cell(tup:(i,j)),cells: alivecells)   } } 

i expect relatively uniform randomness. has definite patterns:

large image

zooming in bit on lower left:

zoomed in

(i've changed color black on every 32 row , column, see if patterns lined power of 2).

any clue causing patterns? i've tried:

  • replacing arc4random rand().
  • adding arc4stir() before each arc4random_uniform call
  • shifting display (to ensure pattern in data, not display glitch)

ideas on next steps?

  1. you cannot hit period or many regular non-uniform clusters of arc4random on displayable set (16*(2**31) - 1).

these signs of corrupted/unininitialized memory. example, initializing 768x768 field, showing 1024xsomething field.

  1. try replacing int(arc4random_uniform(100)) 100 see.

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -