Esempio n. 1
0
        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;
            const int randomLocationIdx = 4;
            PointF    location          = Positions.Positions[randomLocationIdx];

            int    randomLocationIdx2 = (RndGen.Next(positionsCount - 1) + randomLocationIdx + 1) % positionsCount;
            PointF location2          = Positions.Positions[randomLocationIdx2];

            WrappedWorld.CreateRandomVeryGoodFood(location, size, RndGen);
            Actions.Eat = true;

            if (RndGen.Next(3) > 0)
            {
                Shape randomEnemy = WrappedWorld.CreateRandomEnemy(location2, size, RndGen);
                Actions.Eat      = false;
                Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.GetCenter()));
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomFood(location2, size, RndGen);
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Esempio n. 2
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            int    positionsWcCount  = Positions.PositionsWithoutCenter.Count;
            int    randomLocationIdx = RndGen.Next(positionsWcCount);
            PointF location          = Positions.PositionsWithoutCenter[randomLocationIdx];

            int    randomLocationIdx2 = (RndGen.Next(positionsWcCount - 1) + randomLocationIdx + 1) % positionsWcCount;
            PointF location2          = Positions.PositionsWithoutCenter[randomLocationIdx2];

            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                Shape randomFood = WrappedWorld.CreateRandomFood(location, size, RndGen);
                Actions.Movement = MoveActionsToTarget(randomFood.GetCenter());
            }
            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
        protected void CreateObject(int color)
        {
            m_currentObject = new Shape(Shape.Shapes.Square, new PointF(0f, 0f), new SizeF(WrappedWorld.Scene.Width, WrappedWorld.Scene.Height));
            WrappedWorld.AddGameObject(m_currentObject);

            SetObjectColor(color);
        }
Esempio n. 5
0
        public override void PresentNewTrainingUnit()
        {
            m_p           = WrappedWorld.CreateNonVisibleAgent().GetGeometry().Location;
            m_currentStep = 0;

            int rest  = m_rndGen.Next(1, (int)TSHints[RHYTHM_MAX_SIZE] + 1);
            int delay = m_rndGen.Next(0, (int)TSHints[DELAY] + 1);

            m_timeplan        = new TimeActions[(rest + 1) * 3 + delay + 1];
            m_timeplan[delay] = TimeActions.GiveHint;
            m_timeplan[delay + (rest + 1)]     = TimeActions.GiveHint;
            m_timeplan[delay + (rest + 1) * 2] = TimeActions.AskAction;
            m_timeplan[delay + (rest + 1) * 3] = TimeActions.AskAction;

            m_size = new Size(20, 20);

            if (m_timeplan[0] == TimeActions.GiveHint)
            {
                PointF p;

                if (TSHints[TSHintAttributes.IS_VARIABLE_POSITION] >= 1)
                {
                    p = WrappedWorld.RandomPositionInsideViewport(m_rndGen, m_size);
                }
                else
                {
                    p = m_p;
                }

                WrappedWorld.CreateShape(Shape.Shapes.Tent, Color.White, p, m_size);
            }
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        public override void ExecuteStep()
        {
            if (m_currentStep >= m_timeplan.Length)
            {
                return;
            }

            m_currentStep++;
            base.ExecuteStep();
            WrappedWorld.GameObjects.Clear();
            if (m_timeplan[m_currentStep] == TimeActions.GiveHint)
            {
                PointF p;

                if (TSHints[TSHintAttributes.IS_VARIABLE_POSITION] >= 1)
                {
                    p = WrappedWorld.RandomPositionInsideViewport(m_rndGen, m_size);
                }
                else
                {
                    p = m_p;
                }

                WrappedWorld.CreateShape(Shape.Shapes.Tent, Color.White, p, m_size);
            }
        }
Esempio n. 8
0
        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);
        }
        public void GenerateObstacles()
        {
            WrappedWorld.CreateAgent();                                                         // Generate agent
            m_agent = WrappedWorld.Agent;

            m_target = WrappedWorld.CreateTarget(new Point(0, 0));
            WrappedWorld.AddGameObject(m_target);

            RoguelikeWorld world = WrappedWorld as RoguelikeWorld;                              // Reference to World
            Grid           g     = world.GetGrid();                                             // Get grid

            TSHints[TIMESTEPS_LIMIT] = 200;

            int widthOfRectangle  = 3;
            int heightOfRectangle = 2;

            createWallRectangleWithFillProbability(world, m_rndGen, 5, 5, widthOfRectangle, heightOfRectangle, 0.8f, 1.0f);

            // Position agent
            m_agent.Position.X = 200;
            m_agent.Position.Y = 193;

            // Position target
            m_target.Position.X = m_rndGen.Next(160, 280);

            if (m_rndGen.Next(0, 2) == 0)
            {
                m_target.Position.Y = 120;
            }
            else
            {
                m_target.Position.Y = 270;
            }
        }
