public virtual void CreateTargets(int noObjects, PointF center) { SizeF centerSz = new SizeF(center); // Is Size because there is no overload for +(Point,Point)........ // Pick random unique shapes from the available pool Resize(ref m_shapeIdcs, noObjects); int shapeCount = Enum.GetValues(typeof(Shape.Shapes)).Length; // noObjects must be at most shapeCount MyCombinationBase.GenerateCombinationUnique(new ArraySegment <float>(m_shapeIdcs), m_candidates, 0, shapeCount, m_rndGen); // Setup initial shape's positional parameters float step = (float)(2 * Math.PI / noObjects); // rads float angle = TSHints[TSHintAttributes.IS_VARIABLE_POSITION] > 0 ? (float)(m_rndGen.NextDouble() * step) : 0; float distance = Math.Min(WrappedWorld.Viewport.Width, WrappedWorld.Viewport.Height) / 3f; Resize(ref m_targets, noObjects); for (int i = 0; i < m_targets.Length; i++) { // Determine shape position if (TSHints[IS_VARIABLE_DISTANCE] > 0) { distance *= 1 + 0.04f * LearningTaskHelpers.GetRandomGaussian(m_rndGen) * TSHints[RANDOMNESS_LEVEL]; } PointF pos = new PointF((float)(Math.Cos(angle) * distance), (float)(Math.Sin(angle) * distance)); // Determine shape size float scale = 1.4f; if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] > 0) { scale = scale + 0.2f * LearningTaskHelpers.GetRandomGaussian(m_rndGen) * TSHints[RANDOMNESS_LEVEL]; } SizeF size = new SizeF(16 * scale, 16 * scale); // Determine shape rotation float rotation = 0; if (TSHints[TSHintAttributes.IS_VARIABLE_ROTATION] > 0) { rotation = (float)(m_rndGen.NextDouble() * 360); } // Determine shape color Color color = Color.White; if (TSHints[TSHintAttributes.IS_VARIABLE_COLOR] > 0) { color = LearningTaskHelpers.RandomVisibleColor(m_rndGen); } // Create the correct shape m_targets[i] = WrappedWorld.CreateShape((Shape.Shapes)m_shapeIdcs[i], color, pos + centerSz, size, rotation); angle += step; } }
public override void ExecuteStepBeforeEvaluation() { if (m_object != null) { WrappedWorld.RemoveGameObject(m_object); } if (m_currentObjectType == ObjectType.BeforeTarget) { NextTargetAction(m_targetWithAction); CreateObject(ObjectType.Target); m_targetsShown++; } else if (LearningTaskHelpers.FlipBiasedCoin(m_rndGen, 0.33f)) { if (LearningTaskHelpers.FlipBiasedCoin(m_rndGen, 0.5f)) { NextTargetAction(false); CreateObject(ObjectType.BeforeTarget); } else { NextTargetAction(m_targetWithAction); CreateObject(ObjectType.Target); m_targetsShown++; } } else { NextTargetAction(true); CreateObject(ObjectType.Empty); } }
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 randomEnemy = WrappedWorld.CreateRandomEnemy(location, size, RndGen); Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.GetCenter())); PointF location2 = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size); if (LearningTaskHelpers.FlipCoin(RndGen)) { WrappedWorld.CreateRandomFood(location2, size, RndGen); } else { WrappedWorld.CreateRandomStone(location2, size, RndGen); } WriteActions(); }
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; }
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(); }
public override void PresentNewTrainingUnit() { m_stepCount = 0; // Scale the noise in the world base on randomness_level { float randomness = TSHints[RANDOMNESS_LEVEL]; WrappedWorld.ImageNoiseStandardDeviation = 7 * randomness * randomness; } int noObjects = (int)TSHints[TSHintAttributes.NUMBER_OF_DIFFERENT_OBJECTS]; // Generate an artificial invisible agent m_agent = WrappedWorld.CreateNonVisibleAgent(); PointF agentPos = m_agent.GetGeometry().Location; m_agent.GameObjectStyle = GameObjectStyleType.None; // Prevent reseting movement vector when colliding with something from the top (default style is Platformer) // Generate shapes around the agent CreateTargets(noObjects, agentPos); // Pick one target and duplicate it in the pow center m_pickIdx = m_rndGen.Next(noObjects); var pick = m_targets[m_pickIdx]; Color color = TSHints[TSHintAttributes.IS_VARIABLE_COLOR] > 0 ? LearningTaskHelpers.RandomVisibleColor(m_rndGen) : pick.ColorMask; m_question = WrappedWorld.CreateShape((Shape.Shapes)m_shapeIdcs[m_pickIdx], color, agentPos, pick.Size); }
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(); }
// 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; }
protected void SetTargetColor(int colorIndex) { m_object.IsBitmapAsMask = true; Color color = LearningTaskHelpers.GetVisibleGrayscaleColor(colorIndex); m_object.ColorMask = Color.FromArgb( AddRandomColorOffset(color.R), AddRandomColorOffset(color.G), AddRandomColorOffset(color.B)); }
public override void PresentNewTrainingUnit() { WrappedWorld.CreateNonVisibleAgent(); int numberOfObjects = (int)TSHints[TSHintAttributes.NUMBER_OBJECTS]; m_sameObjectetPlaced = m_rndGen.Next(2) == 0; bool placeSameObject = m_sameObjectetPlaced; if (m_sameObjectetPlaced) { numberOfObjects--; } int numberOfShapes = Enum.GetValues(typeof(Shape.Shapes)).Length; List <int> uniqueNumbers = LearningTaskHelpers.UniqueNumbers(m_rndGen, 0, numberOfShapes, numberOfObjects); List <Shape.Shapes> shapes = uniqueNumbers.Select(x => (Shape.Shapes)x).ToList(); foreach (Shape.Shapes shape in shapes) { SizeF s; if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1f) { float a = (float)(10 + m_rndGen.NextDouble() * 10); s = new SizeF(a, a); } else { s = new Size(15, 15); } Color color; if (TSHints[TSHintAttributes.IS_VARIABLE_COLOR] >= 1) { color = LearningTaskHelpers.RandomVisibleColor(m_rndGen); } else { color = Color.White; } PointF position; if (placeSameObject) { placeSameObject = false; position = WrappedWorld.RandomPositionInsidePowNonCovering(m_rndGen, s, 2); WrappedWorld.CreateShape(shape, color, position, s); } position = WrappedWorld.RandomPositionInsidePowNonCovering(m_rndGen, s, 2); WrappedWorld.CreateShape(shape, color, position, s); } }
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)); }
public override void PresentNewTrainingUnit() { if (LearningTaskHelpers.FlipCoin(m_rndGen)) { WrappedWorld.CreateNonVisibleAgent(); CreateTarget(); } else { m_target = null; } }
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); } } }
// Instantiates and installs the condition public ConditionGameObject(ManInWorld world, bool movingCondition, float salience) : base(Shapes.Square, PointF.Empty) { IsBitmapAsMask = true; IsWhite = LearningTaskHelpers.FlipCoin(m_rand); m_colorMask = IsWhite ? Color.White : Color.Black; float size1D = DetermineSize(salience); PointF location = PickLocation(world, movingCondition, new SizeF(size1D, size1D)); Position = location; Size.Height = Size.Width = size1D; world.AddGameObject(this); }
// 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); }
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 ExecuteStepBeforeEvaluation() { if (m_object != null) { WrappedWorld.RemoveGameObject(m_object); } if (LearningTaskHelpers.FlipBiasedCoin(m_rndGen, 0.33f)) { //WrappedWorld.CreateNonVisibleAgent(); CreateObject(ObjectType.Target); m_targetsShown++; } else { CreateObject(ObjectType.Empty); } }
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() { 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); }
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); }
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); }
private static int GetSize(float targetSizeStandardDeviation) { const int DEFAULT_SIZE = 32; int size = DEFAULT_SIZE; if (targetSizeStandardDeviation != 0) { float scalingFactor = (float)Math.Pow(2, targetSizeStandardDeviation * LearningTaskHelpers.GetRandomGaussian(m_rand)); size = (int)(scalingFactor * size); } return(size); }
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); } } }