コード例 #1
0
        public void GenerateObstacles()
        {
            WrappedWorld.CreateAgent();                                                         // Generate agent
            m_agent = WrappedWorld.Agent;

            m_target = WrappedWorld.CreateTarget(new Point(0, 0));
            WrappedWorld.AddGameObject(m_target);

            RoguelikeWorld world = WrappedWorld as RoguelikeWorld;                              // Reference to World
            Grid           g     = world.GetGrid();                                             // Get grid

            TSHints[TIMESTEPS_LIMIT] = 200;

            int widthOfRectangle  = 3;
            int heightOfRectangle = 2;

            createWallRectangleWithFillProbability(world, m_rndGen, 5, 5, widthOfRectangle, heightOfRectangle, 0.8f, 1.0f);

            // Position agent
            m_agent.Position.X = 200;
            m_agent.Position.Y = 193;

            // Position target
            m_target.Position.X = m_rndGen.Next(160, 280);

            if (m_rndGen.Next(0, 2) == 0)
            {
                m_target.Position.Y = 120;
            }
            else
            {
                m_target.Position.Y = 270;
            }
        }
コード例 #2
0
ファイル: LTApproach.cs プロジェクト: xeronith/BrainSimulator
        public virtual void CreateTarget()
        {
            float scaleFactor = 1;

            if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1)
            {
                scaleFactor = (float)m_rndGen.NextDouble() * 0.7f + 0.8f;
            }

            m_target = WrappedWorld.CreateTarget(new Point(0, 0), scaleFactor);

            PointF p;

            if ((int)TSHints[TSHintAttributes.DEGREES_OF_FREEDOM] == 1)
            {
                RectangleF POW = WrappedWorld.GetPowGeometry();
                POW.Location = new PointF(POW.X, POW.Y + POW.Height / 2 - m_agent.Size.Height);
                POW.Size     = new SizeF(POW.Width, m_agent.Size.Height * 2);
                p            = WrappedWorld.RandomPositionInsideRectangleNonCovering(m_rndGen, m_target.GetGeometry().Size, POW, 5, 20);
            }
            else
            {
                p = WrappedWorld.RandomPositionInsideViewport(m_rndGen, m_target.GetGeometry().Size, 20);
            }

            m_target.Position = p;
        }
コード例 #3
0
        public override void CreateTarget()
        {
            //MyLog.INFO.WriteLine(" called CreateTarget() from LTMovingTarget");

            m_target = WrappedWorld.CreateTarget(new Point(0, 0));

            m_target.Size.Width  = 30;
            m_target.Size.Height = 30;

            float newNumber = (float)m_rndGen.NextDouble();

            PointF randomPoint = GetPointInEllipse(newNumber, TSHints[ELLIPSE_SIZE]);

            m_angle = newNumber;                                                  // Adapt the new current m_angle to the point generated

            m_target.Position.X = randomPoint.X;
            m_target.Position.Y = randomPoint.Y;

            WrappedWorld.AddGameObject(m_target);
        }
