Created
December 5, 2012 14:10
-
-
Save jbrechtel/4215778 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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