games.pdbrec.com業務報告20170320 | TheoryOfContraints official blog

games.pdbrec.com業務報告20170320

ブロック積み込み処理とxorshiftを使った乱数処理を作りました

 

-------

package Gos

    import (
        "math/rand"
        "time"
    )
    
    var xorshift int32

 

    func init() {
        rand.Seed(time.Now().UnixNano())
        xorshift = rand.Int31n(2147400000) + 1 // fuzzy at funny.
    }

 

    // Original. http://excamera.com/sphinx/article-xorshift.html
    func RndXorshift() int32 {
        xorshift ^= (xorshift << 13)
        xorshift ^= (xorshift >> 17)
        xorshift ^= (xorshift << 5)
 

        // abs mean 絶対値.
        var i = xorshift
        if (i < 0){ i = -i; }
         
        return i
    }

-------

 

とりあえずは動いている