|
@ -37,32 +37,31 @@ passes gamesnotes = map generateoutput (gameswithtouched gamesnotes) |
|
|
generateoutput ((game,note),touched) = Output { width = DT.width $ DT.board game, |
|
|
generateoutput ((game,note),touched) = Output { width = DT.width $ DT.board game, |
|
|
height = DT.height $ DT.board game, |
|
|
height = DT.height $ DT.board game, |
|
|
filled = filledcells game, |
|
|
filled = filledcells game, |
|
|
touched = touchedcells touched, |
|
|
|
|
|
|
|
|
touched = extractcell touched, |
|
|
unit = unitcells game, |
|
|
unit = unitcells game, |
|
|
score = DT.score game |
|
|
score = DT.score game |
|
|
} |
|
|
} |
|
|
filledcells gm = extractcell $ DT.filled $ DT.board gm |
|
|
|
|
|
|
|
|
filledcells gm = extractcell $ DT.filled $ DT.board gm |
|
|
unitcells gm = if null $ DT.units gm |
|
|
unitcells gm = if null $ DT.units gm |
|
|
then [] |
|
|
then [] |
|
|
else extractunit $ head $ DT.units gm |
|
|
else extractunit $ head $ DT.units gm |
|
|
touchedcells tc = extractcell tc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameswithtouched :: [(DT.Game,VM.Notes)] -> [((DT.Game,VM.Notes),Set DT.Cell)] |
|
|
gameswithtouched :: [(DT.Game,VM.Notes)] -> [((DT.Game,VM.Notes),Set DT.Cell)] |
|
|
gameswithtouched [] = [] |
|
|
|
|
|
gameswithtouched (x:[]) = [(x,Data.Set.empty)] |
|
|
|
|
|
gameswithtouched (x:xs) = (x,touched):lastels |
|
|
|
|
|
|
|
|
gameswithtouched els = gameswithtouched0 els Data.Set.empty |
|
|
|
|
|
|
|
|
|
|
|
gameswithtouched0 :: [(DT.Game,VM.Notes)] -> Set DT.Cell -> [((DT.Game,VM.Notes),Set DT.Cell)] |
|
|
|
|
|
gameswithtouched0 [] acc = [] |
|
|
|
|
|
gameswithtouched0 (x:[]) acc = [(x,acc)] |
|
|
|
|
|
gameswithtouched0 (x:xs) acc = (x,touched):lastels |
|
|
where |
|
|
where |
|
|
touched1 = snd $ head lastels |
|
|
|
|
|
touched2 = if null $ DT.units $ fst $ fst $ head lastels |
|
|
|
|
|
then Data.Set.empty |
|
|
|
|
|
else DT.members $ head $ DT.units $ fst $ fst $ head lastels |
|
|
|
|
|
touched = difference (difference (union touched1 touched2) cells) units |
|
|
|
|
|
|
|
|
touched = (difference (difference acc cells) units) |
|
|
cells = DT.filled $ DT.board $ fst x |
|
|
cells = DT.filled $ DT.board $ fst x |
|
|
units = if null $ DT.units $ fst x |
|
|
units = if null $ DT.units $ fst x |
|
|
then Data.Set.empty |
|
|
then Data.Set.empty |
|
|
else DT.members $ head $ DT.units $ fst x |
|
|
else DT.members $ head $ DT.units $ fst x |
|
|
touchedcells tc = extractcell touched |
|
|
touchedcells tc = extractcell touched |
|
|
lastels = gameswithtouched xs |
|
|
|
|
|
|
|
|
lastels = gameswithtouched0 xs (union touched units) |
|
|
|
|
|
|
|
|
extractunit :: DT.Unit -> [Cell] |
|
|
extractunit :: DT.Unit -> [Cell] |
|
|
extractunit unit = extractcell $ DT.members unit |
|
|
extractunit unit = extractcell $ DT.members unit |
|
|