Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created July 9, 2011 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/ea397d8052c71fefbb4b to your computer and use it in GitHub Desktop.
Save amalloy/ea397d8052c71fefbb4b to your computer and use it in GitHub Desktop.
(defn simple-bot []
(let [state *game-state*]
(reduce (fn [state ant]
(binding [*game-state* state]
(when-let [dir (rand-nth (filter #(unoccupied?
(can-move? ant %))
directions))]
(let [new-pos (move-ant ant dir)]
(move ant dir) ; send actual command
(update-in state [:ants] #(-> % ; update state
(disj ant)
(conj new-pos)))))))
state
(my-ants))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment