You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
688 B

module CircuitBase (Circuit(..), Chamber(..), Car(..), server_input, circ_from_perm) where
import Encoding
data Circuit = Circuit { outPin :: Int, inPins :: [Int] } deriving (Eq, Show)
circ_from_perm (x:xs) = if (odd $ length xs) then error "Wrong pin count" else Circuit x xs
data Chamber = Chamber { upperPipe :: [Int], mainChamber :: Bool, lowerPipe :: [Int] }
data Car = Car { chambers :: [Chamber] }
instance Encode Chamber where
sdecode = do
(a, b, c) <- sdecode
return $ Chamber a (not b) c
sencode (Chamber a b c) = sencode (a, not b, c)
instance Encode Car where
sdecode = sdecode >>= (return . Car)
sencode (Car a) = sencode a
server_input = "01202101210201202"