Exemplo n.º 1
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);
        }
Exemplo n.º 2
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)));
        }
Exemplo n.º 3
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)));
        }
Exemplo n.º 4
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()));
        }
Exemplo n.º 5
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)
                ));

        }