Beispiel #1
0
        public void LoadStairTests(LogicPart logic, RMRules rules)
        {
            var yellowUp = new RMCommand[] {
                rules.Move(90),
                rules.Rotate(Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.UpLadder(),
            };

            var greenUp = new RMCommand[yellowUp.Length];
            yellowUp.CopyTo(greenUp, 0);
            greenUp[0] = rules.Move(140);

            AddTest(logic, "Stairs_YellowSuccess", PositionTest(-25, 80, 10, yellowUp));
            AddTest(logic, "Stairs_GreenFailure", PositionTest(25, 30, 10, greenUp));

            AddTest(logic, "Stairs_Scoring_Success", ScoreTest(15, yellowUp));
            AddTest(logic, "Stairs_Scoring_Failure", ScoreTest(0, greenUp));

            AddTest(logic, "Stairs_Scoring_UpWithoutCommand", ScoreTest(0,
                rules.Move(90),
                rules.Rotate(Angle.HalfPi),
                rules.Move(80),
                rules.Stand(0.1)
            ));
        }
        public sealed override LogicPart Create()
        {
            LogicPart logic = new LogicPart();

            LoadTests(logic); 

            return Initialize(logic);
        }
Beispiel #3
0
 public Competitions(string competitionName, string levelName, LogicPartHelper logicPartHelper, Func <IKeyboard> keyboardFactory, Func <GameSettings, List <IEngine> > enginesFactory)
 {
     CompetitionsName = competitionName;
     LevelName        = levelName;
     Logic            = logicPartHelper.Create();
     EnginesFactory   = enginesFactory;
     KeyboardFactory  = keyboardFactory;
 }
        public sealed override LogicPart Create()
        {
            LogicPart logic = new LogicPart();

            //LoadTests(logic);

            return(Initialize(logic));
        }
 private void LoadTests(LogicPart logic)
 {
     GetType().Assembly.GetTypes()
         .Where(type => IsGenericSubclass(type, typeof(CvarcTestCase<,,,,>)))
         .Select(type => Activator.CreateInstance(type) as ICvarcTestCase)
         .Where(instance => instance != null)
         .SelectMany(instance => instance.GetDefinedTests()).ToList()
         .ForEach(test => AddTest(logic, test.Item1, test.Item2));
 }
Beispiel #6
0
        private void LoadTests(LogicPart logic, RMRules rules)
        {
            var testMethods = GetType()
                .GetMethods()
                .Where(m => m.GetCustomAttributes(true).Where(a => a is TestLoaderMethod).Count() != 0)
                .Select(m => m.Name);

            foreach (var name in testMethods)
                GetType().GetMethod(name).Invoke(this, new Object[] { logic, rules });
        }
Beispiel #7
0
        public static Tuple<DemoRules,LogicPart> CreateWorldFactory()
        {
            var rules = new DemoRules();

            var logicPart = new LogicPart();
            logicPart.CreateWorld = () => new DemoWorld();
            logicPart.CreateDefaultSettings = () => new Settings { OperationalTimeLimit = 1, TimeLimit = 15 };
            logicPart.CreateWorldState = stateName => new DemoWorldState();
            logicPart.PredefinedWorldStates.Add("Empty");
            logicPart.WorldStateType = typeof(DemoWorldState);


            return new Tuple<DemoRules, LogicPart>(rules, logicPart);
        }
Beispiel #8
0
		void LoadGAXTests(LogicPart logic, DWMRules rules)
		{
			//1. сделать ступенчатое движение с ускорением и посчитать среднее ускорение
			//2. Пустить робота по кругу и проверить, что ускорение смотрит в центр
			//3. Аналогично с угловой скоростью
			//На DWM-е
            logic.Tests["GAX_CircleMoving"] = new DWMMovementTestBase(
                       GAXTest(new Point3D(0, -3, 0), Angle.Zero, Angle.Zero, Angle.Zero,
                       rules.DWMMoveArc(3, Angle.FromGrad(360), false),
                       rules.DWMStand(1.0)));
            logic.Tests["GAX_Rotating"] = new DWMMovementTestBase(
                       GAXTest(new Point3D(0, 0, 0), Angle.Zero, Angle.Zero, Angle.HalfPi,
                       rules.DWMRotate(Angle.Pi), rules.DWMStand(1.0)));

			
		}
		void LoadInteractionTests(LogicPart logic, DemoRules rules)
		{

			//для AlignmentRect пришлось увеличить delta на проверке угла поворота до 0,005
			logic.Tests["Interaction_Rect_Alignment"] = new RectangularInteractionTestBase(
				LocationTest((frame,asserter)=>
					{
						asserter.IsEqual(Angle.HalfPi.Grad,frame.Angle.Grad,1);
						asserter.IsEqual(22.36, frame.Y, 1);
					},
				rules.Move(-10),
				rules.Rotate(Angle.HalfPi / 2),
				rules.Move(50)));

            logic.Tests["Interaction_Round_Alignment"] = new RoundInteractionTestBase(
                LocationTest((frame, asserter) => asserter.IsEqual(Angle.HalfPi.Grad / 2, frame.Angle.Grad, 1),
                rules.Rotate(Angle.HalfPi / 2),
                rules.Move(30)));

            logic.Tests["Interaction_Round_Alignment2"] = new RoundInteractionTestBase(
                LocationTest((frame, asserter) =>
                {
                    asserter.IsEqual(Angle.HalfPi.Grad, frame.Angle.Grad % 360, 1);
                    asserter.IsEqual(22.45, frame.Y, 1e-3);
                },
                rules.Rotate(Angle.HalfPi / 2),
                rules.Move(30),
                rules.Rotate(Angle.HalfPi / 2),
                rules.Rotate(Angle.Pi * 2),
                rules.Move(10)));

            logic.Tests["Interaction_Rect_Collision"] = new RectangularInteractionTestBase(LocationTest(
               (frame, asserter) => asserter.True(frame.X < 100 && frame.X > 70),
               rules.Move(100)));
            
            logic.Tests["Interaction_Rect_BrickCollision"] = new RectangularInteractionTestBase(
                LocationTest((frame, asserter) =>
                {
                    asserter.IsEqual(0, frame.Angle.Grad % 360, 1);
                    asserter.IsEqual(-10, frame.Y, 1e-3);
                    asserter.IsEqual(100, frame.X, 1e-3);
                },
                rules.Rotate(-Angle.HalfPi),
                rules.Move(10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(100)));
        }
Beispiel #10
0
        public override LogicPart Initialize(LogicPart logicPart)
        {
            var rules = TBBRules.Current;

            logicPart.CreateWorld = () => new TBBWorld();
            logicPart.CreateDefaultSettings = () => new Settings { OperationalTimeLimit = 5, TimeLimit = 90 };
            logicPart.CreateWorldState = name => new TBBWorldState(UInt16.Parse(name));
            logicPart.PredefinedWorldStates.AddRange(Enumerable.Range(0, 5).Select(z => z.ToString()));
            logicPart.WorldStateType = typeof(TBBWorldState);

            var actorFactory = ActorFactory.FromRobot(new TBBRobot(), rules);
            logicPart.Actors[TwoPlayersId.Left] = actorFactory;
            logicPart.Actors[TwoPlayersId.Right] = actorFactory;

            logicPart.Bots["Standing"] = () => rules.CreateStandingBot();

            return logicPart;
        }
Beispiel #11
0
        void LoadDWMTests(LogicPart logic, DWMRules rules)
        {
            logic.Tests["DWM_Movement_LongForward"] = new DWMMovementTestBase(
			LocationTest(100, 0, 0, 10, rules.DWMMoveForward(100.0),
								   rules.DWMStand(1.0)));
            //basic DWM tests
            logic.Tests["DWM_Movement_Forward"] = new DWMMovementTestBase(
                LocationTest(10, 0, 0, 10, rules.DWMMoveForward(10.0),
                                       rules.DWMStand(1.0)));
            logic.Tests["DWM_Movement_Backward"] = new DWMMovementTestBase(
                LocationTest(-10, 0, 0, 10, rules.DWMMoveForward(-10.0),
                                        rules.DWMStand(1.0)));

            logic.Tests["DWM_Movement_RightRotate"] = new DWMMovementTestBase(
                LocationTest(0, 0, -45, 10, rules.DWMRotate(AIRLab.Mathematics.Angle.FromGrad(45.0)),rules.DWMStand(1.0)));

            logic.Tests["DWM_Movement_LeftRotate"] = new DWMMovementTestBase(
                LocationTest(0, 0, 45, 10, rules.DWMRotate(-1 * AIRLab.Mathematics.Angle.FromGrad(45.0)),rules.DWMStand(1.0)));

            logic.Tests["DWM_Movement_ArcRight"] = new DWMMovementTestBase(
                LocationTest(3, 3, 0, 10, rules.DWMMoveArc(3.0, AIRLab.Mathematics.Angle.FromGrad(90.0), true),
                                        rules.DWMStand(1.0)));

            logic.Tests["DWM_Movement_ArcLeft"] = new DWMMovementTestBase(
                LocationTest(3, -3, 0, 10, rules.DWMMoveArc(3.0, AIRLab.Mathematics.Angle.FromGrad(90.0), false),
                                        rules.DWMStand(1.0)));
            //advanced DWM tests
            logic.Tests["DWM_Movement_Turning"] = new DWMMovementTestBase(
                LocationTest(6, 6, 90, 10, rules.DWMMoveForward(3.0),
                                           rules.DWMRotate(AIRLab.Mathematics.Angle.FromGrad(90.0)),
                                           rules.DWMMoveForward(3.0),
                                           rules.DWMRotate(AIRLab.Mathematics.Angle.FromGrad(-90.0)),
                                           rules.DWMMoveForward(3.0),
                                           rules.DWMRotate(AIRLab.Mathematics.Angle.FromGrad(90.0)),
                                           rules.DWMMoveForward(3.0), rules.DWMStand(1.0)));

            logic.Tests["DWM_Movement_ArcMoving"] = new DWMMovementTestBase(
                LocationTest(6, 6, 90, 10, rules.DWMMoveArc(3.0, AIRLab.Mathematics.Angle.FromGrad(90.0), true),
                                           rules.DWMStand(1.0),
                                          rules.DWMMoveArc(3.0, AIRLab.Mathematics.Angle.FromGrad(90.0), false)));

        }
Beispiel #12
0
        public override LogicPart Create()
        {
            var rules = RMRules.Current;

            var logicPart = new LogicPart();
            logicPart.CreateWorld = () => new RMWorld();
            logicPart.CreateDefaultSettings = () => new Settings { OperationalTimeLimit = 5, TimeLimit = 90 };
            logicPart.CreateWorldState = stateName => new RMWorldState();
            logicPart.PredefinedWorldStates.AddRange(Enumerable.Range(0, 10).Select(z => z.ToString()));
            logicPart.WorldStateType = typeof(RMWorldState);

            var actorFactory = ActorFactory.FromRobot(new RMRobot<FullMapSensorData>(), rules);
            logicPart.Actors[TwoPlayersId.Left] = actorFactory;
            logicPart.Actors[TwoPlayersId.Right] = actorFactory;

            logicPart.Bots["Stand"] = () => rules.CreateStandingBot();

            LoadTests(logicPart, rules);

            return logicPart;
        }
Beispiel #13
0
        void LoadEncodersTests(LogicPart logic, DWMRules rules)
        {
            logic.Tests["Encoder_MoveForward"] = new DWMMovementTestBase(
                EncodersTest(
                new EncodersData { 
                    Timestamp = 0, 
                    TotalLeftRotation = Angle.FromGrad(114.3), 
                    TotalRightRotation = Angle.FromGrad(114.3) },
                rules.DWMMoveForward(10.0), rules.DWMStand(1.0)));
            logic.Tests["Encoder_ArcMoving"] = new DWMMovementTestBase(
                EncodersTest(
                new EncodersData
                {
                    Timestamp = 0,
                    TotalLeftRotation = Angle.FromGrad(234.0),
                    TotalRightRotation = Angle.FromGrad(52.0)
                },
                rules.DWMMoveArc(3.0, Angle.HalfPi, true)));

			//езда назад, поворот на месте, одна склейка двух-трех движений
        }
Beispiel #14
0
        void LoadMovementTests(LogicPart logic, DemoRules rules)
        {
            logic.Tests["Movement_Round_Forward"] = new RoundMovementTestBase(LocationTest(10,0, 0, 1, rules.Move(10)));
			logic.Tests["Movement_Round_Backward"] = new RoundMovementTestBase(LocationTest(-10, 0, 0, 1, rules.Move(-10)));
            logic.Tests["Movement_Rect_Forward"] = new RectangularMovementTestBase(LocationTest(10, 0, 0, 1, rules.Move(10)));
			logic.Tests["Movement_Rect_Backward"] = new RectangularMovementTestBase(LocationTest(-10, 0, 0, 1, rules.Move(-10)));
            logic.Tests["Movement_Rect_Square"] = new RectangularMovementTestBase(LocationTest(0, 0, 0, 50,
                rules.Move(10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Rotate(Angle.HalfPi)));
			logic.Tests["Movement_Round_Square"] = new RoundMovementTestBase(LocationTest(0, 0, 0, 10,
                rules.Move(10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Rotate(Angle.HalfPi)));
			logic.Tests["Movement_Rect_Rotate"] = new RectangularMovementTestBase(LocationTest(0, 0, 90, 10, rules.Rotate(Angle.HalfPi)));
            logic.Tests["Movement_Round_Rotate"] = new RoundMovementTestBase(LocationTest(0, 0, 90, 10, rules.Rotate(Angle.HalfPi)));
          
            logic.Tests["Movement_Limit_Linear"] = new RoundMovementTestBase(LocationTest(50, 0, 0, 1,
                rules.MoveWithVelocityForTime(100000, 1)));
			logic.Tests["Movement_Limit_Round"] = new RoundMovementTestBase(LocationTest(0, 0, 0, 1,
                rules.MoveWithVelocityForTime(-100000, 1)));
            logic.Tests["Movement_Limit_Round"] = new RoundMovementTestBase(LocationTest(0, 0, 0, 1,
                rules.RotateWithVelocityForTime(Angle.Pi * 10, 4)));
            logic.Tests["Movement_Limit_Round2"] = new RoundMovementTestBase(LocationTest(0, 0, 0, 1,
                rules.RotateWithVelocityForTime(-Angle.Pi * 19 / 10, 4)));
        }
 void AddTest(LogicPart logic, string name, RMTestEntry test)
 {
     logic.Tests[name] = new RMTestBase(test, new RMWorldState());
 }
 public abstract LogicPart Initialize(LogicPart logic);
        public void LoadTowerBuilderTests(LogicPart logic, RMRules rules)
        {
            AddTest(logic, "Tower_Grip_SingleDetail", TowerBuilderTest(
                1,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect()
            ));

            AddTest(logic, "Tower_Grip_MultipleDetails", TowerBuilderTest(
                2,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(15),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Stand(1),
                rules.Collect()
            ));

            AddTest(logic, "Tower_Grip_LightBeforeStand", TowerBuilderTest(
                1,
                rules.Rotate(Angle.Pi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect()
            ));

            AddTest(logic, "Tower_Grip_LightAfterStand", TowerBuilderTest(
                1,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Rotate(Angle.Pi),
                rules.Move(25),
                rules.Rotate(Angle.HalfPi),
                rules.Move(75),
                rules.Stand(0.1),
                rules.Collect()
            ));

            AddTest(logic, "Tower_Release_SingleDetail", TowerBuilderTest(
                0,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Release_MultipleDetail", TowerBuilderTest(
                0,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(15),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Grip_AlreadyConnected", TowerBuilderTest(
                2,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(15),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.BuildTower(),
                rules.Collect()
            ));
        }
Beispiel #18
0
 public Competitions(LogicPartHelper logicPartHelper, EnginePart engine, ManagerPart manager)
 {
     Logic = logicPartHelper.Create();
     Engine = engine;
     Manager = manager;
 }
Beispiel #19
0
        private void LoadCollisionTests(LogicPart logic, DemoRules rules)
        {
            logic.Tests["Collision_Rect_NoCollision"] = new RectangularCollisionTestBase(CollisionTest(0, 0, 0,
                rules.Grip(),
                rules.MoveWithVelocityForTime(-50, 0.2),
                rules.MoveWithVelocityForTime(50, 0.2)));
            logic.Tests["Collision_Rect_CollisionCount"] = new RectangularCollisionTestBase(CollisionTest(3, 3, 0,
                rules.MoveWithVelocityForTime(50, 1),
                rules.MoveWithVelocityForTime(50, 0.8),
                rules.MoveWithVelocityForTime(50, 0.3),
                rules.MoveWithVelocityForTime(-50, 0.2),
                rules.MoveWithVelocityForTime(50, 0.3),
                rules.MoveWithVelocityForTime(-50, 0.2),
                rules.MoveWithVelocityForTime(50, 0.3),
                rules.MoveWithVelocityForTime(-50, 0.2)));
            logic.Tests["Collision_Rect_CollisionBox"] = new RectangularCollisionTestBase(CollisionTest(1, 1, 0,
                rules.Grip(),
                rules.MoveWithVelocityForTime(50, 1.5),
                rules.RotateWithVelocityForTime(Angle.HalfPi, 1),
                rules.MoveWithVelocityForTime(50, 0.45)));
            logic.Tests["Collision_Rect_NoBox"] = new RectangularCollisionTestBase(CollisionTest(3, 3, 0,
                rules.MoveWithVelocityForTime(50, 1.05),
                rules.RotateWithVelocityForTime(Angle.HalfPi, 1),
                rules.MoveWithVelocityForTime(50, 0.8),
                rules.MoveWithVelocityForTime(50, 0.3),
                rules.MoveWithVelocityForTime(-50, 0.2),
                rules.MoveWithVelocityForTime(50, 0.3),
                rules.MoveWithVelocityForTime(-50, 0.2),
                rules.MoveWithVelocityForTime(50, 0.3),
                rules.MoveWithVelocityForTime(-50, 0.2)));
            logic.Tests["Collision_Rect_RotateNoBox"] = new RectangularCollisionTestBase(CollisionTest(1, 1, 0,
                rules.MoveWithVelocityForTime(50, 1.7),
                rules.RotateWithVelocityForTime(Angle.HalfPi, 1),
                rules.MoveWithVelocityForTime(50, 1.45),
                rules.RotateWithVelocityForTime(Angle.HalfPi, 1),
                rules.MoveWithVelocityForTime(50, 0.7),
                rules.RotateWithVelocityForTime(Angle.HalfPi, 1)));
            logic.Tests["Collision_Rect_RotateBox"] = new RectangularCollisionTestBase(CollisionTest(1, 1, 0,
                rules.Grip(),
                rules.MoveWithVelocityForTime(50, 1.7),
                rules.RotateWithVelocityForTime(Angle.HalfPi, 1),
                rules.MoveWithVelocityForTime(50, 1.6),
                rules.RotateWithVelocityForTime(Angle.HalfPi, 1),
                rules.MoveWithVelocityForTime(50, 0.7),
                rules.RotateWithVelocityForTime(Angle.HalfPi, 1)));
            logic.Tests["Collision_Rect_WallCollisionTime"] = new RectangularCollisionTestBase(ComplexCollisionTest(
                2,
                2.26,//вероятно после изменения размера робота эта велечина должна была измениться до 2,5-2,6
                false,
                false,
                rules.Rotate(Angle.HalfPi),
                rules.Move(50),
                rules.Move(50)
                ));
            logic.Tests["Collision_Rect_PushingWithBrick"] = new RectangularCollisionTestBase(ComplexCollisionTest(
                2,
                8.5,
                true,
                false,
                rules.Rotate(Angle.Pi),
                rules.Move(30),
                rules.Stand(0.00001),
                rules.Grip(),
                rules.Move(-30),
                rules.Rotate(Angle.HalfPi),
                rules.Move(25),
                rules.Rotate(Angle.HalfPi),
                rules.Move(40),
                rules.Rotate(Angle.HalfPi)
                ));
            logic.Tests["Collision_Rect_RotateWallCollision"] = new RectangularCollisionTestBase2(ComplexCollisionTest(
                2,
                8.5, //при удалении костыля время надо тоже уменьшать на 2 сек
                false,
                false,
                rules.Rotate(Angle.Pi),
                rules.Move(30),
                rules.Stand(0.00001),
                rules.Grip(),
                rules.Rotate(-Angle.HalfPi),
                //rules.Stand(2), //костыль, чтоб тест прошел
                rules.Move(70),
                rules.Rotate(-Angle.Pi)
                ));
            logic.Tests["Collision_Rect_BrickCollision"] = new RectangularCollisionTestBase2(
                CollisionTest(
                    4,
                    true,
                    false,
                    rules.Rotate(Angle.HalfPi),
                    rules.Move(50),
                    rules.Rotate(-Angle.HalfPi),
                    rules.Move(45),
                    rules.Rotate(-Angle.HalfPi),
                    rules.Move(70)
                ));
            logic.Tests["Collision_Rect_WallAndBrickCollision"] = new RectangularCollisionTestBase2(
                CollisionTest(
                    4,
                    false,
                    false,
                    rules.Rotate(Angle.HalfPi),
                    rules.Move(15),
                    rules.Rotate(-Angle.HalfPi),
                    rules.Move(45),
                    rules.Rotate(Angle.HalfPi),
                    rules.Move(70)
                ));

        }
        public void LoadClapperboardDeployingTests(LogicPart logic, RMRules rules)
        {
            AddTest(logic, "Clapper_Scores_RightDeployer", ScoreTest(5,
                rules.Move(55),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(85),
                rules.Rotate(Angle.HalfPi),
                rules.Stand(0.1),
                rules.UseRightDeployer()
            ));

            AddTest(logic, "Clapper_Scores_LeftDeployer", ScoreTest(5,
                rules.Move(55),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(85),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.UseLeftDeployer()
            ));

            AddTest(logic, "Clapper_Scores_RemoteDeployingShouldBeFailure", ScoreTest(0,
                rules.Move(55),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.UseLeftDeployer()
            ));

            AddTest(logic, "Clapper_Scores_BackDeployingNotEnough", ScoreTest(0,
                rules.Move(50),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-85),
                rules.Stand(0.1),
                rules.UseLeftDeployer(),
                rules.UseRightDeployer()
            ));

            AddTest(logic, "Clapper_Scores_WrongDeployingObjects", ScoreTest(0,
                rules.Move(200),
                rules.Rotate(Angle.HalfPi),
                rules.Stand(0.1),
                rules.UseRightDeployer(),
                rules.Stand(0.1),
                rules.Rotate(Angle.HalfPi),
                rules.Move(125),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Rotate(Angle.HalfPi),
                rules.Stand(0.1),
                rules.UseRightDeployer()
            ));

            AddTest(logic, "Clapper_Scores_WrongClapperboardColor", ScoreTest(-10,
                rules.Move(25),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(85),
                rules.Rotate(Angle.HalfPi),
                rules.Stand(0.1),
                rules.UseRightDeployer()
            ));

            /* не работает, нужно поменять константы
             *
             * AddTest(logic, "Clapper_Scores_AllClapperboardsClose", ScoreTest(30,
             *     rules.Move(50),
             *     rules.Rotate(Angle.HalfPi),
             *     rules.Move(-90),
             *     rules.Rotate(Angle.HalfPi),
             *     rules.Move(45),
             *     rules.Stand(0.1),
             *     rules.UseLeftDeployer(),
             *     rules.Stand(0.1),
             *     rules.Move(-25),
             *     rules.Stand(0.1),
             *     rules.UseLeftDeployer(),
             *     rules.Stand(0.1),
             *     rules.Move(-25),
             *     rules.Stand(0.1),
             *     rules.UseLeftDeployer(),
             *     rules.Stand(0.1),
             *     rules.Rotate(-Angle.HalfPi),
             *     rules.Move(40),
             *     rules.Rotate(-Angle.HalfPi),
             *     rules.Move(150),
             *     rules.Rotate(-Angle.HalfPi),
             *     rules.Move(40),
             *     rules.Rotate(Angle.HalfPi),
             *     rules.Stand(0.1),
             *     rules.UseRightDeployer(),
             *     rules.Move(-25),
             *     rules.Stand(0.1),
             *     rules.UseRightDeployer(),
             *     rules.Move(-25),
             *     rules.Stand(0.1),
             *     rules.UseRightDeployer()
             * ));
             */
        }
        public void LoadTowerScoringTests(LogicPart logic, RMRules rules)
        {
            AddTest(logic, "Tower_Scores_Zero", ScoreTest(
                0,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_BottomBuildingArea", ScoreTest(
                2,
                rules.Move(100),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(50),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_StartingAreaSquare", ScoreTest(
                2,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(-25),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(65),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_StartingAreaCircle", ScoreTest(
                2,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(-25),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(35),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_BuildingInYellowSquare", ScoreTest(
                0,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(20),
                rules.Rotate(Angle.HalfPi),
                rules.Move(170),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_BigTower", ScoreTest(
                2 * 2,
                rules.Move(65),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(15),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Stand(1),
                rules.Collect(),
                rules.Move(20),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(30),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_TowerWithLight", ScoreTest(
                2 + 3,
                rules.Rotate(Angle.Pi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Rotate(Angle.Pi),
                rules.Move(105),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(50),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_BigTowerWithLight", ScoreTest(
                (2 + 3) * 2,
                rules.Rotate(Angle.Pi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Rotate(Angle.Pi),
                rules.Move(75),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(15),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Stand(1),
                rules.Collect(),
                rules.Move(20),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(30),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_LightWithoutStands", ScoreTest(
                0,
                rules.Rotate(Angle.Pi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(-10),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_ScamTest", ScoreTest(
                2,
                rules.Move(100),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(-25),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(90),
                rules.Stand(0.1),
                rules.BuildTower(),
                rules.Collect(),
                rules.BuildTower(),
                rules.Collect(),
                rules.BuildTower(),
                rules.Collect(),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_InvalidStandPenalty", ScoreTest(
                -10,
                rules.Move(135),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect()
            ));

            AddTest(logic, "Tower_Scores_TwoTowersOneLocation", ScoreTest(
                (2 + 3) * 2 /* 2-level spotlight with bonus */ + (2 + 0) * 1 /* one level spotlight, no bonus */,
                rules.Rotate(Angle.Pi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(-74),
                rules.Rotate(Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(-25),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(44),
                rules.Stand(0.1),
                rules.BuildTower(),
                rules.Move(-10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(85),
                rules.Rotate(Angle.HalfPi),
                rules.Move(50),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(30),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(35),
                rules.Rotate(Angle.HalfPi),
                rules.Move(50),
                rules.Stand(0.1),
                rules.BuildTower()
            ));

            AddTest(logic, "Tower_Scores_TwoTowersTwoLocations", ScoreTest(
                (2 + 3) * 2 + (2 + 3) * 1,
                rules.Rotate(Angle.Pi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(-74),
                rules.Rotate(Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(-25),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(44),
                rules.Stand(0.1),
                rules.BuildTower(),
                rules.Move(-10),
                rules.Rotate(Angle.HalfPi),
                rules.Move(85),
                rules.Rotate(Angle.HalfPi),
                rules.Move(50),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(10),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(30),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Collect(),
                rules.Move(10),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(25),
                rules.Stand(0.1),
                rules.BuildTower()
            ));
        }
Beispiel #22
0
        void LoadGrippingTests(LogicPart logic, DemoRules rules)
        {
            logic.Tests["Gripping_Rect_Grip"] = new RectangularGrippingTestBase(GrippingTest(
                true,
                rules.Move(50),
                rules.Stand(1),
                rules.Grip(),
                rules.Move(-10),
                rules.Stand(5)
                ));
            logic.Tests["Gripping_Round_Grip"] = new RoundGrippingTestBase(GrippingTest(
                true,
                rules.Move(50),
                rules.Stand(1),
                rules.Grip(),
                rules.Move(-10),
                rules.Stand(5)
                ));
            logic.Tests["Gripping_Round_GripAndMove"] = new RoundGrippingTestBase(LocationTest(
                0, 0, 0, 1,
                rules.Move(50),
                rules.Stand(1),
                rules.Grip(),
                rules.Move(-50),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(50),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(50),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(50),
                rules.Rotate(-Angle.HalfPi)
                ));
            logic.Tests["Gripping_Rect_GripAndMove"] = new RectangularGrippingTestBase(LocationTest(
                0, 0, 0, 1,
                rules.Move(50),
                rules.Stand(1),
                rules.Grip(),
                rules.Move(-50),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(50),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(50),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(50),
                rules.Rotate(-Angle.HalfPi)
                ));
            logic.Tests["Gripping_Rect_GripAndMove2"] = new RectangularGrippingTestBase(LocationTest(
                46.1, 0, 0, 1,
                rules.Move(50),
                rules.Stand(1),
                rules.Grip(),
                rules.Rotate(-Angle.HalfPi),
                rules.Rotate(-Angle.HalfPi),
                rules.Rotate(-Angle.HalfPi),
                rules.Rotate(-Angle.HalfPi)
                ));

            logic.Tests["Gripping_Rect_GripThroughWall"] = new RectangularGrippingTestBase(GrippingTest(
                false,
                rules.Rotate(Angle.HalfPi),
                rules.Move(50),
                rules.Grip(),
                rules.Move(-50)));
            logic.Tests["Gripping_Rect_Release"] = new RectangularGrippingTestBase(GrippingTest(
                false,
                rules.Move(50),
                rules.Stand(0.1d),
                rules.Grip(),
                rules.Move(-15),
                rules.Release()));
            logic.Tests["Gripping_Rect_GripUnGripable"] = new RectangularGrippingTestBase(GrippingTest(
                false,
                rules.Move(25),
                rules.Rotate(Angle.HalfPi),
                rules.Move(25),
                rules.Grip(),
                rules.Move(-25)));
            logic.Tests["Gripping_Rect_GripFromBack"] = new RectangularGrippingTestBase(
                GrippingTest(
                    false,
                    rules.Move(-40),
                    rules.Stand(1),
                    rules.Grip()));
        }
 private void AddTest(LogicPart logic, string name, ICvarcTest test)
 {
     logic.Tests[name] = test;
 }
 public abstract LogicPart Initialize(LogicPart logic);
        public void LoadPopCornScoringTests(LogicPart logic, RMRules rules)
        {
            AddTest(logic, "PopCorn_Scores_StartingArea", ScoreTest(
                4,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-54),
                rules.Stand(0.1),
                rules.Release()
            ));

            AddTest(logic, "PopCorn_Scores_UpperCinema", ScoreTest(
                4,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(130),
                rules.Rotate(Angle.HalfPi),
                rules.Move(40),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(60),
                rules.Stand(0.1),
                rules.Release()
            ));

            AddTest(logic, "PopCorn_Scores_BottomCinema", ScoreTest(
                4,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(130),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(40),
                rules.Rotate(Angle.HalfPi),
                rules.Move(60),
                rules.Stand(0.1),
                rules.Release()
            ));

            AddTest(logic, "PopCorn_Scores_BuildingArea", ScoreTest(
                0,
                rules.Move(115),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-60),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Move(-15),
                rules.Stand(0.1),
                rules.Release(),
                rules.Move(40),
                rules.Stand(0.1)
            ));

            AddTest(logic, "PopCorn_Scores_TwoCupsSameLocation", ScoreTest(
                4,
                rules.Move(115),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-60),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Move(60),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-115),
                rules.Stand(0.1),
                rules.Release(),
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-40),
                rules.Stand(0.1),
                rules.Release()
            ));

            AddTest(logic, "PopCorn_Scores_TwoCupsDiffLocations", ScoreTest(
                4 + 4,
                rules.Move(115),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-60),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Move(60),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-115),
                rules.Stand(0.1),
                rules.Release(),
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(130),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(40),
                rules.Rotate(Angle.HalfPi),
                rules.Move(60),
                rules.Stand(0.1),
                rules.Release()
            ));

            AddTest(logic, "PopCorn_Scores_GrippedShouldBeZero", ScoreTest(
                0,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-64),
                rules.Stand(0.1)
            ));

            AddTest(logic, "PopCorn_Scores_FilledCup", ScoreTest(
                5,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-30),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-70),
                rules.Stand(0.1),
                rules.GetPopCorn(),
                rules.Move(70),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-10),
                rules.Stand(0.1),
                rules.Release()
            ));

            AddTest(logic, "PopCorn_Scores_TwoCupsFilled", ScoreTest(
                5,
                rules.Move(115),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-60),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Move(60),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-115),
                rules.Stand(0.1),
                rules.Release(),
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-30),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-70),
                rules.Stand(0.1),
                rules.GetPopCorn(),
                rules.Move(70),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-10),
                rules.Stand(0.1),
                rules.Release()
            ));
        }
        public void LoadPopCornFillingTests(LogicPart logic, RMRules rules)
        {
            AddTest(logic, "PopCorn_Scores_SensorWorking", PopCornTest(
                4,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip()
            ));

            AddTest(logic, "PopCorn_Filling_CheckWorking", PopCornTest(
                4 + 1,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-30),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-70),
                rules.Stand(0.1),
                rules.GetPopCorn()
            ));

            AddTest(logic, "PopCorn_Filling_Backward", PopCornTest(
                4,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-30),
                rules.Rotate(Angle.HalfPi),
                rules.Move(70),
                rules.Stand(0.1),
                rules.GetPopCorn()
            ));

            AddTest(logic, "PopCorn_Filling_DispenserLimit", PopCornTest(
                4 + 5, // not 4 + 6 !
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-30),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-70),
                rules.Stand(0.1),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn()
            ));

            AddTest(logic, "PopCorn_Filling_CupLimit", PopCornTest(
                10,
                rules.Move(64),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.Grip(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-30),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-70),
                rules.Stand(0.1),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.Rotate(Angle.HalfPi),
                rules.Move(-30),
                rules.Rotate(-Angle.HalfPi),
                rules.Stand(0.1),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn()
            ));

            AddTest(logic, "PopCorn_Filling_EmptyGripper", PopCornTest(
                0,
                rules.Move(34),
                rules.Rotate(-Angle.HalfPi),
                rules.Move(-75),
                rules.Stand(0.1),
                rules.GetPopCorn(),
                rules.GetPopCorn(),
                rules.GetPopCorn()
            ));
        }