//Constructor public WordsearchSolutionEvaluator(Solution proposedSolution, Dictionary<string, List<WordPosition>> correctSolutions) { TruePositive = 0; FalsePositive = 0; FalseNegative = 0; TrueNegative = 0; //For each word there was to look for foreach(KeyValuePair<string, List<WordPosition>> kvp in correctSolutions) { string word = kvp.Key; List<WordPosition> correctPositions = kvp.Value; //Check this word is in the wordsearch if(correctPositions.Count > 0) { //Did the proposed solution give a position for this word if(proposedSolution.ContainsKey(word)) { //Did the proposed solution contain this word in the correct position bool inCorrectPosition = false; foreach(WordPosition correctPosition in correctPositions) { if(correctPosition.Equals(proposedSolution[word])) { inCorrectPosition = true; break; } } if(inCorrectPosition) { TruePositive++; } else //Otherwise the proposed solution contains the word in the wrong position (false positive) { FalsePositive++; } } else //Otherwise the proposed solution didn't find this word (false negative) { FalseNegative++; } } else //Otherwise this word was not in the wordsearch { //Did the proposed solution give a position for this word (false positive) if(proposedSolution.ContainsKey(word)) { FalsePositive++; } else //Otherwise the proposed solution recognised that this word isn't actually there (true negative) { TrueNegative++; } } } }