Advertisement
Coriic

Untitled

Jun 7th, 2017
99
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 sumPoints (rateDirections listOfCoordinates))
  6.  
  7. rateDirections:: [Coordinates]->[[Int]]
  8. 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)])
  9.  
  10.  
  11. rateDirection:: Coordinates->[Coordinates]->Int->(Int,Int)->[Int]
  12. rateDirection coords [] seq (x,y) = [seq]
  13. rateDirection (Coordinates x y) ((Coordinates x1 y1):rest) seq (xTranslation, yTranslation)
  14.     | (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)
  15.     | otherwise = [seq] ++ rateDirection (Coordinates (x1+xTranslation) (y1+yTranslation)) rest 1 (xTranslation, yTranslation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement