Esempio n. 1
0
        public override void ExecuteStep()
        {
            if (m_currentStep >= m_timeplan.Length)
            {
                return;
            }

            m_currentStep++;
            base.ExecuteStep();
            WrappedWorld.GameObjects.Clear();
            if (m_timeplan[m_currentStep] == TimeActions.GiveHint)
            {
                PointF p;

                if (TSHints[TSHintAttributes.IS_VARIABLE_POSITION] >= 1)
                {
                    p = WrappedWorld.RandomPositionInsideViewport(m_rndGen, m_size);
                }
                else
                {
                    p = m_p;
                }

                WrappedWorld.CreateShape(Shape.Shapes.Tent, Color.White, p, m_size);
            }
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        public override void PresentNewTrainingUnit()
        {
            m_p           = WrappedWorld.CreateNonVisibleAgent().GetGeometry().Location;
            m_currentStep = 0;

            int rest  = m_rndGen.Next(1, (int)TSHints[RHYTHM_MAX_SIZE] + 1);
            int delay = m_rndGen.Next(0, (int)TSHints[DELAY] + 1);

            m_timeplan        = new TimeActions[(rest + 1) * 3 + delay + 1];
            m_timeplan[delay] = TimeActions.GiveHint;
            m_timeplan[delay + (rest + 1)]     = TimeActions.GiveHint;
            m_timeplan[delay + (rest + 1) * 2] = TimeActions.AskAction;
            m_timeplan[delay + (rest + 1) * 3] = TimeActions.AskAction;

            m_size = new Size(20, 20);

            if (m_timeplan[0] == TimeActions.GiveHint)
            {
                PointF p;

                if (TSHints[TSHintAttributes.IS_VARIABLE_POSITION] >= 1)
                {
                    p = WrappedWorld.RandomPositionInsideViewport(m_rndGen, m_size);
                }
                else
                {
                    p = m_p;
                }

                WrappedWorld.CreateShape(Shape.Shapes.Tent, Color.White, p, m_size);
            }
        }
        // scale and position the target:
        private void CreateTarget()
        {
            SizeF size;
            float standardSideSize = WrappedWorld.Viewport.Width / 10;

            if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1)
            {
                float side = (float)(standardSideSize + m_rndGen.NextDouble() * standardSideSize);
                size = new SizeF(side, side);
            }
            else
            {
                size = new SizeF(standardSideSize, standardSideSize);
            }

            PointF position = WrappedWorld.RandomPositionInsideViewport(m_rndGen, size, -1);

            Shape.Shapes shape;
            switch (m_rndGen.Next(0, (int)TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS]))
            {
            case 0:
            default:
                shape = Shape.Shapes.Circle;
                break;

            case 1:
                shape = Shape.Shapes.Square;
                break;

            case 2:
                shape = Shape.Shapes.Triangle;
                break;

            case 3:
                shape = Shape.Shapes.Mountains;
                break;
            }

            Color color;

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

            m_target = WrappedWorld.CreateShape(shape, color, position, size);

            float distance    = m_target.CenterDistanceTo(m_agent);
            float w           = WrappedWorld.Viewport.Width / 2;
            float h           = WrappedWorld.Viewport.Height / 2;
            float maxDistance = (float)Math.Sqrt(w * w + h * h);

            m_distance = distance / maxDistance;
        }
Esempio n. 5
0
        protected void CreateTarget()
        {
            const int TARGET_SIZE = 32;
            SizeF     size        = new SizeF(TARGET_SIZE, TARGET_SIZE);
            PointF    location    = WrappedWorld.RandomPositionInsideViewport(m_rndGen, size);

            m_target = WrappedWorld.CreateGameObject(@"White10x10.png", location, size);
            // Plumber:
            //m_target.X = m_rndGen.Next(0, World.Scene.WidthFov - m_target.WidthFov + 1);
            //m_target.Y = World.Scene.HeightFov - m_target.HeightFov;
            // Roguelike:
            //m_target.X = m_rndGen.Next(0, WrappedWorld.Viewport.WidthFov - m_target.WidthFov + 1);
            //m_target.Y = m_rndGen.Next(0, WrappedWorld.Viewport.HeightFov - m_target.HeightFov + 1);
        }
