anchor.diff:      "You feel suddenly weak. Make a DC 10 Con save or take 2d6 necrotic damage."
       "Zombies attack!"
       "The floor gives way and you fall in a pit. Take 1d6 falling damage"
  +    "Mutants attack!"
  +    "A Pit Fiend attacks!"
  +    "A Blue Dragon attacks!"
  +    "Carrion crawler attacks!"
  +    "You find a body, a suit of chain mail, and 500 gp."
       |]
     let mutable events = [
       for i in 1..n do
  
positive.code:         let cellWidth = w/float xlen
          let toX x = float x * cellWidth
          let toY y = float y * cellHeight
          g.lineStyle(5., float 0x696969 ) |> ignore
          g.moveTo(0.,2.).lineTo(w,2.).moveTo(2.,0.).lineTo(2.,h) |> ignore
          g.moveTo(0.,h-2.).lineTo(w,h-2.).moveTo(w-2.,0.).lineTo(w-2.,h) |> ignore
          for x in 0 .. xlen - 1 do
            for y in 0.. ylen - 1 do
              let left = (float x) * cellWidth
              let right = (float x + 1.) * cellWidth
              let top = (float y) * cellHeight
              let bottom = (float y + 1.) * cellHeight
              if not <| Maze.rightOpen maze (x,y) then
                g.moveTo(right, top).lineTo(right, bottom) |> ignore
              if not <| Maze.downOpen maze (x,y) then
                g.moveTo(left, bottom).lineTo(right, bottom) |> ignore
          // Also, draw the current position in red
          let left, top =
            match model.currentPosition with
            | (x,y) -> toX x, toY y
          g.lineStyle(0.).beginFill(float 0x891121)
            .drawRect(left + 10., top + 10., cellWidth - 20., cellHeight - 20.) // leave 10-pixel margin because it looks good
            .endFill() |> ignore
          for (x,y,msg) in model.messages do
            let elide maxLen (msg:string) =
              if msg.Length > maxLen then msg.Substring(0, maxLen) + "..."
  
negative.code:   let up = KeyDetect 38
    let right = KeyDetect 39
    let down = KeyDetect 40
  
  type DisplayObject with
    member this.finish = ()
  
  let view (model: ViewModel) dispatch =
    Key.left.Pressed <- delay dispatch (Move Left)
  