Esempio n. 10
0
        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();
        }
Esempio n. 11
0
        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();
        }
Esempio n. 12
0
        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();
        }
Esempio n. 13
0
        public virtual void CreateTarget()
        {
            float scaleFactor = 1;

            if (TSHints[TSHintAttributes.IS_VARIABLE_SIZE] >= 1)
            {
                scaleFactor = (float)m_rndGen.NextDouble() * 0.7f + 0.8f;
            }

            m_target = WrappedWorld.CreateTarget(new Point(0, 0), scaleFactor);

            PointF p;

            if ((int)TSHints[TSHintAttributes.DEGREES_OF_FREEDOM] == 1)
            {
                RectangleF POW = WrappedWorld.GetPowGeometry();
                POW.Location = new PointF(POW.X, POW.Y + POW.Height / 2 - m_agent.Size.Height);
                POW.Size     = new SizeF(POW.Width, m_agent.Size.Height * 2);
                p            = WrappedWorld.RandomPositionInsideRectangleNonCovering(m_rndGen, m_target.GetGeometry().Size, POW, 5, 20);
            }
            else
            {
                p = WrappedWorld.RandomPositionInsideViewport(m_rndGen, m_target.GetGeometry().Size, 20);
            }

            m_target.Position = p;
        }
Esempio n. 14
0
 protected void CreateAgent()
 {
     WrappedWorld.CreateAgent();
     m_agent             = WrappedWorld.Agent;
     m_agent.Position.X -= m_agent.Size.Width / 2;
     m_agent.Position.Y -= m_agent.Size.Height / 2;
 }
Esempio n. 15
0
        protected bool[] MoveActionsToTarget(PointF locationCenter, PointF center)
        {
            bool[] moveActions = new bool[4];

            float  step = WrappedWorld.GetPowGeometry().Width / 16;
            PointF c    = locationCenter - new SizeF(center);

            if (c.X < -step)
            {
                moveActions[2] = true;
            }
            if (step < c.X)
            {
                moveActions[3] = true;
            }
            if (c.Y < -step)
            {
                moveActions[0] = true;
            }
            if (step < c.Y)
            {
                moveActions[1] = true;
            }

            return(moveActions);
        }
Esempio n. 16
0
        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);
            }
        }
        // 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));
        }
Esempio n. 18
0
 private void CreateAgent()
 {
     WrappedWorld.CreateAgent(null);
     m_agent = WrappedWorld.Agent;
     // center the agent
     m_agent.Position.X = WrappedWorld.Scene.Width / 2 - m_agent.Size.Width / 2;
     m_agent.Position.Y = WrappedWorld.Scene.Height / 2 - m_agent.Size.Height / 2;
 }
        protected void CreateAgent()
        {
            WrappedWorld.CreateAgent();
            m_agent = WrappedWorld.Agent;

            m_agent.Position.X = WrappedWorld.Scene.Width / 2;
            m_agent.Position.Y = WrappedWorld.Scene.Height / 2;
        }
Esempio n. 20
0
        // 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;
        }
Esempio n. 21
0
        public override void PresentNewTrainingUnit()
        {
            /*if (WrappedWorld.GetType() == typeof(PlumberWorld))
             * {
             *  m_agent = new MovableGameObject(@"Plumber24x28.png", new PointF(24, 28), type: GameObjectType.Agent);
             *  PlumberWorld world = WrappedWorld as PlumberWorld;
             *  m_target = new GameObject(@"Coin16x16.png", new PointF(200, 200), type: GameObjectType.NonColliding);
             *  world.AddGameObject(m_target);
             *
             *  GameObject obj1 = new GameObject(@"Block60x10.png", new PointF(10, 260));
             *  GameObject obj2 = new GameObject(@"Block60x10.png", new PointF(100, 250));
             *  GameObject obj3 = new GameObject(@"Block5x120.png", new PointF(200, 100));
             *  GameObject obj4 = new GameObject(@"Block60x10.png", new PointF(300, 200));
             *
             *  world.AddGameObject(obj1);
             *  world.AddGameObject(obj2);
             *  world.AddGameObject(obj3);
             *  world.AddGameObject(obj4);
             * }
             * else*/if (WrappedWorld.GetType() == typeof(RoguelikeWorld))
            {
                RoguelikeWorld world = WrappedWorld as RoguelikeWorld;
                world.DegreesOfFreedom = 2;

                // create agent
                m_agent = world.CreateAgent();

                // get grid
                Grid g = world.GetGrid();

                // place objects according to the grid
                world.CreateWall(g.GetPoint(12, 17));
                m_agent.Position = g.GetPoint(15, 16);
                world.CreateWall(g.GetPoint(15, 17));
                world.CreateWall(g.GetPoint(16, 17));
                world.CreateWall(g.GetPoint(17, 17));
                world.CreateWall(g.GetPoint(17, 18));

                // place new wall with random position and size (1 - 3 times larger than default)
                GameObject wall = world.CreateWall(g.GetPoint(0, 0), (float)(1 + m_rndGen.NextDouble() * 2));
                // GetRandomPositionInsidePow avoids covering agent
                PointF randPosition = world.RandomPositionInsideViewport(m_rndGen, wall.GetGeometry().Size);
                wall.Position = randPosition;

                // create target
                m_target = world.CreateTarget(g.GetPoint(18, 18));

                // create shape
                world.CreateShape(// position
                    // Type determine interactions
                    // uses texture shape as mask
                    Shape.Shapes.Star, Color.Cyan, g.GetPoint(11, 13), new SizeF(30, 30), 60, GameObjectType.Obstacle); // you can resize choosen shape

                RogueDoor door = (RogueDoor)world.CreateDoor(g.GetPoint(13, 17), size: 2f);
                world.CreateLever(g.GetPoint(13, 13), door);
            }
        }
        // Create a shape
        protected ComparisonShape CreateTarget(ComparisonShape.Shapes shape)
        {
            SizeF           size     = GetSize(TSHints[SCALE_SHAPE] == 1);
            PointF          location = GetRandomLocation(size);
            float           rotation = GetRotation(TSHints[ROTATE_SHAPE] == 1);
            ComparisonShape target   = new ComparisonShape(shape, location, size, rotation);

            WrappedWorld.AddGameObject(target);
            return(target);
        }
