/// <summary> /// Finds all possible clicks on a single board, their result states and the result evaluations. /// </summary> /// <param name="matrix"></param> /// <returns></returns> private List<TapResult> FindPossibleClicks(Color[,] matrix, bool optimizeForSingleSolution, int clicksLeft) { List<TapResult> result = new List<TapResult>(); // Find all possible clicks on the board, add them to the possible solutions list for (int x = 0; x < 5; x++) { for (int y = 0; y < 6; y++) { if ((matrix[x, y] != Color.None) && ((int)matrix[x,y] <= clicksLeft)) { Color[,] cloneMatrix = matrix.Clone() as Color[,]; TapResult r = Tap(cloneMatrix, x, y); result.Add(r); // If the last result was a solution, there's no need to check for other results if ((optimizeForSingleSolution) && (r.Estimate == Int32.MaxValue)) { return result; } } } } // Sort the list return result.OrderByDescending(q => q.Estimate).ToList(); }