Permalink
Browse files

let waiting take time for AI monsters; close #42

  • Loading branch information...
1 parent 5d1700f commit f04d77d7e86dccda9a0808c6536b76f8df0d4a64 @Mikolaj Mikolaj committed Jul 7, 2011
Showing with 7 additions and 3 deletions.
  1. +6 −2 src/StrategyState.hs
  2. +1 −1 src/Turn.hs
View
@@ -25,6 +25,8 @@ import qualified ItemKind
import Item
import qualified Effect
+-- import Debug.Trace
+
strategy :: Actor -> State -> Perceptions -> Strategy (Action ())
strategy actor
oldState@(State { scursor = cursor,
@@ -34,6 +36,7 @@ strategy actor
lsmell = nsmap,
lmap = lmap } })
per =
+-- trace (show time ++ ": " ++ show actor) $
strategy
where
Movable { mkind = mk, mloc = me, mdir = mdir,
@@ -168,6 +171,7 @@ dirToAction actor tgt allowAttacks dir =
-- perform action
tryWith (advanceTime actor) $
-- if the following action aborts, we just advance the time and continue
+ -- TODO: ensure time is taken for other aborted actions in this file
moveOrAttack allowAttacks True actor dir
onlyMoves :: (Dir -> Bool) -> Loc -> Strategy Dir -> Strategy Dir
@@ -176,5 +180,5 @@ onlyMoves p l = only (\ x -> p (l `shift` x))
moveRandomly :: Strategy Dir
moveRandomly = liftFrequency $ uniform moves
-wait :: Strategy (Action ())
-wait = return $ return ()
+wait :: Actor -> Strategy (Action ())
+wait actor = return $ advanceTime actor
View
@@ -109,7 +109,7 @@ handleMonster actor =
-- Run the AI: choses an action from those given by the AI strategy.
action <-
liftIO $ rndToIO $
- frequency (head (runStrategy (strategy actor state per .| wait)))
+ frequency (head (runStrategy (strategy actor state per .| wait actor)))
action
handleMonsters

0 comments on commit f04d77d

Please sign in to comment.