Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 public KeypadSequence Add(Key key)
 {
     _keySequence.Add(key);
     return this;
 }
Esempio n. 5
0
 public KeypadSequence KeyPress(Key k, KeypadSequence sequence)
 {
     sequence.Add(k);
     return sequence;
 }