Skip to content

Commit

Permalink
Add a ship status update every tick for testing.
Browse files Browse the repository at this point in the history
darcs-hash:20081026040323-d53a8-6057d91e7389df98931cf6033ce1d335ad7e8602.gz
  • Loading branch information
bshepherdson committed Oct 26, 2008
1 parent 4f78071 commit c24d40a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ tick x = do
(ws,wh) <- gets wind
cs' <- mapM (\c -> tickShip ws wh (cid c) (ship c) >>= \s -> return c { ship = s }) cs
tickWind


tickWind :: P ()
tickWind = return () -- TODO: to be defined
Expand Down
5 changes: 5 additions & 0 deletions Ship.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ tickShip ws wh cid s@(Ship { course = c, orCourse = oc, rudder = r, turnRate = d
when overshoot $ to cid ("Steady on course " ++ roundShow nc ++ ", Cap'n")
let s' = if overshoot then s { course = nc } else s { course = oc', orCourse = Nothing, rudder = 0 }
s'' = moveShip ws wh s'
to cid $ showShip s''
return s''

moveShip :: Speed -> Heading -> Ship -> Ship
Expand Down Expand Up @@ -112,6 +113,10 @@ turnReport (Ship { rudder=r}) = "Rudder " ++ rudderReport r ++ ", aye."

roundShow = show . round


showShip :: Ship -> String
showShip (Ship { course = c, orCourse = oc, sails = s, rudder = r, sx = x, sy = y }) = "Ship: ("++ show x ++","++ show y++"), course "++ show c ++", ordered course "++show oc++", rudder " ++ rudderReport r

-----------------------------
----- utility functions ----
-----------------------------
Expand Down

0 comments on commit c24d40a

Please sign in to comment.