forked from ggp-org/ggp-base
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ggp-org#25 from orb/clojurestub
make Clojure player more idiomatic
- Loading branch information
Showing
1 changed file
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
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")))) |