Evolution/Evolution/Utils/XorShiftRandomSource.cs
/// <summary>
/// Generates a single random bit.
/// This method's performance is improved by generating 32 bits in one operation and storing them
/// ready for future calls.
/// </summary>
Generates a single random bit.
This method's performance is improved by generating 32 bits in one operation and storing them
ready for future calls.
Generates a single random bit . This method ' s performance is improved by generating 32 bits in one operation and storing them ready for future calls .
public bool NextBool()
        {
            if (0 == _bitMask)
            {
                uint t = _x ^ (_x << 11);
                _x = _y; _y = _z; _z = _w;
                _bitBuffer = _w = (_w ^ (_w >> 19)) ^ (t ^ (t >> 8));
                _bitMask = 0x80000000;
                return (_bitBuffer & _bitMask) == 0;
            }
            return (_bitBuffer & (_bitMask >>= 1)) == 0;
        }
public bool NextBool ( ) { if ( 0 == _bitMask ) { uint t = _x ^ ( _x << 11 ) ; _x = _y ; _y = _z ; _z = _w ; _bitBuffer = _w = ( _w ^ ( _w >> 19 ) ) ^ ( t ^ ( t >> 8 ) ) ; _bitMask = 0x80000000 ; return ( _bitBuffer & _bitMask ) == 0 ; } return ( _bitBuffer & ( _bitMask >>= 1 ) ) == 0 ; }
Generates a single random bit.
Generates a single random bit .
// Generate 32 more bits. // Reset the bitMask that tells us which bit to read next.