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;
            }
        }
Beispiel #2
0
        protected void CreateObject(int color)
        {
            m_currentObject = new Shape(Shape.Shapes.Square, new PointF(0f, 0f), new SizeF(WrappedWorld.Scene.Width, WrappedWorld.Scene.Height));
            WrappedWorld.AddGameObject(m_currentObject);

            SetObjectColor(color);
        }
        // Create a shape
        protected ComparisonShape CreateTarget(ComparisonShape.Shapes shape)
        {
            SizeF           size     = GetSize(TSHints[SCALE_SHAPE] == 1);
            PointF          location = GetRandomLocation(size);
            float           rotation = GetRotation(TSHints[ROTATE_SHAPE] == 1);
            ComparisonShape target   = new ComparisonShape(shape, location, size, rotation);

            WrappedWorld.AddGameObject(target);
            return(target);
        }
Beispiel #4
0
        protected void CreateTarget()
        {
            const int TARGET_SIZE = 64;

            m_target = new Shape(Shape.Shapes.Square, PointF.Empty, new SizeF(TARGET_SIZE, TARGET_SIZE));
            WrappedWorld.AddGameObject(m_target);
            // Viewport is assumed to be centered
            float minX = (WrappedWorld.Scene.Width - WrappedWorld.Viewport.Width) / 2;
            float maxX = (WrappedWorld.Scene.Width + WrappedWorld.Viewport.Width) / 2 - m_target.Size.Width;

            m_target.Position.X = (float)(minX + m_rndGen.NextDouble() * (maxX - minX));
            float minY = (WrappedWorld.Scene.Height - WrappedWorld.Viewport.Height) / 2;
            float maxY = (WrappedWorld.Scene.Height + WrappedWorld.Viewport.Height) / 2 - m_target.Size.Height;

            m_target.Position.Y = (float)(minY + m_rndGen.NextDouble() * (maxY - minY));
        }
        public void CreateTargets()                                                                                     // Create a number of targets and fill the list(m_gameObjectReferences) of references for the sequence indexing
        {
            currentIndex = 0;
            m_gameObjectReferences.Clear();

            float cumulatedManhattanDistance = 0;

            GameObject previousGameObject = m_agent;

            for (int n = 0; n < (int)TSHints[SEQUENCE_LENGTH]; n++)                                                   // Generate a number of targets corresponding to the length of the sequence
            {
                m_target = new GameObject(GetNumberTargetImage(n), type: GameObjectType.NonColliding);
                WrappedWorld.AddGameObject(m_target);

                m_target.Size.Width  = 10;
                m_target.Size.Height = 15;

                m_gameObjectReferences.Add(m_target);                                                                     // Add the current GameObject to the vector of GameObject references

                // PositionFree = WrappedWorld.RandomPositionInsidePowNonCovering(m_rndGen, m_target.GetGeometry().Size);  // Generate a random point where the corresponding GameObject doesn't cover any other GameObject

                // The generated GameObjects should be close to the agent, close enough so that no objects are outside the screen while following the sequence
                RectangleF r1 = new RectangleF
                {
                    X      = m_agent.Position.X - WrappedWorld.Viewport.Width / 4,
                    Y      = m_agent.Position.Y - WrappedWorld.Viewport.Height / 4,
                    Width  = WrappedWorld.Viewport.Width / 2,
                    Height = WrappedWorld.Viewport.Height / 2
                };

                m_target.Position = WrappedWorld.RandomPositionInsideRectangleNonCovering(m_rndGen, m_target.GetGeometry().Size, r1);

                float estimatedManhattanDistance = Math.Abs(m_gameObjectReferences[n].Position.X - previousGameObject.Position.X)
                                                   + Math.Abs(m_gameObjectReferences[n].Position.Y - previousGameObject.Position.Y);
                estimatedManhattanDistance /= 4;                                                                        // Assuming that agent travels using 1 actuator at a time, (In such case it can move max 4 pixels per step, otherwise it's 8)
                cumulatedManhattanDistance += estimatedManhattanDistance;

                //MyLog.DEBUG.WriteLine("Calculating Manhattan distance between previous Object X,Y: " + previousGameObject.X + ", " + previousGameObject.Y + " AND " + m_gameObjectReferences[n].X + ", " + m_gameObjectReferences[n].Y + " := " + estimatedManhattanDistance);

                previousGameObject = m_gameObjectReferences[n];
            }

            //MyLog.DEBUG.WriteLine("Final estimatedManhattan Distance: " + CumulatedManhattanDistance);

            TSHints[TIMESTEPS_LIMIT] = cumulatedManhattanDistance * TSHints[DISTANCE_BONUS_COEFFICENT];
        }
        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);
        }
Beispiel #7
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
            }
        }
Beispiel #8
0
 protected void CreateTarget()
 {
     m_object = new Shape(Shape.Shapes.Square, new PointF(0f, 0f), new SizeF(WrappedWorld.Scene.Width, WrappedWorld.Scene.Height));
     WrappedWorld.AddGameObject(m_object);
 }