public GridWorldControl(int rows = 20, int cols = 20)
        {
            InitializeComponent();

            _rows    = rows;
            _columns = cols;

            _lastActions = new List <StateAction>();
            _world       = new List <List <GridUserControl> >();

            int x = 0;
            int y = 0;

            for (int i = 0; i < _rows; i++)
            {
                _world.Add(new List <GridUserControl>());
                for (int j = 0; j < _columns; j++)
                {
                    GridUserControl grid = new GridUserControl();
                    grid.Margin = new Thickness(x, y, 0, 0);

                    _world[i].Add(grid);
                    GridWorldGrid.Children.Add(grid);
                    x += GridUserControl.WIDTH;
                }
                x  = 0;
                y += GridUserControl.HEIGHT;
            }

            _world[18][18].State = GridState.Goal;


            _world[12][14].State = GridState.Blocked;
            _world[13][14].State = GridState.Blocked;
            _world[14][14].State = GridState.Blocked;
            _world[14][14].State = GridState.Blocked;
            _world[15][14].State = GridState.Blocked;
            _world[15][13].State = GridState.Blocked;
            _world[15][12].State = GridState.Blocked;
            _world[15][10].State = GridState.Blocked;
            _world[15][11].State = GridState.Blocked;
            _world[15][9].State  = GridState.Blocked;
            _world[15][8].State  = GridState.Blocked;
            _world[10][7].State  = GridState.Blocked;
            _world[9][7].State   = GridState.Blocked;
            _world[8][7].State   = GridState.Blocked;
            _world[7][7].State   = GridState.Blocked;
            _world[5][2].State   = GridState.Blocked;
            _world[5][3].State   = GridState.Blocked;
            _world[6][13].State  = GridState.Blocked;
            _world[6][14].State  = GridState.Blocked;
            _world[6][15].State  = GridState.Blocked;
            _world[6][16].State  = GridState.Blocked;
            _world[6][17].State  = GridState.Blocked;
            _world[6][18].State  = GridState.Blocked;

            _world[16][10].State = GridState.Blocked;
            _world[17][11].State = GridState.Blocked;
            _world[3][5].State   = GridState.Blocked;
            _world[3][6].State   = GridState.Blocked;


            for (int i = 0; i < _rows; i++)
            {
                for (int j = 0; j < _columns; j++)
                {
                    //if (_world[i][j].State == GridState.Blocked || _world[i][j].State == GridState.Goal)
                    //    continue;

                    _world[i][j].UpValueQ    = (_rand.NextDouble() + .01) * .1;
                    _world[i][j].LeftValueQ  = (_rand.NextDouble() + .01) * .1;
                    _world[i][j].DownValueQ  = (_rand.NextDouble() + .01) * .1;
                    _world[i][j].RightValueQ = (_rand.NextDouble() + .01) * .1;
                }
            }

            SpawnPlayer();

            this.Height = GridUserControl.HEIGHT * _rows;
            this.Width  = GridUserControl.WIDTH * _columns;
        }
        public void MakeMove()
        {
            GridUserControl state = _world[(int)_currentLocation.X][(int)_currentLocation.Y];

            double upConfidence    = state.UpValueQ + (.5 * (MAX_STEPS - state.UpValueE));
            double downConfidence  = state.DownValueQ + (.5 * (MAX_STEPS - state.DownValueE));
            double leftConfidence  = state.LeftValueQ + (.5 * (MAX_STEPS - state.LeftValueE));
            double rightConfidence = state.RightValueQ + (.5 * (MAX_STEPS - state.RightValueE));
            double totalChance     = upConfidence + downConfidence + leftConfidence + rightConfidence;

            double upChance    = (upConfidence / totalChance) * 100;
            double downChance  = (downConfidence / totalChance) * 100;
            double leftChance  = (leftConfidence / totalChance) * 100;
            double rightChance = (rightConfidence / totalChance) * 100;

            int output = _rand.Next(1, 101);
            int option = 0;

            if (output < upChance)
            {
                option = UP_OPTION;
            }
            else if (output < upChance + downChance)
            {
                option = DOWN_OPTION;
            }
            else if (output < upChance + downChance + leftChance)
            {
                option = LEFT_OPTION;
            }
            else
            {
                option = RIGHT_OPTION;
            }


            bool   validMove = false;
            Point  lastState = _currentLocation;
            Action action    = Action.Up;

            switch (option)
            {
            case UP_OPTION:
                validMove = MoveUp();
                action    = Action.Up;
                break;

            case RIGHT_OPTION:
                validMove = MoveRight();
                action    = Action.Right;
                break;

            case LEFT_OPTION:
                validMove = MoveLeft();
                action    = Action.Left;
                break;

            case DOWN_OPTION:
                validMove = MoveDown();
                action    = Action.Down;
                break;
            }

            switch (action)
            {
            case Action.Up:
                _world[(int)lastState.X][(int)lastState.Y].UpValueE++;
                break;

            case Action.Right:
                _world[(int)lastState.X][(int)lastState.Y].RightValueE++;
                break;

            case Action.Left:
                _world[(int)lastState.X][(int)lastState.Y].LeftValueE++;
                break;

            case Action.Down:
                _world[(int)lastState.X][(int)lastState.Y].DownValueE++;
                break;
            }

            if (validMove)
            {
                StateAction sa = new StateAction();
                sa.State        = lastState;
                sa.PlayerAction = action;
                //Only add the last action in each state
                RemoveState(sa);
                _lastActions.Add(sa);
            }

            if (_world[(int)_currentLocation.X][(int)_currentLocation.Y].State == GridState.Goal)
            {
                WinGame();
            }
        }