Advertisement
Coriic

Untitled

Jun 4th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rateBoard:: Board->Color->Int
  2. rateBoard (Board innerMap) color =
  3.     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]
  4.         where
  5.             rate listOfCoordinates = sum (Prelude.map (rateAllDirections listOfCoordinates) listOfCoordinates)
  6.             rateAllDirections listOfCoordinates coordinates = sum (Prelude.map (rateNeighborsSequence coordinates listOfCoordinates) [(x,y) | x<-[-1..0], y<-[-1..1], x/=0 && y/=(-1)])
  7.  
  8. rateNeighborsSequence:: Coordinates->[Coordinates]->(Int, Int)->Int
  9. rateNeighborsSequence (Coordinates x y) listOfCoordinates (xTranslation, yTranslation)
  10.     | ((Coordinates (x+xTranslation) (y+yTranslation)) `elem` listOfCoordinates) || ((Coordinates (x-xTranslation) (y-yTranslation)) `elem` listOfCoordinates) = 1
  11.     | otherwise = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement