Skip to content

Instantly share code, notes, and snippets.

@naush
naush / console.clj
Created December 20, 2010 17:54
gtp implementation example
(ns gtp.example.console
(:refer-clojure :exclude [name])
(:require [gtp.core :as gtp] :reload)
(:gen-class))
(defn board []
(let [size (atom 19)]
{:set-size #(reset! size %1)
:get-size @size}))
@naush
naush / make-command.clj
Created December 20, 2010 18:18
gtp implementation detail
(defmacro- make-command [name block]
`(defn ~(symbol name) [& args#]
(if args# (~block args#) (~block))))
# install Firefox, or any other browser under testing
apt-get install firefox
# install Xvfb
apt-get install xvfb
# boost X11 server
Xvfb :99 -ac -screen 0 1024x768x16
# set up environmental variable
export DISPLAY=:99
# launch Firefox
firefox
# add this code to "features/support/env.rb"
if ENV['HEADLESS'] == 'true'
require 'headless'
headless = Headless.new
headless.start
at_exit do
headless.destroy
end
#!/bin/bash -x
source ~/.bashrc
rvm use 1.9.2@project
bundle install
rake db:migrate
rake spec
HEADLESS=true rake cucumber
# !
return (a > b)
# !!
if (a > b)
return true
else
return false
# !!!
(def gray 0)
(def black 1)
(def white 2)
(defn board [size] (vec (repeat * size size) gray))
(defn out-of-bound [point size] (or (< point 0) (> point (dec size))))
(defn gray? [board point size] (= gray (nth board point)))
(defn ally? [board point color] (= color (nth board point)))
(defn new-ally? [board point color ally]
(and (ally? board point color) (not (.contains ally point))))
(defn find-neighbors [point size]
(let [north (- point size)
east (inc point)
south (+ point size)
west (dec point)]