public IList<Key> GetPossibleMoves(Key currentKey) { BoardPosition currentPosition = _board.GetPosition(currentKey); List<BoardPosition> potentialPositions = GetPotentialMoves(currentPosition); List<BoardPosition> validPositions = GetValidMoves(potentialPositions); var results = (from vp in validPositions select _board.GetKey(vp)).ToList(); return results; }
public int CountSequencesFromKey(Key key, KeypadSequence sequence) { if (!sequence.IsValidSequence()) return 0; if (sequence.Length == _pathSize) return 1; int count = 0; var possibleMoves = this._moveStrategy.GetPossibleMoves(key); foreach (var move in possibleMoves) count += CountSequencesFromKey(move, _board.KeyPress(move, new KeypadSequence(sequence))); return count; }
public BoardPosition GetPosition(Key key) { for (int y = 0; y <= board.GetUpperBound(0); y++) { for (int x = 0; x <= board.GetUpperBound(1); x++) { Key k = this.GetKeyInternal(x, y); if (k == key) return new BoardPosition() { X = x, Y = y }; } } throw new KeyNotFoundException("Key was not found on board: " + key.Name); }
public KeypadSequence Add(Key key) { _keySequence.Add(key); return this; }
public KeypadSequence KeyPress(Key k, KeypadSequence sequence) { sequence.Add(k); return sequence; }