Ejemplo n.º 1
0
        public override void Initialize(Random random)
        {
            base.Initialize(random);
            _line.Randomize(random);

            do
            {
                var part1 = Line.B * _line.A;
                part1--;
                if (part1 == 0)
                {
                    continue;
                }

                var multipliers = MathHelper.GetSimpleMultipliers(part1);
                multipliers.Add(1);
                var first = new List <int> {
                    1
                };
                var second = new List <int> {
                    1
                };

                while (multipliers.Any())
                {
                    var item = multipliers[0];
                    multipliers.RemoveAt(0);
                    if (random.FlipCoin())
                    {
                        first.Add(item);
                    }
                    else
                    {
                        second.Add(item);
                    }
                }

                Line.A  = first.Aggregate((r, c) => r * c);
                _line.B = second.Aggregate((r, c) => r * c);
            } while (Line.IsParallelTo(_line));

            Line.Normalize();
            _line.Normalize();
        }
Ejemplo n.º 2
0
 public virtual void Initialize(Random random)
 {
     Line.Randomize(random);
 }