public (CellItemType, Beacon) MoveWithStrategy(Game game)
        {
            CellItemType retVal;
            Beacon       beaconValue = new Beacon();
            var          poppedNode  = new Node();

            if (game.CurrentNode.Children.Count > 0)
            {
                poppedNode       = game.CurrentNode.Children.Pop();
                Position.Row     = poppedNode.Position.Row;
                Position.Column  = poppedNode.Position.Column;
                game.CurrentNode = poppedNode;
                retVal           = poppedNode.CellItemType;
            }
            else
            {
                poppedNode       = game.CurrentNode.Parent;
                Position.Row     = poppedNode.Position.Row;
                Position.Column  = poppedNode.Position.Column;
                game.CurrentNode = poppedNode;
                retVal           = poppedNode.CellItemType;
                Metrics.backtrackCount++;
            }
            Metrics.moveCount++;

            if (retVal == CellItemType.Beacon)
            {
                BaseCellItem cell = game.Map[poppedNode.Position.Row, poppedNode.Position.Column];
                beaconValue = cell as Beacon;
                if (beaconValue != null && beaconValue.Value < 1)
                {
                    retVal      = CellItemType.Empty;
                    beaconValue = null;
                }
            }
            if (retVal == CellItemType.GoldenSquare)
            {
                // fix facing
                Symbol = "\u2133";
            }

            game.AssignPlayerToCell(this);
            return(retVal, beaconValue);
        }
        public void PlayRandomly()
        {
            Task.Run(() =>
            {
                bool end = false;
                while (!end)
                {
                    while (!dashboard.pauseStatus())
                    {
                        // 1. randomize move between Rotate or Move
                        ActionType action = player.RandomizeAction();

                        if (action == ActionType.RotateRandom)
                        {
                            // 2. if Rotate, randomize how many times it will rotate 90-degrees

                            // arbitrary range of 1 to 10
                            player.Rotate();
                            dashboard.UpdateDashboard(player, ActionType.Rotate); // update move

                            this.Dispatcher.Invoke(() => RefreshGrid());
                            Thread.Sleep(player.Metrics.gameSpeed);
                        }
                        else if (action == ActionType.MoveRandom)
                        {
                            // 3. if Move, randomize how many times it will move
                            //var cell = player.MoveForward(game, true, gameSpeed);

                            var cell = player.ScanForward(game);
                            if (cell.CellItemType == CellItemType.Wall)
                            {
                                dashboard.UpdateDashboard(player, action, CellItemType.Wall);
                            }
                            else
                            {
                                // remove the player from its current cell
                                game.ClearCell(player.Position.Row, player.Position.Column);

                                // assign new coordinates to the player
                                player.Position.Row    = cell.Position.Row;
                                player.Position.Column = cell.Position.Column;

                                game.AssignPlayerToCell(player);

                                var newCoordinates = new Tuple <int, int>(player.Position.Row, player.Position.Column);

                                if (player.PositionHistory.Contains(newCoordinates))
                                {
                                    player.Metrics.backtrackCount++;
                                }
                                player.PositionHistory.Add(newCoordinates);

                                player.Metrics.moveCount++;
                                if (cell.CellItemType == Common.Enums.CellItemType.GoldenSquare)
                                {
                                    end    = true;
                                    action = ActionType.Win;
                                    dashboard.UpdateDashboard(player, action); // update move
                                }
                                else if (cell.CellItemType == Common.Enums.CellItemType.Pit)
                                {
                                    end    = true;
                                    action = ActionType.Die;
                                    dashboard.UpdateDashboard(player, action);
                                }
                                else
                                {
                                    action = ActionType.Move;
                                    dashboard.UpdateDashboard(player, action);
                                }
                            }

                            this.Dispatcher.Invoke(() => RefreshGrid());
                            Thread.Sleep(player.Metrics.gameSpeed);
                        }


                        if (end)
                        {
                            break;
                        }
                    }
                }
            });
        }
        public BaseCellItem MoveForward(Game game, bool random, int gameSpeed)
        {
            int times = 1;

            if (random)
            {
                times = Randomizer.RandomizeNumber(1, game.Size);
            }
            Console.WriteLine(string.Format("The player will move to the {0} for {1} time(s)!", Facing.ToString(), times));

            BaseCellItem cell = null;

            for (int i = 0; i < times; i++)
            {
                Thread.Sleep(gameSpeed);
                cell = ScanForward(game);
                //scanCount += 1;
                if (cell.CellItemType == CellItemType.Wall)
                {
                    Console.WriteLine("The player ran into a thick wall and cannot move forward. Aborting the remaining moves, if any.");
                    break;
                }

                // remove the player from its current cell
                game.ClearCell(Position.Row, Position.Column);

                // assign new coordinates to the player
                Position.Row    = cell.Position.Row;
                Position.Column = cell.Position.Column;

                game.AssignPlayerToCell(this);

                var newCoordinates = new Tuple <int, int>(Position.Row, Position.Column);

                Console.WriteLine(string.Format("Player moved to coordinates [{0},{1}]", Position.Row, Position.Column));
                if (PositionHistory.Contains(newCoordinates))
                {
                    Metrics.backtrackCount++;
                }
                PositionHistory.Add(newCoordinates);
                //moveCount += 1;
                Metrics.moveCount++;

                if (cell.CellItemType == CellItemType.Pit)
                {
                    // die
                    Console.WriteLine("The player died a horrible death.");
                    break;
                }
                else if (cell.CellItemType == CellItemType.GoldenSquare)
                {
                    // win
                    Console.WriteLine("The player has struck gold.");
                    break;
                }
                else if (cell.CellItemType == CellItemType.Beacon)
                {
                    // clue
                    Console.WriteLine("The player has found a beacon.");
                    break;
                }
            }
            return(cell);
        }