public void NavigateBack() { var prevPoint = gamePoints.Pop(); currentPoint = gamePoints.Peek(); occupationField[prevPoint.Index] = false; wordStateMachine.NavigateBack(); }
private void NavigationBase(int newIndex) { occupationField[newIndex] = true; var newPoint = new GamePoint(GameInformation, newIndex); gamePoints.Push(newPoint); currentPoint = newPoint; wordStateMachine.NavigateForward(GameInformation.FieldLetters[newIndex]); }
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 }; }