Skip to content

Instantly share code, notes, and snippets.

@aryairani
Created December 19, 2012 15:34
Show Gist options
  • Save aryairani/4337557 to your computer and use it in GitHub Desktop.
Save aryairani/4337557 to your computer and use it in GitHub Desktop.
trait AbstractAgent[S,A] {
type Self = AbstractAgent[S,A]
def learn(s: S): Self
}
trait GameDomain {
type State
type Action
type Agent <: AbstractAgent[State, Action]
}
case class LearningSimulation[G<:GameDomain with Singleton]( agent: G#Agent,
state: G#State)
{
def step: LearningSimulation[G] = {
def newAgent = agent.learn(state): G#Agent // type mismatch
copy(agent = newAgent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment