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 randomVeryGoodFood = WrappedWorld.CreateRandomVeryGoodFood(location, size, RndGen); Actions.Movement = MoveActionsToTarget(randomVeryGoodFood.Center()); PointF location2 = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size); if (RndGen.Next(3) > 0) { Shape randomEnemy = WrappedWorld.CreateRandomEnemy(location2, size, RndGen); Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.Center())); } else if (RndGen.Next(3) > 0) { WrappedWorld.CreateRandomFood(location2, size, RndGen); } else if (RndGen.Next(3) > 0) { WrappedWorld.CreateRandomStone(location2, size, RndGen); } WriteActions(); }
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(); }
// Get a target location private PointF GetRandomLocation(SizeF size) { // Need to separate objects enough so that even large objects do not touch when // rotated. const int OBJECT_MARGIN = 10; return(WrappedWorld.RandomPositionInsidePowNonCovering(m_rand, size, OBJECT_MARGIN)); }
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 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); }
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); } } }