Example #1
0
        public void TestCreateRobot()
        {
            var algorithm = new PastukhVitaliiAlgorithm();
            var map       = new Map();

            map.Stations.Add(new EnergyStation()
            {
                Energy = 500, Position = new Position(7, 7)
            });
            map.Stations.Add(new EnergyStation()
            {
                Energy = 500, Position = new Position(8, 8)
            });
            map.Stations.Add(new EnergyStation()
            {
                Energy = 500, Position = new Position(9, 9)
            });

            var robots = new List <Robot.Common.Robot>()
            {
                new Robot.Common.Robot()
                {
                    Energy = 8000, Position = new Position(1, 1)
                }
            };

            robots.Add(new Robot.Common.Robot()
            {
                Energy = 8000, Position = new Position(0, 0)
            });

            var testmethod = algorithm.DoStep(robots, 0, map);

            Assert.IsTrue(testmethod is CreateNewRobotCommand);
        }
Example #2
0
        public void TestDoStep()
        {
            var algorithm  = new PastukhVitaliiAlgorithm();
            var map        = new Map();
            var stationPos = new Position(3, 2);
            var station1   = new EnergyStation()
            {
                Energy = 1234, Position = stationPos, RecoveryRate = 4
            };
            var stationPos1 = new Position(5, 3);
            var station2    = new EnergyStation()
            {
                Energy = 1234, Position = stationPos, RecoveryRate = 4
            };

            map.Stations.Add(station1);

            var robots = new List <Robot.Common.Robot>()
            {
                new Robot.Common.Robot()
                {
                    Energy = 8000, Position = new Position(2, 2),
                }
            };
            var x = algorithm.DoStep(robots, 0, map);

            Assert.IsTrue(x is MoveCommand);
        }
Example #3
0
        public void TimeTest()
        {
            var algorithm  = new PastukhVitaliiAlgorithm();
            var map        = new Map();
            var stationPos = new Position(5, 5);
            var station1   = new EnergyStation()
            {
                Energy = 1234, Position = stationPos, RecoveryRate = 4
            };

            map.Stations.Add(station1);
            var robots = new List <Robot.Common.Robot>()
            {
                new Robot.Common.Robot()
                {
                    Energy = 500, Position = new Position(15, 5)
                }
            };
            var time = new Stopwatch();

            time.Start();
            var testmethod = algorithm.DoStep(robots, 0, map) as MoveCommand;

            time.Stop();
            Assert.IsTrue(time.Elapsed < new TimeSpan(0, 0, 1));
        }
Example #4
0
        public void TestDefaultEnergy()
        {
            var algorithm = new PastukhVitaliiAlgorithm();
            var map       = new Map();

            map.Stations.Add(new EnergyStation()
            {
                Energy = 500, Position = new Position(7, 7)
            });
            map.Stations.Add(new EnergyStation()
            {
                Energy = 500, Position = new Position(8, 8)
            });
            map.Stations.Add(new EnergyStation()
            {
                Energy = 500, Position = new Position(9, 9)
            });
            var robots = new List <Robot.Common.Robot>()
            {
                new Robot.Common.Robot()
                {
                    Energy = 8000, Position = new Position(5, 8)
                }
            };

            var testmethod = algorithm.DoStep(robots, 0, map) as CreateNewRobotCommand;

            Assert.AreEqual(testmethod.NewRobotEnergy, 100);
        }
Example #5
0
        public void ChangePositionNextStep()
        {
            var algorithm  = new PastukhVitaliiAlgorithm();
            var map        = new Map();
            var stationPos = new Position(5, 5);
            var station1   = new EnergyStation()
            {
                Energy = 1234, Position = stationPos, RecoveryRate = 4
            };

            map.Stations.Add(station1);
            var robots = new List <Robot.Common.Robot>()
            {
                new Robot.Common.Robot()
                {
                    Energy = 500, Position = new Position(15, 5)
                }
            };
            var testmethod = algorithm.DoStep(robots, 0, map) as MoveCommand;

            Assert.AreEqual(new Position(9, 5), testmethod.NewPosition);
        }