Exemple #1
0
 public WorldState(InitializationMessage init)
 {
     m_size      = init.size;
     m_rover     = new Rover(init.min_sensor, init.max_sensor, init.max_turn, init.max_hard_turn);
     m_timeLimit = init.time_limit;
     m_tree      = new SimpleQuadTree(new RectangleF(-(m_size.Width / 2.0f), -(m_size.Height / 2.0f), m_size.Width, m_size.Height));
 }
Exemple #2
0
        public SimpleQuadTree(RectangleF rect, SimpleQuadTree parent)
        {
            this.rect   = rect;
            this.depth  = parent.depth + 1;
            this.parent = parent;

            foreach (MarsObject o in parent.objects)
            {
                if (this.rect.IntersectsWith(o.GetRect()))
                {
                    AddObject(o);
                }
            }
        }
Exemple #3
0
 private void Split()
 {
     children    = new SimpleQuadTree[4];
     children[0] = new SimpleQuadTree(
         new RectangleF(rect.Left, rect.Top, rect.Width / 2.0f, rect.Height / 2.0f),
         this);
     children[1] = new SimpleQuadTree(
         new RectangleF(children[0].rect.Right, rect.Top, this.rect.Width / 2.0f, this.rect.Height / 2.0f),
         this);
     children[2] = new SimpleQuadTree(
         new RectangleF(rect.Left, children[0].rect.Bottom, this.rect.Width / 2.0f, this.rect.Height / 2.0f),
         this);
     children[3] = new SimpleQuadTree(
         new RectangleF(children[0].rect.Right, children[0].rect.Bottom, this.rect.Width / 2.0f, this.rect.Height / 2.0f),
         this);
     objects = null;
 }