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
| (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})) |
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
| (defmacro- make-command [name block] | |
| `(defn ~(symbol name) [& args#] | |
| (if args# (~block args#) (~block)))) |
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
| # 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 |
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
| # 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 |
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
| #!/bin/bash -x | |
| source ~/.bashrc | |
| rvm use 1.9.2@project | |
| bundle install | |
| rake db:migrate | |
| rake spec | |
| HEADLESS=true rake cucumber |
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
| # ! | |
| return (a > b) | |
| # !! | |
| if (a > b) | |
| return true | |
| else | |
| return false | |
| # !!! |
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
| (def gray 0) | |
| (def black 1) | |
| (def white 2) | |
| (defn board [size] (vec (repeat * size size) gray)) |
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 out-of-bound [point size] (or (< point 0) (> point (dec size)))) |
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 gray? [board point size] (= gray (nth board point))) |
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 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)] |