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(); }
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(); }
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(); }
public override void PresentNewTrainingUnit() { if (LearningTaskHelpers.FlipCoin(m_rndGen)) { WrappedWorld.CreateNonVisibleAgent(); CreateTarget(); } else { m_target = null; } }
// 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); }
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(); 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); } } }
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); }