module RobotWorld(s0, s1, g0, g1, g2, g3) where import Array import List import Monad import IRL import GraphicsUtils -- ---------------------------------------------------------------------- -- -- Example Worlds and States -- -- ---------------------------------------------------------------------- -- An example state s0 :: RobotState s0 = RobotState { position = (0,0) , pen = False , color = Blue , facing = North , treasure = [] , pocket = 0 } s1 :: RobotState s1 = s0 { treasure = [(x,y) | x <- [-13,-11 .. 1], y <- [9,11 .. 15]] } -- Example worlds size :: Int size = 20 interior = [North, South, East, West] nb = [South, East, West] sb = [North, East, West] eb = [North, South, West] wb = [North, South, East] nwc = [South, East] nec = [South, West] swc = [North, East] sec = [North, West] g0 :: Grid g0 = array ((-size,-size),(size,size)) ([ ((i, size),nb) | i <- r ] ++ [ ((i,-size),sb) | i <- r ] ++ [ (( size,i),eb) | i <- r ] ++ [ ((-size,i),wb) | i <- r ] ++ [ ((i,j),interior) | i <- r, j <- r ] ++ [ ((size,size), nec),((size,-size), sec), ((-size,size),nwc),((-size,-size),swc)] ) where r = [1-size .. size-1] mkHorWall, mkVerWall :: Int -> Int -> Int -> [(Position,[Direction])] mkHorWall x1 x2 y = [ ((x,y), nb) | x <- [x1..x2] ] ++ [ ((x,y+1),sb) | x <- [x1..x2] ] mkVerWall y1 y2 x = [ ((x,y), eb) | y <- [y1..y2] ] ++ [ ((x+1,y),wb) | y <- [y1..y2] ] g1 :: Grid g1 = g0 // mkHorWall (-5) 5 10 mkBox :: Position -> Position -> [(Position,[Direction])] mkBox (x1,y1) (x2,y2) = mkHorWall (x1+1) x2 y1 ++ mkHorWall (x1+1) x2 y2 ++ mkVerWall (y1+1) y2 x1 ++ mkVerWall (y1+1) y2 x2 g2 :: Grid g2 = accum intersect g0 (mkBox (-15,8) (2,17)) g3 :: Grid g3 = accum union g2 [((-7,17),interior),((-7,18),interior)]