Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
Created December 5, 2012 14:10
Show Gist options
  • Select an option

  • Save jbrechtel/4215778 to your computer and use it in GitHub Desktop.

Select an option

Save jbrechtel/4215778 to your computer and use it in GitHub Desktop.
(defn cell-state [room x-pos y-pos]
(cond
(> 0 x-pos) :wall
(> 0 y-pos) :wall
(<= (count room) x-pos) :wall
(<= (count room) y-pos) :wall
:else ((room x-pos) y-pos)))
(defn agent-state [room, x-pos, y-pos]
(let [current (cell-state room x-pos y-pos)
north (cell-state room x-pos (- y-pos 1))
south (cell-state room x-pos (+ y-pos 1))
east (cell-state room (+ x-pos 1) y-pos)
west (cell-state room (- x-pos 1) y-pos)]
{:current current :north north :south south :east east :west west}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment