Exemple #1
0
        private List <ObservationSpaceRow> CreateRowControls(IMaze maze)
        {
            int position  = 0;
            int rowNumber = 0;
            List <ObservationSpaceRow> rows = new List <ObservationSpaceRow>();

            for (int i = 0; i < maze.Rows; i++)
            {
                var row = new ObservationSpaceRow();
                row.SetRowNumber(rowNumber);

                for (int j = 0; j < maze.Columns; j++)
                {
                    var space = new ObservationSpace();
                    space.SetPosition(position);

                    if (position == maze.GetInitialState())
                    {
                        space.SetStart(true);
                        space.SetActive();
                        space.Invalidate();
                    }

                    if (position == maze.GoalPosition)
                    {
                        space.SetGoal(true);
                    }

                    var customReward = maze.GetAdditionalRewards().Where(x => x.State == position).FirstOrDefault();

                    if (customReward != null)
                    {
                        space.SetReward(true, customReward.Value);
                    }

                    DrawWalls(maze, position, space);

                    row.AddSpace(space);
                    space.BorderStyle = BorderStyle.FixedSingle;
                    space.Dock        = DockStyle.Left;
                    space.BringToFront();

                    position++;
                }

                rows.Add(row);
                rowNumber++;
            }

            return(rows);
        }
Exemple #2
0
        private void DrawWalls(IMaze maze, int position, ObservationSpace space)
        {
            var walls = maze.Obstructions.Where(x => x.BetweenSpace == position || x.AndSpace == position);

            foreach (var wall in walls)
            {
                if (position == wall.BetweenSpace)
                {
                    DrawWalls(position, wall.AndSpace, space);
                }
                else
                {
                    DrawWalls(position, wall.BetweenSpace, space);
                }
            }
        }
Exemple #3
0
 private void DrawWalls(int currentSpace, int otherSpace, ObservationSpace space)
 {
     if (currentSpace == otherSpace - 1)
     {
         space.rightWall.Visible = true;
     }
     else if (currentSpace == otherSpace + 1)
     {
         space.leftWall.Visible = true;
     }
     else if (currentSpace > otherSpace)
     {
         space.topWall.Visible = true;
     }
     else if (currentSpace < otherSpace)
     {
         space.bottomWall.Visible = true;
     }
 }
Exemple #4
0
 public void AddSpace(ObservationSpace observationSpace)
 {
     observationSpace.Dock = DockStyle.Left;
     this.Controls.Add(observationSpace);
     Spaces.Add(observationSpace);
 }