コード例 #1
0
 public Move(int column, int row, MoveOrientation orientation, string word, Hand hand, Board board)
 {
     this.Column      = column;
     this.Row         = row;
     this.Orientation = orientation;
     this.Word        = word;
     this.Hand        = hand;
     this.Board       = board;
 }
コード例 #2
0
        private static Tuple <int, int> AdvancePosition(Tuple <int, int> current, MoveOrientation orientation)
        {
            switch (orientation)
            {
            case MoveOrientation.HORIZONTAL:
                return(new Tuple <int, int>(current.Item1 + 1, current.Item2));

            case MoveOrientation.VERTICAL:
                return(new Tuple <int, int>(current.Item1, current.Item2 + 1));

            default:
                throw new ApplicationException("Unkown Orientation.");
            }
        }
コード例 #3
0
ファイル: Board.cs プロジェクト: dwat001/scrabble-solver
        private Tuple <int, int> AdvanceRowColumn(Tuple <int, int> rowColumn, MoveOrientation moveOrientation)
        {
            switch (moveOrientation)
            {
            case MoveOrientation.VERTICAL:
                return(new Tuple <int, int>(rowColumn.Item1 + 1, rowColumn.Item2));

            case MoveOrientation.HORIZONTAL:
                return(new Tuple <int, int>(rowColumn.Item1, rowColumn.Item2 + 1));

            default:
                throw new ApplicationException("Unkown Orientations.");
            }
        }
コード例 #4
0
ファイル: Board.cs プロジェクト: dwat001/scrabble-solver
        private Cell PreviousCell(Cell currentCell, MoveOrientation orientation)
        {
            switch (orientation)
            {
            case MoveOrientation.VERTICAL:
                if (currentCell.Row <= BOARD_START_INDEX)
                {
                    return(null);
                }
                return(cells[currentCell.Row - 1][currentCell.Column]);

            case MoveOrientation.HORIZONTAL:
                if (currentCell.Column <= BOARD_START_INDEX)
                {
                    return(null);
                }
                return(cells[currentCell.Row][currentCell.Column - 1]);

            default:
                throw new ApplicationException("Unexpected Orientation");
            }
        }
コード例 #5
0
ファイル: Board.cs プロジェクト: dwat001/scrabble-solver
        private Cell NextCell(Cell currentCell, MoveOrientation orientation)
        {
            switch (orientation)
            {
            case MoveOrientation.VERTICAL:
                if (currentCell.Row >= BOARD_END_INDEX)
                {
                    return(null);
                }
                return(cells[currentCell.Row + 1][currentCell.Column]);

            case MoveOrientation.HORIZONTAL:
                if (currentCell.Column >= BOARD_END_INDEX)
                {
                    return(null);
                }
                return(cells[currentCell.Row][currentCell.Column + 1]);

            default:
                throw new ApplicationException("Unexpected Orientation");
            }
        }
コード例 #6
0
ファイル: Board.cs プロジェクト: dwat001/scrabble-solver
        internal string GetWord(MoveOrientation orientation, Cell initialCell, char proposedLetter)
        {
            Cell startCell;
            Cell previousCell = initialCell;

            do // Move startCell to first letter in word.
            {
                startCell    = previousCell;
                previousCell = PreviousCell(startCell, orientation);
            } while (previousCell != null && previousCell.Letter.HasValue);

            StringBuilder sb          = new StringBuilder();
            Cell          currentCell = startCell;

            while (currentCell != null && (currentCell.Letter.HasValue ||
                                           (currentCell.Column == initialCell.Column && currentCell.Row == initialCell.Row)))
            {
                sb.Append(currentCell.Letter ?? proposedLetter);
                currentCell = NextCell(currentCell, orientation);
            }

            return(sb.ToString());
        }
コード例 #7
0
 internal MergedEventArgs(MoveOrientation orientation, int index, (int FromIndex, int ToIndex) movedCellIndexes, int matrixOrder, int mergedValue)