Beispiel #1
0
        static void Main(string[] args)
        {
            PositionOctree <Value> octree = new PositionOctree <Value>();

            octree.Insert(new Value(5), 1, 1, 1);
            octree.Insert(new Value(24), 1000000, 1000000, 1000000);
            octree.Insert(new Value(534), 1000000000, 1000000000, 1000000000);
            octree.Insert(new Value(-5), -1, -1, -1);
            octree.Insert(new Value(-24), -1000000, -1000000, -1000000);
            octree.Insert(new Value(-534), -1000000000, -1000000000, -1000000000);
            Value v = octree.Find(1, 1, 1);

            Console.WriteLine(v.Blah);
            v = octree.Find(1000000, 1000000, 1000000);
            Console.WriteLine(v.Blah);
            v = octree.Find(1000000000, 1000000000, 1000000000);
            Console.WriteLine(v.Blah);
            v = octree.Find(-1, -1, -1);
            Console.WriteLine(v.Blah);
            v = octree.Find(-1000000, -1000000, -1000000);
            Console.WriteLine(v.Blah);
            v = octree.Find(-1000000000, -1000000000, -1000000000);
            Console.WriteLine(v.Blah);
            Console.ReadKey();
        }
Beispiel #2
0
            public DroneManagement(IngameTime time, IMyIntergridCommunicationSystem comms)
            {
                dronesByPosition = new PositionOctree <Drone>();
                drones           = new Dictionary <long, Drone>();
                commands         = new Dictionary <string, Action <object> >();

                this.time  = time;
                this.comms = comms;
            }
 public void TestSetAndGet()
 {
     var octree = new PositionOctree<string>();
     octree.Insert("hello", 0, 0, 0);
     Assert.Equal("hello", octree.Find(0, 0, 0));
     octree.Insert("world", -1, -1, -1);
     Assert.Equal("world", octree.Find(-1, -1, -1));
     octree.Insert("blah", -1, 0, -1);
     Assert.Equal("blah", octree.Find(-1, 0, -1));
 }
 public void TestSetAndFastGet()
 {
     var octree = new PositionOctree<string>();
     octree.Insert("hello", 0, 0, 0);
     Assert.Equal("hello", PositionOctreeUtil.GetFast64(octree, 0, 0, 0));
     octree.Insert("world", -1, -1, -1);
     Assert.Equal("world", PositionOctreeUtil.GetFast64(octree, -1, -1, -1));
     octree.Insert("blah", -1, 0, -1);
     Assert.Equal("blah", PositionOctreeUtil.GetFast64(octree, -1, 0, -1));
 }
Beispiel #5
0
                public Sector(Vector3D center, double halfLength, Sector parent, PositionOctree <T> root, int depth, int quadrantNum)
                {
                    this.parent      = parent;
                    this.root        = root;
                    this.center      = center;
                    this.halfLength  = halfLength;
                    this.depth       = depth;
                    this.quadrantNum = quadrantNum;

                    leaves = new List <Leaf>(8);
                }
        public void TestSetAndFastGet()
        {
            var octree = new PositionOctree <string>();

            octree.Insert("hello", 0, 0, 0);
            _assert.Equal("hello", PositionOctreeUtil.GetFast64(octree, 0, 0, 0));
            octree.Insert("world", -1, -1, -1);
            _assert.Equal("world", PositionOctreeUtil.GetFast64(octree, -1, -1, -1));
            octree.Insert("blah", -1, 0, -1);
            _assert.Equal("blah", PositionOctreeUtil.GetFast64(octree, -1, 0, -1));
        }
        public void TestSetAndGet()
        {
            var octree = new PositionOctree <string>();

            octree.Insert("hello", 0, 0, 0);
            _assert.Equal("hello", octree.Find(0, 0, 0));
            octree.Insert("world", -1, -1, -1);
            _assert.Equal("world", octree.Find(-1, -1, -1));
            octree.Insert("blah", -1, 0, -1);
            _assert.Equal("blah", octree.Find(-1, 0, -1));
        }
Beispiel #8
0
            private void ReturnPosition(MyIGCMessage message)
            {
                long  droneID = message.Source;
                Drone drone;

                if (drones.TryGetValue(droneID, out drone))
                {
                    Vector3D position = (Vector3D)message.Data;
                    PositionOctree <Drone> .Leaf?leaf = new PositionOctree <Drone> .Leaf();

                    if (dronesByPosition.TryDeleteLeafAt(drone.position, ref leaf))
                    {
                        drone.ReturnPosition(position);

                        dronesByPosition.TryAddLeaf(drone.position, drone);
                        return;
                    }

                    drone.ReturnPosition(position);
                    dronesByPosition.TryAddLeaf(drone.position, drone);
                }
            }
        public override int Run(string[] remainingArguments)
        {
            PositionOctree<Value> octree = new PositionOctree<Value>();
            octree.Insert(new Value(5), 1, 1, 1);
            octree.Insert(new Value(24), 1000000, 1000000, 1000000);
            octree.Insert(new Value(534), 1000000000, 1000000000, 1000000000);
            octree.Insert(new Value(-5), -1, -1, -1);
            octree.Insert(new Value(-24), -1000000, -1000000, -1000000);
            octree.Insert(new Value(-534), -1000000000, -1000000000, -1000000000);
            Value v = octree.Find(1, 1, 1);
            Console.WriteLine(v.Blah);
            v = octree.Find(1000000, 1000000, 1000000);
            Console.WriteLine(v.Blah);
            v = octree.Find(1000000000, 1000000000, 1000000000);
            Console.WriteLine(v.Blah);
            v = octree.Find(-1, -1, -1);
            Console.WriteLine(v.Blah);
            v = octree.Find(-1000000, -1000000, -1000000);
            Console.WriteLine(v.Blah);
            v = octree.Find(-1000000000, -1000000000, -1000000000);
            Console.WriteLine(v.Blah);

            return 0;
        }