Esempio n. 23
0
        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);
            }
        }
Esempio n. 24
0
 public override void PresentNewTrainingUnit()
 {
     if (LearningTaskHelpers.FlipCoin(m_rndGen))
     {
         WrappedWorld.CreateNonVisibleAgent();
         CreateTarget();
     }
     else
     {
         m_target = null;
     }
 }
Esempio n. 25
0
        public override void PresentNewTrainingUnit()
        {
            WrappedWorld.CreateAgent();
            condition = new ConditionGameObject(WrappedWorld, TSHints[MOVING_CONDITION] == 1, TSHints[CONDITION_SALIENCE]);
            ConditionalTarget blackConditionTarget = CreateTarget(/* isWhiteConditionalTarget: */ false);
            ConditionalTarget whiteConditionTarget = CreateTarget(/* isWhiteConditionalTarget: */ true);

            dummyTarget         = condition.IsWhite ? blackConditionTarget : whiteConditionTarget;
            rewardTarget        = condition.IsWhite ? whiteConditionTarget : blackConditionTarget;
            stepsSincePresented = 0;
            initialDistance     = WrappedWorld.Agent.DistanceTo(rewardTarget);
        }
 public override void PresentNewTrainingUnit()
 {
     WrappedWorld.CreateNonVisibleAgent();
     targetA = CreateTarget(ComparisonShape.GetRandomShape(m_rand, (int)TSHints[NUMBER_OF_DIFFERENT_OBJECTS]));
     if (GuaranteePositiveExample())
     {
         targetB = CreateTarget(targetA.Shape);
     }
     else
     {
         targetB = CreateTarget(ComparisonShape.GetRandomShape(m_rand, (int)TSHints[NUMBER_OF_DIFFERENT_OBJECTS]));
     }
 }
Esempio n. 27
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);
        }
        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);
                }
            }
        }
Esempio n. 29
0
        public override void ExecuteStepAfterEvaluation()
        {
            if (m_currentObject != null)
            {
                WrappedWorld.RemoveGameObject(m_currentObject);
            }

            FiniteTransducerTransition t = m_ft.pickNextTransitionRandomly();

            m_ft.UseTransition(t);
            m_lastTransition = t;

            DisplayLastTransitionSymbol();
        }
Esempio n. 30
0
        protected void CreateTarget()
        {
            const int TARGET_SIZE = 32;
            SizeF     size        = new SizeF(TARGET_SIZE, TARGET_SIZE);
            PointF    location    = WrappedWorld.RandomPositionInsideViewport(m_rndGen, size);

            m_target = WrappedWorld.CreateGameObject(@"White10x10.png", location, size);
            // Plumber:
            //m_target.X = m_rndGen.Next(0, World.Scene.WidthFov - m_target.WidthFov + 1);
            //m_target.Y = World.Scene.HeightFov - m_target.HeightFov;
            // Roguelike:
            //m_target.X = m_rndGen.Next(0, WrappedWorld.Viewport.WidthFov - m_target.WidthFov + 1);
            //m_target.Y = m_rndGen.Next(0, WrappedWorld.Viewport.HeightFov - m_target.HeightFov + 1);
        }