Esempio n. 6
0
        // scale and position the target:
        protected void CreateTarget()
        {
            // the number of different sizes depends on level:
            int maxSide = (int)(Math.Max(WrappedWorld.Viewport.Width, WrappedWorld.Viewport.Height) * 0.9);

            float randomNumber = m_rndGen.Next(1, (int)TSHints[TARGET_SIZE_LEVELS] + 1);

            m_scale = randomNumber / TSHints[TARGET_SIZE_LEVELS];
            float side = maxSide * m_scale;

            //MyLog.Writer.WriteLine(maxSide);
            //MyLog.Writer.WriteLine(side);

            SizeF size = new SizeF(side, side);

            PointF position = WrappedWorld.RandomPositionInsideViewport(m_rndGen, size, -1);

            List <Shape.Shapes> shapes = new List <Shape.Shapes>();

            switch ((int)TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS])
            {
            case 3:
                shapes.Add(Shape.Shapes.Star);
                goto case 2;

            case 2:
                shapes.Add(Shape.Shapes.DoubleRhombus);
                goto case 1;

            case 1:
                shapes.Add(Shape.Shapes.Square);
                break;
            }
            Shape.Shapes shape = shapes[m_rndGen.Next(0, (int)TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS])];

            Color color;

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

            WrappedWorld.CreateShape(shape, color, position, size);
        }
Esempio n. 7
0
        public override void PresentNewTrainingUnit()
        {
            WrappedWorld.CreateNonVisibleAgent();
            WrappedWorld.IsWorldFrozen = true;

            // with Pr=.5 show object
            if (LearningTaskHelpers.FlipCoin(m_rndGen))
            {
                //random size
                SizeF shapeSize = new SizeF(32, 32);
                if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1.0f)
                {
                    float side = (float)(10 + m_rndGen.NextDouble() * 38);
                    shapeSize = new SizeF(side, side);
                }

                // random position
                PointF shapePosition = WrappedWorld.Agent.GetGeometry().Location + new Size(20, 0);
                if (TSHints[TSHintAttributes.IS_VARIABLE_POSITION] >= 1.0f)
                {
                    shapePosition = WrappedWorld.RandomPositionInsideViewport(m_rndGen, shapeSize, 2);
                }

                // random color
                Color shapeColor = Color.White;
                if (TSHints[TSHintAttributes.IS_VARIABLE_COLOR] >= 1.0f)
                {
                    shapeColor = LearningTaskHelpers.RandomVisibleColor(m_rndGen);
                }

                // random rotation
                float rotation = 0;
                if (TSHints[TSHintAttributes.IS_VARIABLE_ROTATION] >= 1.0f)
                {
                    rotation = (float)(m_rndGen.NextDouble() * 360);
                }

                m_target_type = Shape.GetRandomShape(m_rndGen, (int)TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS]);

                m_target = WrappedWorld.CreateShape(m_target_type, shapeColor, shapePosition, shapeSize, rotation);
            }
            else
            {
                m_target = null;
            }
        }
        public override void PresentNewTrainingUnit()
        {
            WrappedWorld.CreateNonVisibleAgent();

            m_appears = LearningTaskHelpers.FlipCoin(m_rndGen);
            if (!m_appears)
            {
                return;
            }

            SizeF size;

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

            PointF position;

            if (TSHints[IS_TARGET_MOVING] >= 1)
            {
                position = WrappedWorld.RandomPositionInsideViewport(m_rndGen, size);
            }
            else
            {
                position = WrappedWorld.Agent.GetGeometry().Location;
            }

            m_isBlack = LearningTaskHelpers.FlipCoin(m_rndGen);
            Color color = m_isBlack ? Color.Black : Color.White;

            WrappedWorld.CreateShape(Shape.Shapes.Square, color, position, size);
        }
        public override void PresentNewTrainingUnit()
        {
            WrappedWorld.CreateNonVisibleAgent();

            //random size
            SizeF  shapeSize     = new SizeF(120, 120);
            PointF shapePosition = new PointF(WrappedWorld.Scene.Width / 2, WrappedWorld.Scene.Height / 2);
            Color  shapeColor    = Color.White;
            float  rotation      = 0;

            Shape nthShape = m_lastNShapes[m_lastNShapes.Length - 2];   // check N steps back, but current is not pushed, so it is N - 1

            if (nthShape != null && m_rndGen.NextDouble() < 0.5)
            {
                // with probability 0.5 copy the same
                shapeSize       = new SizeF(nthShape.Size.Width, nthShape.Size.Height);
                shapePosition.X = nthShape.Position.X;
                shapePosition.Y = nthShape.Position.Y;
                shapeColor      = nthShape.ColorMask;
                rotation        = nthShape.Rotation;
                m_target_type   = nthShape.ShapeType;
            }
            else
            {
                // with probability 0.5 create a random new one

                // generate random size
                if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1.0f)
                {
                    int side = m_rndGen.Next(60, 121);
                    shapeSize = new Size(side, side);
                }

                // random position
                shapePosition.X -= shapeSize.Width / 2;
                shapePosition.Y -= shapeSize.Height / 2;

                if (TSHints[TSHintAttributes.IS_VARIABLE_POSITION] >= 1.0f)
                {
                    shapePosition = WrappedWorld.RandomPositionInsideViewport(m_rndGen, shapeSize);
                }

                // random color
                if (TSHints[TSHintAttributes.IS_VARIABLE_COLOR] >= 1.0f)
                {
                    shapeColor = LearningTaskHelpers.RandomVisibleColor(m_rndGen);
                }

                // random rotation
                if (TSHints[TSHintAttributes.IS_VARIABLE_ROTATION] >= 1.0f)
                {
                    rotation = (float)(m_rndGen.NextDouble() * 360);
                }

                // random shape
                m_target_type = Shape.GetRandomShape(m_rndGen, (int)TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS]);
            }

            m_target = (Shape)WrappedWorld.CreateShape(m_target_type, shapeColor, shapePosition, shapeSize, rotation);

            Push(m_target);
        }
        public override void PresentNewTrainingUnit()
        {
            int numberOfObjects = (int)TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS];
            List <Shape.Shapes> positiveExamplesRed = new List <Shape.Shapes>();
            List <Shape.Shapes> negativeExamplesRed = new List <Shape.Shapes>();

            for (int i = 0; i < numberOfObjects / 2; i++)
            {
                positiveExamplesRed.Add(m_positiveExamples[i]);
                negativeExamplesRed.Add(m_negativeExamples[i]);
            }

            WrappedWorld.CreateNonVisibleAgent();

            SizeF size;
            float standardSideSize = WrappedWorld.Viewport.Width / 10;

            if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1.0f)
            {
                float a = (float)(standardSideSize + m_rndGen.NextDouble() * standardSideSize);
                size = new SizeF(a, a);
            }
            else
            {
                size = new SizeF(standardSideSize, standardSideSize);
            }

            Color color;

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

            PointF position;

            if (TSHints[TSHintAttributes.IS_VARIABLE_POSITION] >= 1.0f)
            {
                position = WrappedWorld.RandomPositionInsideViewport(m_rndGen, size);
            }
            else
            {
                position = WrappedWorld.Agent.GetGeometry().Location;
            }

            m_positiveExamplePlaced = LearningTaskHelpers.FlipCoin(m_rndGen);

            Shape.Shapes shape;
            if (m_positiveExamplePlaced)
            {
                int randShapePointer = m_rndGen.Next(0, positiveExamplesRed.Count);
                shape = positiveExamplesRed[randShapePointer];
            }
            else
            {
                int randShapePointer = m_rndGen.Next(0, negativeExamplesRed.Count);
                shape = negativeExamplesRed[randShapePointer];
            }

            WrappedWorld.CreateShape(shape, color, position, size);
        }
