All pastes #175717 Raw Edit

PRNGs

public cpp v1 · immutable
·published 2006-09-19 02:14 UTC
rendered paste body
[03:04:23] <stew> dhw[03:04:33] <stew> MersenneTwister isn't implemented yet[03:04:38] <stew> but I used like[03:04:44] <stew> part of what makes MersenneTwister so good[03:04:55] <stew> the excellent random distribution of bits[03:05:07] <dhw> did you make your own rng or implement one?[03:05:08] <stew> want a quick benchmark? :)[03:05:12] <dhw> sure[03:05:23] <stew>     void RandEngine::NextState()[03:05:23] <stew>     {[03:05:23] <stew>         m_currentState *= 1103515245;[03:05:23] <stew>         m_currentState += 12345;[03:05:23] <stew>     }[03:05:29] <stew> That's the simple rand() style thing[03:05:35] <stew> I'm not sure which compiler uses that[03:05:55] <stew> but 39,063kb -> 10,602kb (ish)[03:05:56] <dhw> hm[03:06:04] <stew> about 27% size[03:06:10] <stew> now, with the following:[03:06:17] <stew>     void MersenneTwisterEngine::NextState()[03:06:17] <stew>     {[03:06:17] <stew>         m_currentState ^= m_currentState << 11;[03:06:17] <stew>         m_currentState ^= m_currentState >> 7;[03:06:17] <stew>         m_currentState ^= m_currentState >> 15;[03:06:17] <stew>         m_currentState ^= m_currentState << 18;[03:06:17] <stew>     }[03:06:37] <stew> 39,063kb -> 39,063kb with winrar standard compression lol[03:07:07] <stew> It couldn't pack it by a single byte ;p[03:07:20] <stew> or if it could, the overhead of the lookup table evidently outweighed compressing lol[03:07:45] <stew> Now to attempt higher compression :) sec