Esempio n. 1
0
 private IEnumerable <GameState> CreateGameStates(GameState gameState, IWordStateMachine wordStateMachine)
 {
     for (int index = 0; index < gameState.OccupationField.Length; index++)
     {
         GamePoint startGamePoint = new GamePoint(gameState.GameInformation, index);
         wordStateMachine.Reset();
         if (wordStateMachine.CanNavigateForward(startGamePoint.ToChar()) && !gameState.OccupationField[startGamePoint.Index])
         {
             TemporaryGameState temporaryGameState = new TemporaryGameState(gameState, startGamePoint, wordStateMachine);
             foreach (var newGameState in CreateGameStates(temporaryGameState))
             {
                 yield return(newGameState);
             }
         }
     }
 }
Esempio n. 2
0
        private IEnumerable <GameState> CreateGameStates(TemporaryGameState temporaryGameState)
        {
            foreach (NavigateDirection navigateDirection in Enum.GetValues(typeof(NavigateDirection)))
            {
                if (temporaryGameState.CanNavigate(navigateDirection))
                {
                    temporaryGameState.Navigate(navigateDirection);
                    foreach (var newGameState in CreateGameStates(temporaryGameState))
                    {
                        yield return(newGameState);
                    }
                    temporaryGameState.NavigateBack();
                }
            }

            if (temporaryGameState.IsWordExist())
            {
                yield return(temporaryGameState.GetNewGameState());
            }
        }