Example #1
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            PointF location = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size);

            Shape randomVeryGoodFood = WrappedWorld.CreateRandomVeryGoodFood(location, size, RndGen);

            Actions.Movement = MoveActionsToTarget(randomVeryGoodFood.Center());

            PointF location2 = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size);

            if (RndGen.Next(3) > 0)
            {
                Shape randomEnemy = WrappedWorld.CreateRandomEnemy(location2, size, RndGen);
                Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.Center()));
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomFood(location2, size, RndGen);
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Example #2
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            int    positionsWcCount  = Positions.PositionsWithoutCenter.Count;
            int    randomLocationIdx = RndGen.Next(positionsWcCount);
            PointF location          = Positions.PositionsWithoutCenter[randomLocationIdx];

            int    randomLocationIdx2 = (RndGen.Next(positionsWcCount - 1) + randomLocationIdx + 1) % positionsWcCount;
            PointF location2          = Positions.PositionsWithoutCenter[randomLocationIdx2];

            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                Shape randomFood = WrappedWorld.CreateRandomFood(location, size, RndGen);
                Actions.Movement = MoveActionsToTarget(randomFood.GetCenter());
            }
            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Example #3
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            int    positionsCount    = Positions.Positions.Count;
            int    randomLocationIdx = RndGen.Next(positionsCount);
            PointF location          = Positions.Positions[randomLocationIdx];

            int    randomLocationIdx2 = (RndGen.Next(positionsCount - 1) + randomLocationIdx + 1) % positionsCount;
            PointF location2          = Positions.Positions[randomLocationIdx2];

            Shape randomEnemy = WrappedWorld.CreateRandomEnemy(location, size, RndGen);

            Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.Center()));

            if (LearningTaskHelpers.FlipCoin(RndGen))
            {
                WrappedWorld.CreateRandomFood(location2, size, RndGen);
            }
            else
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Example #4
0
        protected void CreateTeacher()
        {
            List <RogueTeacher.Actions> actions = new List <RogueTeacher.Actions>
            {
                RogueTeacher.GetRandomAction(m_rndGen, (int)TSHints[TSHintAttributes.DEGREES_OF_FREEDOM]),
                RogueTeacher.GetRandomAction(m_rndGen, (int)TSHints[TSHintAttributes.DEGREES_OF_FREEDOM]),
                RogueTeacher.GetRandomAction(m_rndGen, (int)TSHints[TSHintAttributes.DEGREES_OF_FREEDOM]),
                RogueTeacher.GetRandomAction(m_rndGen, (int)TSHints[TSHintAttributes.DEGREES_OF_FREEDOM]),
                RogueTeacher.GetRandomAction(m_rndGen, (int)TSHints[TSHintAttributes.DEGREES_OF_FREEDOM])
            };

            RectangleF restrcitedRectangle = WrappedWorld.GetPowGeometry();

            restrcitedRectangle = LearningTaskHelpers.ResizeRectangleAroundCentre(restrcitedRectangle, 0.8f);

            PointF teachersPoint;

            if ((int)TSHints[TEACHER_ON_DIFF_START_POSITION] != 0)
            {
                teachersPoint = WrappedWorld.RandomPositionInsideRectangleNonCovering(m_rndGen, RogueTeacher.GetDefaultSize(), restrcitedRectangle, 10);
            }
            else
            {
                teachersPoint = new PointF(m_agent.Position.X + WrappedWorld.Viewport.Width / 3, m_agent.Position.Y);
            }

            m_teacher = WrappedWorld.CreateTeacher(teachersPoint, actions) as RogueTeacher;
        }
Example #5
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            if (RndGen.Next(9) > 0)
            {
                SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

                PointF location = Positions.Center();

                if (LearningTaskHelpers.FlipCoin(RndGen))
                {
                    WrappedWorld.CreateRandomFood(location, size, RndGen);
                    Actions.Eat = true;
                }
                else
                {
                    WrappedWorld.CreateRandomStone(location, size, RndGen);
                }

                if (LearningTaskHelpers.FlipCoin(RndGen))
                {
                    PointF location2 = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size);
                    WrappedWorld.CreateRandomStone(location2, size, RndGen);
                }
            }

            WriteActions();
        }
Example #6
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            int       positionsCount    = Positions.Positions.Count;
            const int randomLocationIdx = 4;
            PointF    location          = Positions.Positions[randomLocationIdx];

            int    randomLocationIdx2 = (RndGen.Next(positionsCount - 1) + randomLocationIdx + 1) % positionsCount;
            PointF location2          = Positions.Positions[randomLocationIdx2];

            WrappedWorld.CreateRandomVeryGoodFood(location, size, RndGen);
            Actions.Eat = true;

            if (RndGen.Next(3) > 0)
            {
                Shape randomEnemy = WrappedWorld.CreateRandomEnemy(location2, size, RndGen);
                Actions.Eat      = false;
                Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.GetCenter()));
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomFood(location2, size, RndGen);
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Example #7
0
        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;
        }
Example #8
0
        protected bool[] MoveActionsToTarget(PointF locationCenter, PointF center)
        {
            bool[] moveActions = new bool[4];

            float  step = WrappedWorld.GetPowGeometry().Width / 16;
            PointF c    = locationCenter - new SizeF(center);

            if (c.X < -step)
            {
                moveActions[2] = true;
            }
            if (step < c.X)
            {
                moveActions[3] = true;
            }
            if (c.Y < -step)
            {
                moveActions[0] = true;
            }
            if (step < c.Y)
            {
                moveActions[1] = true;
            }

            return(moveActions);
        }
