commit 2a5cc869cf6585bfb5ac0b407c0071b995ea5251 Author: Shaun Kerr Date: Wed May 15 15:53:15 2019 +1200 init diff --git a/Main.hs b/Main.hs new file mode 100644 index 0000000..e0d30d7 --- /dev/null +++ b/Main.hs @@ -0,0 +1,34 @@ +newtype Group = [MainCharacter] +newtype NeoTokyo = [Group] + +data MainCharacter = Asuka | Shinji | Rei | Misato | Ritsuko | Gendo + +defFrens :: MainCharacter -> [MainCharacter] +defFrens Asuka = [Rei, Shinji, Misato] +defFrens Shinji = [Rei, Gendo, Ritsuko, Misato, Asuka] +defFrens Rei = [Gendo, Shinji, Asuka] +defFrens Misato = [Asuka, Shinji, Ritsuko] +defFrens Ritsuko = [Misato, Shinji, Gendo] +defFrens Gendo = [Rei, Shinji, Ritsuko] + +charsGroup :: MainCharacter -> NeoTokyo -> Group +charsGroup x nt = filter (\g -> x `elem` g) nt + +curFrens :: MainCharacter -> NeoTokyo -> [MainCharacter] +curFrens x nt = filter (/= x) $ charsGroup x nt + +uniq :: (Ord a) => [a] -> [a] +uniq = map head . group . sort + +adjGroups :: MainCharacter -> NeoTokyo -> [Group] +adjGroups x nt = filter (\g -> any (elem adjFrens) g) otherGroups + where + otherGroups = filter (\g -> not $ x `elem` g) nt + adjFrens = uniq $ fold (++) (map defFrens $ curFrens x nt) + +getAdj :: MainCharacter -> NeoTokyo -> [MainCharacter] +getAdj x nt = curFrens x nt ++ (fold (++) adjGroups x nt) + +hurt :: MainCharacter -> NeoTokyo -> NeoTokyo + +attract :: MainCharacter -> NeoTokyo -> NeoTokyo