X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=src%2Ftask8%2Ftask8.hs;h=83e7e3bd35d7a3288f8fbedbf3b62114cc1364ef;hb=35fd88f4adee89988e8433c825f88b58a9691466;hp=b23198dd285124d004be999fba22fa2eb709830b;hpb=b092ac27ba61305cad4ec2f5a5526c7fd31bf792;p=summerofcode2018soln.git diff --git a/src/task8/task8.hs b/src/task8/task8.hs index b23198d..83e7e3b 100644 --- a/src/task8/task8.hs +++ b/src/task8/task8.hs @@ -82,13 +82,14 @@ candidates longCost lawn agendum closed = newCandidates successors :: Int -> Lawn -> Location -> (Q.Seq Neighbour) successors longCost lawn (row, column) = Q.fromList $ map neighbourify neighbours where neighbours = filter (\l -> l `M.member` lawn) - [(r, c) | r <- [(row - 1)..(row + 1)], - c <- [(column - 1)..(column + 1)], - r >= minR, - r <= maxR, - c >= minC, - c <= maxC, - ((r == row && c /= column) || (r /= row && c == column)) ] + [ (r, c) | r <- [(row - 1)..(row + 1)] + , c <- [(column - 1)..(column + 1)] + , r >= minR + , r <= maxR + , c >= minC + , c <= maxC + , ((r == row && c /= column) || (r /= row && c == column)) + ] neighbourify neighbour = Neighbour {stepLocation = neighbour, stepCost = scCalc neighbour} minR = minimum $ map fst $ M.keys lawn maxR = maximum $ map fst $ M.keys lawn