Skip to content

Commit

Permalink
Merge pull request ggp-org#25 from orb/clojurestub
Browse files Browse the repository at this point in the history
make Clojure player more idiomatic
  • Loading branch information
samschreiber committed Oct 28, 2013
2 parents 16bbc90 + 4175ef9 commit 90d92a8
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src_clj/sample_gamer.clj
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
; An implementation of a sample random gamer in Clojure.
; -Sam Schreiber

; NOTE: the implicit 'this symbol is bound to the local class.

(ns gamer_namespace)
(ns gamer_namespace
(:import [org.ggp.base.player.gamer.statemachine StateMachineGamer]
[org.ggp.base.util.statemachine.implementation.prover ProverStateMachine]))

;; An implementation of a sample random gamer in Clojure.
;; -Sam Schreiber
(defn SampleClojureGamer []
(proxy [org.ggp.base.player.gamer.statemachine.StateMachineGamer] []
(proxy [StateMachineGamer] []
;; NOTE: the implicit 'this symbol is bound to the local class.

(getInitialStateMachine []
(new org.ggp.base.util.statemachine.implementation.prover.ProverStateMachine))
(ProverStateMachine.))

(stateMachineSelectMove [timeout]
(.
(. this (getStateMachine) [])
(getRandomMove
(. this (getCurrentState) [])
(. this (getRole) [])
)
)
)

(stateMachineMetaGame [timeout] ())
(stateMachineAbort [] ())
(stateMachineStop [] ())
(getName [] ())
)
)
(let [state-machine (.getStateMachine this)
current-state (.getCurrentState this)
role (.getRole this)
random-move (.getRandomMove state-machine
current-state
role)]
random-move))

(stateMachineMetaGame [timeout]
(println "SampleClojureGamer metagame called"))

(stateMachineAbort []
(println "SampleClojureGamer abort called"))

(stateMachineStop []
(println "SampleClojureGamer stop called"))))

0 comments on commit 90d92a8

Please sign in to comment.