Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ateVerticalNeighbors:: Coordinates->[Coordinates]->Int
- rateVerticalNeighbors ((Coordinates x y) listOfCoordinates)
- | ((Coordinates x y-1) `elem` listOfCoordinates) || ((Coordinates x y+1) `elem` listOfCoordinates) = 1
- | otherwise = 0
- rateHorizontalNeighbors:: Coordinates->[Coordinates]->Int
- rateHorizontalNeighbors ((Coordinates x y) listOfCoordinates)
- | ((Coordinates x-1 y) `elem` listOfCoordinates) || ((Coordinates x+1 y) `elem` listOfCoordinates) = 1
- | otherwise = 0
- rateRightDiagonalNeighbors:: Coordinates->[Coordinates]->Int
- rateRightDiagonalNeighbors ((Coordinates x y) listOfCoordinates)
- | ((Coordinates x-1 y-1) `elem` listOfCoordinates) || ((Coordinates x+1 y+1) `elem` listOfCoordinates) = 1
- | otherwise = 0
- rateLeftDiagonalNeighbors:: Coordinates->[Coordinates]->Int
- rateLeftDiagonalNeighbors ((Coordinates x y) listOfCoordinates) =
- | ((Coordinates x-1 y+1) `elem` listOfCoordinates) || ((Coordinates x+1 y-1) `elem` listOfCoordinates) = 1
- | otherwise = 0
- rateBoard:: Board->Color->Int
- rateBoard ((Board map) color) =
- 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])
- where
- rateIterating ((length listOfCoordinates) listOfCoordinates) = 0
- rateIterating (index listOfCoordinates) = rateVerticalNeighbors ((listOfCoordinates !! index) listOfCoordinates) +
- rateHorizontalNeighbors ((listOfCoordinates !! index) listOfCoordinates) +
- rateVRightDiagonalNeighbors ((listOfCoordinates !! index) listOfCoordinates) +
- rateLeftDiagonalNeighbors ((listOfCoordinates !! index) listOfCoordinates) +
- rateIterating (index+1 listOfCoordinates)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement