示例#1
0
        public MainForm()
        {
            InitializeComponent();

            this._Camera = new Camera();
            this._Domain = new Domain(x => (x % 2 == 0) ? (x / 2) : (x * 3 + 1));
            this._World = new World(this._Domain);

            for (uint t = 1; t < 9500; t++)
            {
                Entry x = this._Domain[t];
            }
            this._World.Insert(this._Domain[1], Vector.Zero, Vector.Zero);
        }
示例#2
0
            /// <summary>
            /// Updates this leader state by the given amount of time. Returns true if a new stone was introduced.
            /// </summary>
            public bool Update(World World, Stone Stone, double Time, double Expansion, out Stone Introduced)
            {
                Vector dir;
                if (World._Pressure(Stone, out dir) < this.PressureThreshold)
                {
                    if (World.ContainsEntry(this.Next))
                    {
                        this.Next = GetNext(World, Stone);
                        if (this.Next == null)
                        {
                            Introduced = null;
                            return true;
                        }
                    }

                    Introduced = new Stone(this.Next);
                    Introduced.Position = Stone.Position;
                    double dirlen = dir.Length;
                    if (dirlen > 0.001)
                    {
                        dir = dir.Normal;
                        Introduced.Velocity = Stone.Velocity + dir * Settings.Current.StoneIntroductionSpeed;
                        Introduced.Position += dir * Stone.Radius;
                    }
                    _Tweak(this.Next, ref Introduced.Position);
                    return true;
                }
                else
                {
                    this.PressureThreshold *= Expansion;
                    this.Timeout -= Time;
                    Introduced = null;
                    return false;
                }
            }
示例#3
0
 /// <summary>
 /// Prepares this leader for the next entry. Returns false if there are no entries left to introduce.
 /// </summary>
 public bool Reset(World World, Stone Stone)
 {
     this.PressureThreshold = Settings.Current.StoneIntroductionPressureThreshold;
     this.Timeout = Settings.Current.StoneIntroductionTimeout;
     this.Next = GetNext(World, Stone);
     return this.Next != null;
 }
示例#4
0
 /// <summary>
 /// Gets the next entry to be introduced by the given stone, or null if there are none left.
 /// </summary>
 public static Entry GetNext(World World, Stone Stone)
 {
     Entry entry = Stone.Entry;
     Entry n = entry.Next;
     if (n != null && !World.ContainsEntry(n))
         return n;
     uint maxweight = 0;
     Entry next = null;
     foreach (Entry p in entry.Previous)
         if (!World.ContainsEntry(p) && p.Weight > maxweight)
         {
             maxweight = p.Weight;
             next = p;
         }
     return next;
 }