Created
June 26, 2013 14:59
-
-
Save whostolebenfrog/5868081 to your computer and use it in GitHub Desktop.
Bot
This file contains 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
(ns tron.bots | |
(:require [tron.core :as tron])) | |
(defn up [[x y]] | |
[x (dec y)]) | |
(defn down [[x y]] | |
[x (inc y)]) | |
(defn left [[x y]] | |
[(dec x) y]) | |
(defn right [[x y]] | |
[(inc x) y]) | |
(defn neighbours [pos] | |
((juxt up down left right) pos)) | |
(defn valid-neighbours [look pos] | |
{:post [(not-any? look %)]} | |
(remove look (neighbours pos))) | |
(defn ben | |
[look {pos :pos}] | |
(if (look (up pos)) | |
{:pos (first (valid-neighbours look pos))} | |
{:pos (up pos)})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment