Printing Worlds

Today I focused on printing world graphs on the console, as getting a GUI with OpenGL is just taking too long. Things were very productive too I managed to expand on a previously written function to display ant quadrants. and using more mod trickery print only specific lines of each quadrant in turn for specific lines of a world graph.

specificLinePrint aWorld row wsiz siz worldCol = do
a <- getLine let siz = truncate $ sqrt $fromIntegral $length $brokenUpGraph $ fstTrip ((sndTrip aWorld) (0)) let preData = brokenUpGraph $ fstTrip ((sndTrip aWorld) (getGraph row siz wsiz worldCol)) -- pulls out the specific Graph! so only siz^2 elements in pre Data! let theData = fst $ splitAt siz $snd (splitAt ((row`mod`siz)*siz) preData) -- TODO wsiz chang to local size putStr("World Col = "++ (show worldCol) ++ " ") putStr("World Row = " ++ (show row) ++ " ") putStr("World Siz = " ++ (show wsiz) ++ " ") putStrLn("Test ") specialPrintLn worldCol wsiz preData putStrLn("%") specialPrintLn worldCol wsiz siz row theData let moveOn = worldCol+1 if moveOn > wsiz
then printWorldLine (row+1) (worldCol+1) wsiz siz aWorld
else printWorldLine row (worldCol+1) wsiz siz aWorld

One nice thing about working with code like this is that because the function produces IO it is ok to use traditional debuging techniques in order to narrow down problems.

Leave a Reply

Your email address will not be published. Required fields are marked *