Exemplo n.º 1
0
        // return per-kerbal variance, in the range [1-variance,1+variance]
        static double Variance(ProtoCrewMember c, double variance)
        {
            // get a value in [0..1] range associated with a kerbal
            double k = (double)Lib.Hash32(c.name.Replace(" Kerman", "")) / (double)UInt32.MaxValue;

            // move in [-1..+1] range
            k = k * 2.0 - 1.0;

            // return kerbal-specific variance in range [1-n .. 1+n]
            return(1.0 + variance * k);
        }
Exemplo n.º 2
0
        // return per-kerbal variance, in the range [1-variance,1+variance]
        static double Variance(String name, ProtoCrewMember c, double variance)
        {
            // get a value in [0..1] range associated with a kerbal
            // we want this to be pseudo-random, so don't just add/multiply the two values, that would be too predictable
            // also add the process name. a kerbal that eats a lot shouldn't necessarily drink a lot, too
            double k = (double)Lib.Hash32(name + c.courage.ToString() + c.stupidity.ToString()) / (double)UInt32.MaxValue;

            // move in [-1..+1] range
            k = k * 2.0 - 1.0;

            // return kerbal-specific variance in range [1-n .. 1+n]
            return(1.0 + variance * k);
        }