Example #1
0
        private static decimal RandomizePrices_Percent(Random rand, RandomBellArgs bell)
        {
            const double MAXVALUE = 4;      // output goes form 1/MAX to MAX

            double retVal = rand.NextBellPercent(bell, MAXVALUE);

            return(Convert.ToDecimal(retVal));
        }
Example #2
0
        private void RandomizePrices()
        {
            Random rand = StaticRandom.GetRandomForThread();

            RandomBellArgs bell = new RandomBellArgs(1, -45, 1, -45);

            _partPriceAdjustments = BotConstructor.AllPartTypes.Value.
                                    Select(o => Tuple.Create(o, RandomizePrices_Percent(rand, bell))).
                                    ToArray();

            _mineralPriceAdjustments = UtilityCore.GetEnums <MineralType>().
                                       Select(o => Tuple.Create(o, RandomizePrices_Percent(rand, bell))).
                                       ToArray();
        }
Example #3
0
        private void DrawBellArms()
        {
            #region OLD
            //var controlPoints = new List<Tuple<Point, Point>>();

            //// Arm1
            //if (!trkBellArmsLeftLen.Value.IsNearZero())
            //{
            //    Vector arm1 = new Vector(1, 1).ToUnit() * trkBellArmsLeftLen.Value;

            //    arm1 = arm1.
            //        ToVector3D().
            //        GetRotatedVector(new Vector3D(0, 0, -1), trkBellArmsLeftAngle.Value).
            //        ToVector2D();

            //    controlPoints.Add(Tuple.Create(new Point(0, 0), arm1.ToPoint()));
            //}

            //// Arm2
            //if (!trkBellArmsRightLen.Value.IsNearZero())
            //{
            //    Vector arm2 = new Vector(-1, -1).ToUnit() * trkBellArmsRightLen.Value;

            //    arm2 = arm2.
            //        ToVector3D().
            //        GetRotatedVector(new Vector3D(0, 0, -1), trkBellArmsRightAngle.Value).
            //        ToVector2D();

            //    Point point = new Point(1, 1);
            //    controlPoints.Add(Tuple.Create(point, point + arm2));
            //}

            //// Bezier
            //Point3D[] controlPoints3D = controlPoints.
            //    Select(o => o.Item2.ToPoint3D()).
            //    ToArray();

            //BezierSegment3D bezier = new BezierSegment3D(0, 1, controlPoints3D, new[] { new Point3D(0, 0, 0), new Point3D(1, 1, 0) });
            #endregion

            RandomBellArgs bezier = new RandomBellArgs(trkBellArmsLeftLen.Value, trkBellArmsLeftAngle.Value, trkBellArmsRightLen.Value, trkBellArmsRightAngle.Value);

            // Points
            Random rand = StaticRandom.GetRandomForThread();

            IEnumerable <double> samples = Enumerable.Range(0, 75000).
                                           //Select(o => BezierUtil.GetPoint(rand.NextDouble(), bezier).Y);
                                           Select(o => rand.NextBell(bezier));

            IEnumerable <Point> idealLine = BezierUtil.GetPoints(100, bezier.Bezier).
                                            Select(o => o.ToPoint2D());

            // Draw
            DrawGraph(samples, idealLine);

            Rect bounds = GetBounds();

            if (!trkBellArmsLeftLen.Value.IsNearZero())
            {
                Point from = GetScaledPoint(bezier.Bezier.EndPoint0, bounds);
                Point to   = GetScaledPoint(bezier.Bezier.ControlPoints[0], bounds);
                AddLine(from, to, _brushLightBlue);
            }

            if (!trkBellArmsRightLen.Value.IsNearZero())
            {
                Point from = GetScaledPoint(bezier.Bezier.EndPoint1, bounds);
                Point to   = GetScaledPoint(bezier.Bezier.ControlPoints[bezier.Bezier.ControlPoints.Length - 1], bounds);
                AddLine(from, to, _brushLightBlue);
            }

            // Report coords
            lblBellValues.Text     = GetBellArmValues();
            lblBellCtrlPoints.Text = GetBellPoints(bezier.Bezier.ControlPoints.Select(o => o.ToPoint2D()));
        }