コード例 #4
0
        //Agent and target are generated in the same function, because the correspondent positions will depend on the wall positions
        public void GenerateObstacles()
        {
            int level = (int)TSHints[OBSTACLES_LEVEL];                                          // Update value of current level

            WrappedWorld.CreateAgent();                                                         // Generate agent
            m_agent = WrappedWorld.Agent;

            m_target = WrappedWorld.CreateTarget(new Point(0, 0));
            WrappedWorld.AddGameObject(m_target);

            RoguelikeWorld world = WrappedWorld as RoguelikeWorld;                              // Reference to World
            Grid           g     = world.GetGrid();                                             // Get grid

            if (level == 1)
            {
                TSHints[TIMESTEPS_LIMIT] = 500;

                int widthOfRectangle  = 10;
                int heightOfRectangle = 5;

                createWallRectangle(world, widthOfRectangle, heightOfRectangle);

                // Position agent
                m_agent.Position.X = 50;
                m_agent.Position.Y = 50;

                // Position target
                m_target.Position.X = 280;
                m_target.Position.Y = 120;
            }

            if (level == 2)                                                                     // Like level 1, but inverted
            {
                TSHints[TIMESTEPS_LIMIT] = 500;

                int widthOfRectangle  = 10;
                int heightOfRectangle = 5;

                createWallRectangle(world, widthOfRectangle, heightOfRectangle);

                // Position agent
                m_agent.Position.X = 280;
                m_agent.Position.Y = 120;

                // Position target
                m_target.Position.X = 50;
                m_target.Position.Y = 50;
            }

            if (level == 3)
            {
                TSHints[TIMESTEPS_LIMIT] = 400;

                int widthOfRectangle  = 20;
                int heightOfRectangle = 5;

                createWallRectangle(world, widthOfRectangle, heightOfRectangle);

                world.CreateWall(g.GetPoint(14, 4));
                world.CreateWall(g.GetPoint(14, 3));
                world.CreateWall(g.GetPoint(14, 2));

                // Position agent
                m_agent.Position.X = 80;
                m_agent.Position.Y = 120;

                // Position target
                m_target.Position.X = 550;
                m_target.Position.Y = 110;
            }

            if (level == 4)
            {
                TSHints[TIMESTEPS_LIMIT] = 400;

                int widthOfRectangle  = 20;
                int heightOfRectangle = 10;

                createWallRectangle(world, widthOfRectangle, heightOfRectangle);

                world.CreateWall(g.GetPoint(14, 9));
                world.CreateWall(g.GetPoint(14, 8));
                world.CreateWall(g.GetPoint(14, 7));
                world.CreateWall(g.GetPoint(14, 6));
                world.CreateWall(g.GetPoint(14, 5));
                world.CreateWall(g.GetPoint(14, 4));
                world.CreateWall(g.GetPoint(14, 3));

                world.CreateWall(g.GetPoint(8, 1));
                world.CreateWall(g.GetPoint(8, 2));
                world.CreateWall(g.GetPoint(8, 3));
                world.CreateWall(g.GetPoint(8, 4));
                world.CreateWall(g.GetPoint(8, 5));
                world.CreateWall(g.GetPoint(8, 6));
                world.CreateWall(g.GetPoint(8, 7));
                world.CreateWall(g.GetPoint(8, 8));

                // Position agent
                m_agent.Position.X = 80;
                m_agent.Position.Y = 60;

                // Position target
                m_target.Position.X = 550;
                m_target.Position.Y = 250;
            }

            if (level == 5)
            {
                TSHints[TIMESTEPS_LIMIT] = 300;

                int widthOfRectangle  = 13;
                int heightOfRectangle = 5;

                createWallRectangle(world, widthOfRectangle, heightOfRectangle);

                // Walls positioned randomly inside the wall rectangle
                createWallVerticalLine(world, 4, m_rndGen.Next(1, 3), 3);
                createWallVerticalLine(world, 6, m_rndGen.Next(1, 3), 3);
                createWallVerticalLine(world, 8, m_rndGen.Next(1, 3), 3);

                // Position agent
                m_agent.Position.X = 50;
                m_agent.Position.Y = 50;

                // Position target according to the wall rectangle that was generated with random size
                m_target.Position.X = 350;
                //m_target.Y = 110;
                m_target.Position.Y = m_rndGen.Next(70, 110);   // Randomize Y position of target
            }

            if (level == 6)
            {
                TSHints[TIMESTEPS_LIMIT] = 260;

                int widthOfRectangle  = 13;
                int heightOfRectangle = 5;

                createWallRectangle(world, widthOfRectangle, heightOfRectangle);

                // Walls positioned randomly inside the wall rectangle
                createWallVerticalLine(world, 4, m_rndGen.Next(1, 3), 3);
                createWallVerticalLine(world, 6, m_rndGen.Next(1, 3), 3);
                createWallVerticalLine(world, 8, m_rndGen.Next(1, 3), 3);

                // Position agent
                m_agent.Position.X = 50;
                m_agent.Position.Y = 50;

                // Position target according to the wall rectangle that was generated with random size
                m_target.Position.X = 350;
                //m_target.Y = 110;
                m_target.Position.Y = m_rndGen.Next(70, 110);   // Randomize Y position of target
            }
        }