コード例 #1
0
        public void DetectsCollisionInAdjacentBucket()
        {
            SimOpt.SimOpts = new SimOptions {
                FieldHeight = FieldHeight, FieldWidth = FieldWidth, FixedBotRadii = true
            };

            var manager = new BucketManager(SimOpt.SimOpts);

            var position1 = new DoubleVector(BucketManager.BucketSize - 1, BucketManager.BucketSize - 1);
            var position2 = new DoubleVector(BucketManager.BucketSize + 1, BucketManager.BucketSize + 1);

            var bot1 = new Robot(manager)
            {
                Position = position1, AbsNum = 0
            };
            var bot2 = new Robot(manager)
            {
                Position = position2, AbsNum = 1
            };

            manager.UpdateBotBucket(bot1);
            manager.UpdateBotBucket(bot2);

            var collisionBots = manager.CheckForCollisions(bot1, true);

            collisionBots.Should().Contain(bot2);
        }
コード例 #2
0
        public void DetectsCollision(double[] position1, double[] position2, double[] position3, bool collides2, bool collides3)
        {
            SimOpt.SimOpts = new SimOptions {
                FieldHeight = FieldHeight, FieldWidth = FieldWidth, FixedBotRadii = true
            };

            var manager = new BucketManager(SimOpt.SimOpts);

            var bot1 = new Robot(manager)
            {
                Position = position1, AbsNum = 0
            };
            var bot2 = new Robot(manager)
            {
                Position = position2, AbsNum = 1
            };
            var bot3 = new Robot(manager)
            {
                Position = position3, AbsNum = 2
            };

            manager.UpdateBotBucket(bot1);
            manager.UpdateBotBucket(bot2);
            manager.UpdateBotBucket(bot3);

            var collisionBots = manager.CheckForCollisions(bot1, true);

            if (collides2)
            {
                collisionBots.Should().Contain(bot2);
            }
            else
            {
                collisionBots.Should().NotContain(bot2);
            }

            if (collides3)
            {
                collisionBots.Should().Contain(bot3);
            }
            else
            {
                collisionBots.Should().NotContain(bot3);
            }
        }