Example #9
0
        protected void AddShape()
        {
            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            Color color = Colors.GetRandomColor(RndGen);

            PointF location = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size);

            ShapeIndex = RndGen.Next(ScConstants.numShapes);
            Shape.Shapes randomShape = (Shape.Shapes)ShapeIndex;

            WrappedWorld.CreateShape(randomShape, color, location, size);
        }
Example #10
0
        protected override void AddShape(int randomLocationIndex)
        {
            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            Color color = Colors.GetRandomColor(RndGen, out ColorIndex);

            PointF location = Positions.Positions[randomLocationIndex];

            ShapeIndex = RndGen.Next(ScConstants.numShapes);
            Shape.Shapes randomShape = (Shape.Shapes)ShapeIndex;

            WrappedWorld.CreateShape(randomShape, color, location, size);

            GenerationsCheckTable[randomLocationIndex][ColorIndex] = true;
        }
Example #11
0
        protected Shape CreateTarget(int imageIndex)
        {
            SizeF size = new SizeF(15, 15);

            if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1f)
            {
                float a = (float)(10 + m_rand.NextDouble() * 15);
                size = new SizeF(a, a);
            }

            // positions are reduced to keep all objects in POW
            RectangleF r = WrappedWorld.GetPowGeometry();

            r.Location = new PointF(r.X + r.Width / 8, r.Y + r.Height / 8);
            r.Size     = new SizeF(r.Width * 3 / 4, r.Height * 3 / 4);
            PointF p = WrappedWorld.RandomPositionInsideRectangleNonCovering(m_rand, size, r, 10, 18);

            return(WrappedWorld.CreateShape((Shape.Shapes)imageIndex, Color.White, p, size, type: GameObjectType.NonColliding));
        }
Example #12
0
        public override void Init()
        {
            base.Init();
            InitCheckTable();
            Positions = new ScFixPositions(WrappedWorld.GetPowGeometry());
            Colors    = new ScFixColors(ScConstants.numColors, WrappedWorld.BackgroundColor);
            WrappedWorld.ImageNoiseStandardDeviation = 256.0f / ScConstants.numColors / 2;

            if (Directory.Exists(Path))
            {
                LtWritten = true;
            }
            else
            {
                Directory.CreateDirectory(Path);
                var path = Path + "labels.csv";
                File.Create(path).Close();
                OpenFileStream();
            }
        }
Example #13
0
        public override void PresentNewTrainingUnit()
        {
            WrappedWorld.CreateNonVisibleAgent();

            RectangleF leftPart  = WrappedWorld.GetPowGeometry();
            RectangleF rightPart = WrappedWorld.GetPowGeometry();
            SizeF      shift     = new SizeF(leftPart.Width / 2 + 4, 0);

            leftPart.Width  = leftPart.Width / 2 - 4;
            rightPart.Width = rightPart.Width / 2 - 2;
            rightPart.X    += rightPart.Width + 4;

            WrappedWorld.CreateShape(
                Shape.Shapes.Square,
                Color.Black,
                rightPart.Location - new SizeF(4, 0),
                new SizeF(4, leftPart.Height));

            int numberOfObjects = (int)TSHints[TSHintAttributes.NUMBER_OBJECTS];

            m_diffObjectetPlaced = m_rndGen.Next(2) == 0;

            for (int i = 0; i < numberOfObjects; i++)
            {
                SizeF size;
                if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1f)
                {
                    float a = (float)(10 + m_rndGen.NextDouble() * 10);
                    size = new SizeF(a, a);
                }
                else
                {
                    size = new SizeF(15, 15);
                }

                Color color;
                if (TSHints[TSHintAttributes.IS_VARIABLE_COLOR] >= 1f)
                {
                    color = LearningTaskHelpers.RandomVisibleColor(m_rndGen);
                }
                else
                {
                    color = Color.White;
                }

                Shape.Shapes shape = Shape.GetRandomShape(m_rndGen);

                PointF position = WrappedWorld.RandomPositionInsideRectangleNonCovering(m_rndGen, size, leftPart, 2);

                bool placeDifference = m_diffObjectetPlaced;

                if (!placeDifference || i != numberOfObjects - 1)
                {
                    WrappedWorld.CreateShape(shape, color, position, size);
                    WrappedWorld.CreateShape(shape, color, position + shift, size);
                }
                else
                {
                    PointF       positionR = position + shift;
                    Color        colorR    = color;
                    Shape.Shapes shapeR    = shape;
                    SizeF        sizeR     = size;

                    if (LearningTaskHelpers.FlipCoin(m_rndGen) && TSHints[TSHintAttributes.IS_VARIABLE_POSITION] >= 1.0f)
                    {
                        positionR       = WrappedWorld.RandomPositionInsideRectangleNonCovering(m_rndGen, size, rightPart, 2);
                        placeDifference = false;
                    }
                    if (LearningTaskHelpers.FlipCoin(m_rndGen) && TSHints[TSHintAttributes.IS_VARIABLE_COLOR] >= 1f)
                    {
                        colorR          = LearningTaskHelpers.RandomVisibleColor(m_rndGen);
                        placeDifference = false;
                    }
                    if (LearningTaskHelpers.FlipCoin(m_rndGen) && TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1f)
                    {
                        sizeR = size + new Size(5, 5);
                    }
                    if (placeDifference || LearningTaskHelpers.FlipCoin(m_rndGen))
                    {
                        shapeR = Shape.GetRandomShape(m_rndGen);
                    }

                    WrappedWorld.CreateShape(shape, color, position, size);
                    WrappedWorld.CreateShape(shapeR, colorR, positionR, sizeR);
                }
            }
        }