simplify stockfish play actor FSM

This commit is contained in:
Thibault Duplessis 2012-07-11 21:14:15 +02:00
parent 0175b72c8d
commit 9d464a758b

View file

@ -46,13 +46,10 @@ final class PlayFSM(
whenUnhandled {
case Event(play: Play, data)
next(data enqueue Task(play, sender))
case Event(GetQueueSize, data)
case Event(GetQueueSize, data)
sender ! QueueSize(data.queue.size); stay
case Event(Out(""), _) stay
case Event(Out(t), _) if t startsWith "id " stay
case Event(Out(t), _) if t startsWith "info " stay
case Event(Out(t), _) if t startsWith "option name " stay
case Event(Err(t), _) { log.error(t); stay }
case Event(Out(t), _) if isNoise(t) stay
case Event(Err(t), _) { log.error(t); stay }
}
def next(data: Data) = data match {
@ -68,6 +65,9 @@ final class PlayFSM(
case doing: Doing stay using data
}
def isNoise(t: String) =
t.isEmpty || (t startsWith "id ") || (t startsWith "info ") || (t startsWith "option name ")
def onTermination() {
process.destroy()
}