Ejemplo n.º 1
0
        protected void SetTargetColor()
        {
            m_target.IsBitmapAsMask = true;

            m_colorIndex = m_rndGen.Next((int)TSHints[NUMBER_OF_COLORS]);
            Color color = LearningTaskHelpers.GetVisibleColor(m_colorIndex);

            m_target.ColorMask = Color.FromArgb(
                AddRandomColorOffset(color.R),
                AddRandomColorOffset(color.G),
                AddRandomColorOffset(color.B));
        }
Ejemplo n.º 2
0
        public override void PresentNewTrainingUnit()
        {
            WrappedWorld.CreateNonVisibleAgent();

            // wtih 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
                m_colorIdx = m_rndGen.Next((int)TSHints[COLOR_COUNT]);
                Color shapeColor = LearningTaskHelpers.GetVisibleColor(m_colorIdx);

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

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

                m_target = WrappedWorld.CreateShape(shape, shapeColor, shapePosition, shapeSize, rotation);
            }
            else
            {
                m_target = null;
            }
        }