Exemple #1
0
    public override Solvability CheckSolvability(Dot[,] board)
    {
        int columns = board.GetLength (0);
        int rows = board.GetLength (1);
        HashSet<string> dotTypeSet = new HashSet<string>();

        for (int i = 0; i<columns; i++)
        {
            for(int j = 0; j < rows; j++)
            {
                Dot dot = board[i,j];
                dotTypeSet.Add(dot.GetDotType());

                if(i+1 < columns && board[i+1,j].GetDotType() == dot.GetDotType())
                {
                    return Solvability.HAS_MOVES;
                }

                if(j+1 < rows && board[i,j+1].GetDotType() == dot.GetDotType())
                {
                    return Solvability.HAS_MOVES;
                }
            }
        }

        if (columns * rows <= dotTypeSet.Count)
        {
            return Solvability.UNSOLVABLE;
        }
        else
        {
            return Solvability.NO_MOVES;
        }
    }