def seed=(seed)
case seed
when Integer
@state = Array.new(STATE_SIZE)
@state[0] = seed & PAD_32_BITS
(1..LAST_STATE).each do |i|
@state[i] = (1812433253 * (@state[i-1] ^ @state[i-1]>>30) + i)& PAD_32_BITS
end
@last_read = LAST_STATE
when Array
self.seed = 19650218
i=1
j=0
[STATE_SIZE, seed.size].max.times do
@state[i] = (@state[i] ^ (@state[i-1] ^ @state[i-1]>>30) * 1664525) + j + seed[j] & PAD_32_BITS
if (i+=1) >= STATE_SIZE
@state[0] = @state[-1]
i = 1
end
j = 0 if (j+=1) >= seed.size
end
(STATE_SIZE-1).times do
@state[i] = (@state[i] ^ (@state[i-1] ^ @state[i-1]>>30) * 1566083941) - i & PAD_32_BITS
if (i+=1) >= STATE_SIZE
@state[0] = @state[-1]
i = 1
end
end
@state[0] = 0x80000000
else
raise ArgumentError, "Seed must be an Integer or an Array"
end
end