diff --git a/Proj2.hs b/Proj2.hs index 7631262..ff9f91e 100644 --- a/Proj2.hs +++ b/Proj2.hs @@ -162,12 +162,25 @@ nextGuess (prevGuess, chord : chords) _ = (chord, chords) -- ==== HELPER FUNCTIONS ====================================================== +-- given lists xs and ys, calculates the maximum number of pairwise matches +-- between xs and all permutations of ys +-- +-- used in the feedback function to calculate the number of correct notes +-- and/or octaves +-- matches :: (Eq a, Show a) => [a] -> [a] -> Int matches xs ys = maximum permutationMatches where permutationMatches = map (pairwiseMatches xs) (permutations ys) pairwiseMatches xs ys = length $ filter (uncurry (==)) $ zip xs ys +-- outputs a list of all possible chords, where a chord is a list of unique +-- pitches. this function happens to generate chords such that the pitches are +-- in alphabetical order, but this is only to ensure that there are no +-- duplicate pitches +-- +-- used in initialGuess as the game state (represents all possible targets) +-- allChords :: [[Pitch]] allChords = [ chord