Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rateBoard:: Board->Color->Int
- rateBoard (Board innerMap) color =
- rate [x | x <- Map.keys innerMap, fromJust (Map.lookup x innerMap) == color] - rate [x | x <- Map.keys innerMap, fromJust (Map.lookup x innerMap) == negateColor color]
- where
- rate listOfCoordinates = sum (Prelude.map sumPoints (rateDirections listOfCoordinates))
- rateDirections:: [Coordinates]->[[Int]]
- rateDirections (coords:rest) = (Prelude.map (rateDirection coords (coords:rest) 0) [(x,y) | x<-[0..1], y<-[-1..1], not(x==1 && y==1) && not(x==0 && y==0)])
- rateDirection:: Coordinates->[Coordinates]->Int->(Int,Int)->[Int]
- rateDirection coords [] seq (x,y) = [seq]
- rateDirection (Coordinates x y) ((Coordinates x1 y1):rest) seq (xTranslation, yTranslation)
- | (Coordinates x y) `elem` ((Coordinates x1 y1):rest) = rateDirection (Coordinates (x+xTranslation) (y+yTranslation)) (Data.List.delete (Coordinates x y) ((Coordinates x1 y1):rest)) (seq+1) (xTranslation, yTranslation)
- | otherwise = [seq] ++ rateDirection (Coordinates (x1+xTranslation) (y1+yTranslation)) rest 1 (xTranslation, yTranslation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement