Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pelensky's full-sized avatar

Dan Pelensky pelensky

View GitHub Profile

Keybase proof

I hereby claim:

  • I am pelensky on github.
  • I am pelensky (https://keybase.io/pelensky) on keybase.
  • I have a public key ASAFyvEoyVgoewByUAdPqSca5BlRi00zTZHBQTmmJ7UdEAo

To claim this, I am signing this object:

@pelensky
pelensky / app-runner.clj
Created August 11, 2017 10:14
App Runner namespace, with parts of the code I haven't changed removed.
(ns tic-tac-toe.app-runner
(:require clj-http.client :as client]))
; Code removed
(defn- api-call [board-state]
(let [result (client/post "https://xast1bug7h.execute-api.us-east-1.amazonaws.com/ttt" {:form-params {"boardState" (str board-state)} :content-type :json} )]
(read-string (get result :body))))
(defn- player-move [board-state player]
@pelensky
pelensky / computer.clj
Last active August 11, 2017 10:20
All functions required for Network Computer Player Lambda
(ns computer
(:gen-class
:methods [[handler [networkplayer.BoardObject] Long]]) )
(declare negamax)
(def starting-depth 0)
(def starting-colour 1)
; Code removed
@pelensky
pelensky / boardObject.java
Created August 11, 2017 09:45
Board Object class with a getter and a setter to get JSON into Clojure
package networkplayer;
public class BoardObject {
private String boardState;
public void setBoardState(String boardState) {
this.boardState = boardState;
}
@pelensky
pelensky / life.clj
Last active August 1, 2017 08:07
Game Of Life Logic for an Infinite World in Clojure
(ns game-of-life.life)
(def fewest-neighbours-to-stay-living 2)
(def most-neighbours-to-stay-living 3)
(def exact-neighbours-to-regenerate 3)
(def neighbours
[ [-1 1] [0 1] [1 1]
[-1 0] [1 0]
[-1 -1] [0 -1] [1 -1]])
@pelensky
pelensky / display.clj
Created August 1, 2017 07:49
Game Of Life Display for an Infinite World in Clojure
(ns game-of-life.display)
(defn- current-x [coordinates]
(get (first coordinates) 0))
(defn- current-y [coordinates]
(get (first coordinates) 1))
(defn- remaining [coordinates]
into [] (rest coordinates))
@pelensky
pelensky / unbeatable_computer.clj
Created July 28, 2017 07:29
Negamax in Clojure - no Alpha Beta pruning
(ns tic-tac-toe.unbeatable-computer
(:require [tic-tac-toe.board :as ttt-board]))
(declare negamax)
(def starting-depth 0)
(def starting-colour 1)
(defn find-computer-marker [board-state]
(if ( #(even? (count %)) (get board-state :board))
"X" "O"))