Advertisement
Coriic

Untitled

May 30th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. ateVerticalNeighbors:: Coordinates->[Coordinates]->Int
  2. rateVerticalNeighbors ((Coordinates x y) listOfCoordinates)
  3. | ((Coordinates x y-1) `elem` listOfCoordinates) || ((Coordinates x y+1) `elem` listOfCoordinates) = 1
  4. | otherwise = 0
  5.  
  6. rateHorizontalNeighbors:: Coordinates->[Coordinates]->Int
  7. rateHorizontalNeighbors ((Coordinates x y) listOfCoordinates)
  8. | ((Coordinates x-1 y) `elem` listOfCoordinates) || ((Coordinates x+1 y) `elem` listOfCoordinates) = 1
  9. | otherwise = 0
  10.  
  11. rateRightDiagonalNeighbors:: Coordinates->[Coordinates]->Int
  12. rateRightDiagonalNeighbors ((Coordinates x y) listOfCoordinates)
  13. | ((Coordinates x-1 y-1) `elem` listOfCoordinates) || ((Coordinates x+1 y+1) `elem` listOfCoordinates) = 1
  14. | otherwise = 0
  15.  
  16. rateLeftDiagonalNeighbors:: Coordinates->[Coordinates]->Int
  17. rateLeftDiagonalNeighbors ((Coordinates x y) listOfCoordinates) =
  18. | ((Coordinates x-1 y+1) `elem` listOfCoordinates) || ((Coordinates x+1 y-1) `elem` listOfCoordinates) = 1
  19. | otherwise = 0
  20.  
  21.  
  22.  
  23. rateBoard:: Board->Color->Int
  24. rateBoard ((Board map) color) =
  25. rate (0 [x | x <- Map.keys map, fromJust (Map.lookup coordinates map) == color]) - rate(0 [x | x <- Map.keys map, fromJust (Map.lookup coordinates map) == !color])
  26. where
  27. rateIterating ((length listOfCoordinates) listOfCoordinates) = 0
  28. rateIterating (index listOfCoordinates) = rateVerticalNeighbors ((listOfCoordinates !! index) listOfCoordinates) +
  29. rateHorizontalNeighbors ((listOfCoordinates !! index) listOfCoordinates) +
  30. rateVRightDiagonalNeighbors ((listOfCoordinates !! index) listOfCoordinates) +
  31. rateLeftDiagonalNeighbors ((listOfCoordinates !! index) listOfCoordinates) +
  32. rateIterating (index+1 listOfCoordinates)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement