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 (rateAllDirections listOfCoordinates) listOfCoordinates)
- rateAllDirections listOfCoordinates coordinates = sum (Prelude.map (rateNeighborsSequence coordinates listOfCoordinates) [(x,y) | x<-[-1..0], y<-[-1..1], x/=0 && y/=(-1)])
- rateNeighborsSequence:: Coordinates->[Coordinates]->(Int, Int)->Int
- rateNeighborsSequence (Coordinates x y) listOfCoordinates (xTranslation, yTranslation)
- | ((Coordinates (x+xTranslation) (y+yTranslation)) `elem` listOfCoordinates) || ((Coordinates (x-xTranslation) (y-yTranslation)) `elem` listOfCoordinates) = 1
- | otherwise = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement