@@ -6,6 +6,8 @@ import Control.Monad.State
66import Data.Word
77import Data.Binary (decodeFile )
88import Text.Printf
9+ import qualified Data.Array.BitArray as BA
10+ import qualified Data.Set as S
911
1012import Trace
1113import Sim
@@ -44,9 +46,30 @@ fill bid dir p@(x,y,z) = do
4446 (neighbour, diff) <- findFreeNeighbour p
4547 let diff' = negateNear diff
4648 move bid neighbour
49+ grounded <- willBeGrounded p
50+ unless grounded $
51+ setHarmonics bid High
4752 issueFill bid diff'
53+ setHarmonics bid Low
4854 step
4955
56+ -- This would be too slow
57+ -- isGrounded :: P3 -> Generator Bool
58+ -- isGrounded p = do
59+ -- matrix <- gets gsFilled
60+ -- return $ go matrix S.empty p
61+ -- where
62+ -- go _ _ (_,0,_) = True
63+ -- go m visited p@(x,y,z) =
64+ -- case m BA.!? p of
65+ -- Nothing -> return False
66+ -- Just False -> return False
67+ -- Just True ->
68+ -- let neighbours = [(x+1, y, z), (x, y+1, z), (x, y, z+1),
69+ -- (x-1, y, z), (x, y-1, z), (x, y, z-1)]
70+ -- nonVisited = [neighbour | neighbour `S.notMember` visited]
71+ -- in or [go m (S.insert neighbour visited) neighbour | neighbour <- nonVisited]
72+
5073makeLine :: Direction -> Resolution -> Word8 -> Word8 -> [P3 ]
5174makeLine dir r y z =
5275 case dir of
@@ -98,10 +121,11 @@ dumbHighSolver modelPath tracePath = do
98121 model <- decodeFile modelPath
99122 let trace = makeTrace model $ do
100123 let bid = 0
101- issue bid Flip
124+ -- issueFlip bid
102125 dumbFill bid
103126 move bid (0 ,0 ,0 )
104- issue bid Flip
127+ -- issueFlip bid
105128 issue bid Halt
129+ print trace
106130 writeTrace tracePath trace
107131
0 commit comments