Exemplo 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);
             }
         }
     }
 }
        public TemporaryGameState(GameState initialGameState, GamePoint initialPoint, IWordStateMachine wordStateMachine)
        {
            this.wordStateMachine = wordStateMachine;
            this.wordStateMachine.Reset();
            this.wordStateMachine.NavigateForward(initialPoint.ToChar());

            this.gamePoints = new Stack <GamePoint>();
            this.gamePoints.Push(initialPoint);

            this.GameInformation = initialGameState.GameInformation;

            this.GameState = initialGameState;

            this.InitialPoint = initialPoint;
            this.currentPoint = initialPoint;

            this.occupationField = new BitArray(initialGameState.OccupationField)
            {
                [currentPoint.Index] = true
            };
        }