Пример #1
0
        public void checkSenses()
        {
            leftEyeSense [0]  = 0.0;
            leftEyeSense [1]  = 0.0;
            leftEyeSense [2]  = 0.0;
            rightEyeSense [0] = 0.0;
            rightEyeSense [1] = 0.0;
            rightEyeSense [2] = 0.0;
            pressure          = 0;

            double leftAngle  = DudeMath.wrapPi(spacials.angle - eyeAngle);
            double rightAngle = DudeMath.wrapPi(spacials.angle + eyeAngle);

            foreach (var thingy in Thing.things)
            {
                if (thingy.id == this.id)
                {
                    continue;
                }

                double angleBetweenDudes = Math.Atan2(spacials.pos.X - thingy.spacials.pos.X, spacials.pos.Y - thingy.spacials.pos.Y);

                double dist = (spacials.pos - thingy.spacials.pos).Length;
                pressure += dist * thingy.spacials.mass;               //See tanh later, just taking advantage of this expensive number

                double leftEyeDifference  = DudeMath.aDiff(leftAngle, angleBetweenDudes);
                double rightEyeDifference = DudeMath.aDiff(rightAngle, angleBetweenDudes);

                if ((leftEyeDifference > -focus / 2) && (leftEyeDifference < focus / 2))
                {
                    leftEyeSense[0] += 16 * (thingy.red / dist);
                    leftEyeSense[1] += 16 * (thingy.green / dist);
                    leftEyeSense[2] += 16 * (thingy.blue / dist);
                }
                if ((rightEyeDifference > -focus / 2) && (rightEyeDifference < focus / 2))
                {
                    rightEyeSense[0] += 16 * (thingy.red / dist);
                    rightEyeSense[1] += 16 * (thingy.green / dist);
                    rightEyeSense[2] += 16 * (thingy.blue / dist);
                }

                leftEyeSense[0]  = Math.Tanh(leftEyeSense[0]);
                leftEyeSense[1]  = Math.Tanh(leftEyeSense[1]);
                leftEyeSense[2]  = Math.Tanh(leftEyeSense[2]);
                rightEyeSense[0] = Math.Tanh(rightEyeSense[0]);
                rightEyeSense[1] = Math.Tanh(rightEyeSense[1]);
                rightEyeSense[2] = Math.Tanh(rightEyeSense[2]);

//				leftEyePos.X = pd.x + Math.Sin (leftAngle) * 4;
//				leftEyePos.Y = pd.y + Math.Cos (leftAngle) * 4;
//				rightEyePos.X = pd.x + Math.Sin (leftAngle) * 4;
//				rightEyePos.Y = pd.y + Math.Cos (leftAngle) * 4;
            }

            pressure = Math.Tanh(pressure);             //Squish it down
        }
Пример #2
0
        public void doThrusters()
        {
            thrusters[0, 0] = DudeMath.wrapPi(thrusters[0, 0] + (outs[(int)nnOutputs.thrusterA0] * 0.1));
            thrusters[1, 0] = DudeMath.wrapPi(thrusters[1, 0] + (outs[(int)nnOutputs.thrusterA1] * 0.1));
            thrusters[2, 0] = DudeMath.wrapPi(thrusters[2, 0] + (outs[(int)nnOutputs.thrusterA2] * 0.1));
            thrusters[3, 0] = DudeMath.wrapPi(thrusters[3, 0] + (outs[(int)nnOutputs.thrusterA3] * 0.1));


            thrusters[0, 1] = DudeMath.map(outs [(int)nnOutputs.thrusterT0], -1, 1, 0, 1);
            thrusters[1, 1] = DudeMath.map(outs [(int)nnOutputs.thrusterT1], -1, 1, 0, 1);
            thrusters[2, 1] = DudeMath.map(outs [(int)nnOutputs.thrusterT2], -1, 1, 0, 1);
            thrusters[3, 1] = DudeMath.map(outs [(int)nnOutputs.thrusterT3], -1, 1, 0, 1);


            for (int i = 0; i < 4; i++)
            {
                //double angle = DudeMath.wrapPi (spacials.angle + thrusters [i,0]);

                //spacials.pos.X += Math.Sin (angle) * thrusters[i,1] * 1;
                //spacials.pos.Y += Math.Cos (angle) * thrusters[i,1] * 1;
            }
        }