This commit is contained in:
Shaun Kerr 2019-05-15 15:53:15 +12:00
commit 2a5cc869cf

34
Main.hs Normal file
View File

@ -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