-
-
Save whostolebenfrog/5868115 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
;; the backup bot where my real one failed | |
;; function name is ben | |
(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