Esempio n. 11
0
        public override void PresentNewTrainingUnit()
        {
            m_agent = WrappedWorld.CreateNonVisibleAgent();

            SizeF size;

            if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1)
            {
                float side = (float)(8 + m_rndGen.NextDouble() * 16);
                size = new SizeF(side, side);
            }
            else
            {
                int side = 10;
                size = new Size(side, side);
            }

            PointF position;
            float  radius = Math.Min(WrappedWorld.Viewport.Height, WrappedWorld.Viewport.Width) / 3;

            if (TSHints[FIXED_DISTANCE] >= 1)
            {
                double angle = m_rndGen.NextDouble() * Math.PI * 2;
                position  = new PointF((float)(Math.Cos(angle) * radius), (float)(Math.Sin(angle) * radius));
                position += new SizeF(m_agent.Position.X, m_agent.Position.Y);
            }
            else
            {
                position = WrappedWorld.RandomPositionInsideViewport(m_rndGen, size);
            }

            Shape.Shapes shape;
            if (TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS] >= 1)
            {
                switch (m_rndGen.Next(0, 4))
                {
                case 0:
                default:
                    shape = Shape.Shapes.Circle;
                    break;

                case 1:
                    shape = Shape.Shapes.Square;
                    break;

                case 2:
                    shape = Shape.Shapes.Triangle;
                    break;

                case 3:
                    shape = Shape.Shapes.Mountains;
                    break;
                }
            }
            else
            {
                shape = Shape.Shapes.Circle;
            }

            Color color;

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

            m_target = WrappedWorld.CreateShape(shape, color, position, size);
        }