Advertisement
Coriic

Untitled

Jun 4th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. hasWon:: Board->Color->Bool
  2. hasWon (Board map) color = Prelude.any (checkAllDirections listOfCoordinates) listOfCoordinates
  3.     where
  4.         isFiveInDirection howMany (Coordinates x y) listOfCoordinates (xTranslation, yTranslation)
  5.             | ((Coordinates x y) `elem` listOfCoordinates) = True && (isFiveInDirection (howMany+1) (Coordinates (x+xTranslation) (y+yTranslation)) listOfCoordinates (xTranslation, yTranslation))
  6.             | ((Coordinates x y) `elem` listOfCoordinates) && howMany==5 = True
  7.             | otherwise = False
  8.         checkAllDirections listOfCoordinates coords = Prelude.any (isFiveInDirection 1 coords listOfCoordinates) [(x,y)| x<-[-1..1], y<-[-1..1], x/=0 && y/=0]
  9.         listOfCoordinates = [coords | coords <- Map.keys map, fromJust (Map.lookup coords map) == color]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement