Ejemplo n.º 1
0
        public void SetTool(Shape.Shapes shape)
        {
            AttachParameter(Parameters.Tool, (int)shape);
            var key = Globals.Root.CurrentConfig.GetFirstKeyForAction(new ToolAction(shape));

            if (Utilities.Key_Shortcuts_Safe())
            {
                ShortcutDisplay = GUIUtilities.KeyShortDescription(key);
            }
        }
Ejemplo n.º 2
0
        public bool ShapeEnabled(Shape.Shapes shape)
        {
            var key = Config.ShapeEnableKey(shape);

            if (Configurations[0].ReadBooleanEx(Config.Shapes_DefaultOff))
            {
                return(Configurations[0].ReadBooleanEx(key));
            }
            return(ReadBoolean(key, true));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public override void PresentNewTrainingUnit()
        {
            WrappedWorld.CreateNonVisibleAgent();

            int        numberOfShapes = Enum.GetValues(typeof(Shape.Shapes)).Length;
            List <int> uniqueCouple   = LearningTaskHelpers.UniqueNumbers(m_rndGen, 0, numberOfShapes, 2);

            Shape.Shapes standardShape    = (Shape.Shapes)uniqueCouple[0];
            Shape.Shapes alternativeShape = (Shape.Shapes)uniqueCouple[1];

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

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

            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 Size(15, 15);
                }

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

                PointF position = WrappedWorld.RandomPositionInsidePowNonCovering(m_rndGen, size);

                if (placeDifferentObj)
                {
                    placeDifferentObj = false;
                    WrappedWorld.CreateShape(alternativeShape, color, position, size);
                }
                else
                {
                    WrappedWorld.CreateShape(standardShape, color, position, size);
                }
            }
        }
Ejemplo n.º 5
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;
        }
Ejemplo 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);
        }
Ejemplo 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;
            }
        }
Ejemplo n.º 8
0
        /// <summary>Factory method must be used for construction, to ensure correct type is used.  Derived types can be constructed directly </summary>
        public static Action Create(Parameters parameter, string value)
        {
            switch (parameter)
            {
            case Parameters.None:
            case Parameters.Undefined: return(new NullAction());

            case Parameters.Action_Verb: return(Verb.Find((Codes)Enum.Parse(typeof(Codes), value)));

            case Parameters.Action_Key: return(new KeyAction((Keys)int.Parse(value)));

            case Parameters.Action_Character: return(new CharAction(value[0]));

            case Parameters.Action_Text: return(new TextAction(value));

            case Parameters.Tool:
                Shape.Shapes shape = (Shape.Shapes)Utilities.IntVal(value);
                return(new ToolAction(shape));

            case Parameters.Action_Palette: return(new PaletteAction(value));

            case Parameters.Action_Palette_Button: return(new PaletteButtonAction(Utilities.IntVal(value)));

            case Parameters.Action_ShowPalette: return(new ShowPaletteAction(value));

            case Parameters.Action_Snap: return(new SnapAction((Shape.SnapModes)Utilities.IntVal(value)));

            case Parameters.Action_ShowGrid: return(new ShowGridAction(Utilities.IntVal(value)));

            default:
                if (parameter >= Parameters.None)
                {
                    return(new ParameterAction(parameter, Utilities.IntVal(value)));
                }
                Utilities.LogSubError($"Unknown parameter code: ({(int)parameter})");
                return(new NullAction());
            }
        }
Ejemplo n.º 9
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);
                }
            }
        }
Ejemplo n.º 10
0
 public static Action CreateForShape(Shape.Shapes shape, bool transient) => Create(Parameters.Tool, ((int)shape).ToString());
Ejemplo n.º 11
0
 public ToolAction(Shape.Shapes tool) : base(Parameters.Tool)
 {
     Tool = tool;
 }
Ejemplo n.º 12
0
        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);
        }