Example #1
0
 def main(cls, args):
     """ generated source for method main """
     GamerLogger.setSpilloverLogfile("spilloverLog")
     GamerLogger.log("Proxy", "Starting the ProxyGamePlayerClient program.")
     if not (len(args)):
         GamerLogger.logError("Proxy", "Usage is: \n\tProxyGamePlayerClient gamer port")
         return
     port = 9147
     gamer = None
     try:
         port = Integer.valueOf(args[1])
     except Exception as e:
         GamerLogger.logError("Proxy", args[1] + " is not a valid port.")
         return
     gamers = Lists.newArrayList(ProjectSearcher.GAMERS.getConcreteClasses())
     gamerNames = ArrayList()
     if len(gamerNames) != len(gamers):
         for c in gamers:
             gamerNames.add(c.__name__.replaceAll("^.*\\.", ""))
     idx = gamerNames.indexOf(args[0])
     if idx == -1:
         GamerLogger.logError("Proxy", args[0] + " is not a subclass of gamer.  Valid options are:")
         for s in gamerNames:
             GamerLogger.logError("Proxy", "\t" + s)
         return
     try:
         gamer = (gamers.get(idx).newInstance())
     except Exception as ex:
         GamerLogger.logError("Proxy", "Cannot create instance of " + args[0])
         return
     try:
         theClient.start()
     except IOException as e:
         GamerLogger.logStackTrace("Proxy", e)
Example #2
0
 def abort(self):
     """ generated source for method abort """
     try:
         self.stateMachineAbort()
     except Exception as e:
         GamerLogger.logStackTrace("GamePlayer", e)
         raise AbortingException(e)
Example #3
0
 def process(self, receptionTime):
     """ generated source for method process """
     #  Ensure that we aren't already playing a match. If we are,
     #  ignore the message, saying that we're busy.
     if self.gamer.getMatch() != None:
         GamerLogger.logError("GamePlayer", "Got start message while already busy playing a game: ignoring.")
         self.gamer.notifyObservers(GamerUnrecognizedMatchEvent(self.matchId))
         return "busy"
     #  Create the new match, and handle all of the associated logistics
     #  in the gamer to indicate that we're starting a new match.
     match = Match(self.matchId, -1, self.startClock, self.playClock, self.game)
     self.gamer.setMatch(match)
     self.gamer.setRoleName(self.roleName)
     self.gamer.notifyObservers(GamerNewMatchEvent(match, self.roleName))
     #  Finally, have the gamer begin metagaming.
     try:
         self.gamer.notifyObservers(PlayerTimeEvent(self.gamer.getMatch().getStartClock() * 1000))
         self.gamer.metaGame(self.gamer.getMatch().getStartClock() * 1000 + receptionTime)
     except MetaGamingException as e:
         GamerLogger.logStackTrace("GamePlayer", e)
         #  Upon encountering an uncaught exception during metagaming,
         #  assume that indicates that we aren't actually able to play
         #  right now, and tell the server that we're busy.
         self.gamer.setMatch(None)
         self.gamer.setRoleName(None)
         return "busy"
     return "ready"
Example #4
0
 def __init__(self, parentThread):
     """ generated source for method __init__ """
     super(ClientManager, self).__init__()
     self.parentThread = parentThread
     command = GamerConfiguration.getCommandForJava()
     processArgs = ArrayList()
     processArgs.add(command)
     processArgs.add("-mx" + GamerConfiguration.getMemoryForGamer() + "m")
     processArgs.add("-server")
     processArgs.add("-XX:-DontCompileHugeMethods")
     processArgs.add("-XX:MinHeapFreeRatio=10")
     processArgs.add("-XX:MaxHeapFreeRatio=10")
     processArgs.add("-classpath")
     processArgs.add(System.getProperty("java.class.path"))
     processArgs.add("org.ggp.base.player.proxy.ProxyGamePlayerClient")
     processArgs.add(self.gamerName)
     processArgs.add("" + self.clientListener.getLocalPort())
     if GamerConfiguration.runningOnLinux():
         processArgs.add(0, "nice")
     pb = ProcessBuilder(processArgs)
     try:
         GamerLogger.log("Proxy", "[PROXY] Starting a new proxy client, using gamer " + self.gamerName + ".")
         self.theClientProcess = pb.start()
         self.outConnector = StreamConnector(self.theClientProcess.getErrorStream(), System.err)
         self.errConnector = StreamConnector(self.theClientProcess.getInputStream(), System.out)
         self.outConnector.start()
         self.errConnector.start()
         self.theClientConnection = self.clientListener.accept()
         self.theOutput = PrintStream(self.theClientConnection.getOutputStream())
         self.theInput = BufferedReader(InputStreamReader(self.theClientConnection.getInputStream()))
         GamerLogger.log("Proxy", "[PROXY] Proxy client started.")
     except IOException as e:
         GamerLogger.logStackTrace("Proxy", e)
Example #5
0
 def create(cls, description):
     """ generated source for method create """
     try:
         GamerLogger.log("StateMachine", "Converting...")
         return PropNetConverter().convert(Role.computeRoles(description), flatDescription)
     except Exception as e:
         GamerLogger.logStackTrace("StateMachine", e)
         return None
Example #6
0
 def renderToFile(self, filename):
     """ generated source for method renderToFile """
     try:
         fout.write(self.__str__())
         fout.close()
         fos.close()
     except Exception as e:
         GamerLogger.logStackTrace("StateMachine", e)
Example #7
0
 def preview(self, game, timeout):
     """ generated source for method preview """
     self.lazilyLoadGamerStub()
     try:
         self.theClojureGamer.preview(game, timeout)
     except GamePreviewException as e:
         GamerLogger.logError("GamePlayer", "Caught exception in Clojure stateMachineMetaGame:")
         GamerLogger.logStackTrace("GamePlayer", e)
Example #8
0
 def abort(self):
     """ generated source for method abort """
     self.lazilyLoadGamerStub()
     self.theClojureGamer.setMatch(getMatch())
     self.theClojureGamer.setRoleName(getRoleName())
     try:
         self.theClojureGamer.abort()
     except AbortingException as e:
         GamerLogger.logError("GamePlayer", "Caught exception in Clojure stateMachineAbort:")
         GamerLogger.logStackTrace("GamePlayer", e)
Example #9
0
 def metaGame(self, timeout):
     """ generated source for method metaGame """
     self.lazilyLoadGamerStub()
     self.theClojureGamer.setMatch(getMatch())
     self.theClojureGamer.setRoleName(getRoleName())
     try:
         self.theClojureGamer.metaGame(timeout)
     except MetaGamingException as e:
         GamerLogger.logError("GamePlayer", "Caught exception in Clojure stateMachineMetaGame:")
         GamerLogger.logStackTrace("GamePlayer", e)
Example #10
0
 def lazilyLoadGamerStub(self):
     """ generated source for method lazilyLoadGamerStub """
     if self.thePythonGamer == None:
         try:
             #  Load in the Python gamer, using a Jython intepreter.
             interpreter.exec_("from " + self.getPythonGamerModule() + " import " + self.getPythonGamerName())
             self.thePythonGamer = PyGamerObject.__tojava__(Gamer.__class__)
         except Exception as e:
             GamerLogger.logError("GamePlayer", "Caught exception in Python initialization:")
             GamerLogger.logStackTrace("GamePlayer", e)
Example #11
0
 def stop(self):
     """ generated source for method stop """
     self.lazilyLoadGamerStub()
     self.thePythonGamer.setMatch(getMatch())
     self.thePythonGamer.setRoleName(getRoleName())
     try:
         self.thePythonGamer.stop()
     except StoppingException as e:
         GamerLogger.logError("GamePlayer", "Caught exception in Python stateMachineStop:")
         GamerLogger.logStackTrace("GamePlayer", e)
Example #12
0
 def selectMove(self, timeout):
     """ generated source for method selectMove """
     self.lazilyLoadGamerStub()
     self.theClojureGamer.setMatch(getMatch())
     self.theClojureGamer.setRoleName(getRoleName())
     try:
         return self.theClojureGamer.selectMove(timeout)
     except MoveSelectionException as e:
         GamerLogger.logError("GamePlayer", "Caught exception in Clojure stateMachineSelectMove:")
         GamerLogger.logStackTrace("GamePlayer", e)
         return None
Example #13
0
 def closeClient(self):
     """ generated source for method closeClient """
     try:
         self.outConnector.pleaseStop = True
         self.errConnector.pleaseStop = True
         self.theClientConnection.close()
         self.theInput = None
         self.theOutput = None
     except IOException as e:
         GamerLogger.logStackTrace("Proxy", e)
     self.theClientProcess.destroy()
Example #14
0
 def lazilyLoadGamerStub(self):
     """ generated source for method lazilyLoadGamerStub """
     if self.theClojureGamer == None:
         try:
             #  Load the Clojure script -- as a side effect this initializes the runtime.
             RT.loadResourceScript(self.getClojureGamerFile() + ".clj")
             #  Get a reference to the gamer-generating function.
             #  Call it!
             self.theClojureGamer = gamerVar.invoke()
         except Exception as e:
             GamerLogger.logError("GamePlayer", "Caught exception in Clojure initialization:")
             GamerLogger.logStackTrace("GamePlayer", e)
Example #15
0
 def metaGame(self, timeout):
     """ generated source for method metaGame """
     try:
         stateMachine = self.getInitialStateMachine()
         stateMachine.initialize(getMatch().getGame().getRules())
         currentState = stateMachine.getInitialState()
         role = stateMachine.getRoleFromConstant(getRoleName())
         getMatch().appendState(currentState.getContents())
         self.stateMachineMetaGame(timeout)
     except Exception as e:
         GamerLogger.logStackTrace("GamePlayer", e)
         raise MetaGamingException(e)
Example #16
0
 def selectMove(self, timeout):
     """ generated source for method selectMove """
     try:
         stateMachine.doPerMoveWork()
         if lastMoves != None:
             for sentence in lastMoves:
                 moves.add(stateMachine.getMoveFromTerm(sentence))
             currentState = stateMachine.getNextState(currentState, moves)
             getMatch().appendState(currentState.getContents())
         return self.stateMachineSelectMove(timeout).getContents()
     except Exception as e:
         GamerLogger.logStackTrace("GamePlayer", e)
         raise MoveSelectionException(e)
Example #17
0
 def stop(self):
     """ generated source for method stop """
     try:
         stateMachine.doPerMoveWork()
         if lastMoves != None:
             for sentence in lastMoves:
                 moves.add(stateMachine.getMoveFromTerm(sentence))
             currentState = stateMachine.getNextState(currentState, moves)
             getMatch().appendState(currentState.getContents())
             getMatch().markCompleted(stateMachine.getGoals(currentState))
         self.stateMachineStop()
     except Exception as e:
         GamerLogger.logStackTrace("GamePlayer", e)
         raise StoppingException(e)
Example #18
0
 def run(self):
     """ generated source for method run """
     while True:
         try:
             if self.inputQueue.remainingCapacity() > 0:
                 self.inputQueue.add(ProxyMessage(in_, 0L, receptionTime))
                 self.inputConnectionQueue.add(connection)
                 GamerLogger.log("Proxy", "[PROXY QueueListener] Got incoming message from game server: " + in_ + ". Added to queue in position " + len(self.inputQueue) + ".")
             else:
                 GamerLogger.logError("Proxy", "[PROXY QueueListener] Got incoming message from game server: " + in_ + ". Could not add to queue, because queue is full!")
         except Exception as e:
             GamerLogger.logStackTrace("Proxy", e)
         except Error as e:
             GamerLogger.logStackTrace("Proxy", e)
Example #19
0
 def switchStateMachine(self, newStateMachine):
     """ generated source for method switchStateMachine """
     try:
         #  Attempt to run through the game history in the new machine
         for nextMove in theMoveHistory:
             for theSentence in nextMove:
                 theJointMove.add(newStateMachine.getMoveFromTerm(theSentence))
             newCurrentState = newStateMachine.getNextStateDestructively(newCurrentState, theJointMove)
         #  Finally, switch over if everything went well.
         role = newRole
         currentState = newCurrentState
         stateMachine = newStateMachine
     except Exception as e:
         GamerLogger.log("GamePlayer", "Caught an exception while switching state machine!")
         GamerLogger.logStackTrace("GamePlayer", e)
Example #20
0
 def process(self, receptionTime):
     """ generated source for method process """
     #  First, check to ensure that this play request is for the match
     #  we're currently playing. If we're not playing a match, or we're
     #  playing a different match, send back "busy".
     if self.gamer.getMatch() == None or not self.gamer.getMatch().getMatchId() == self.matchId:
         self.gamer.notifyObservers(GamerUnrecognizedMatchEvent(self.matchId))
         GamerLogger.logError("GamePlayer", "Got play message not intended for current game: ignoring.")
         return "busy"
     if self.moves != None:
         self.gamer.getMatch().appendMoves(self.moves)
     try:
         self.gamer.notifyObservers(PlayerTimeEvent(self.gamer.getMatch().getPlayClock() * 1000))
         return self.gamer.selectMove(self.gamer.getMatch().getPlayClock() * 1000 + receptionTime).__str__()
     except MoveSelectionException as e:
         GamerLogger.logStackTrace("GamePlayer", e)
         return "nil"
Example #21
0
 def failGracefully(self, e1, e2):
     """ generated source for method failGracefully """
     if e1 != None:
         GamerLogger.logStackTrace("StateMachine", e1)
     if e2 != None:
         GamerLogger.logStackTrace("StateMachine", e2)
     GamerLogger.logError("StateMachine", "Failsafe Machine: graceful failure mode kicking in.")
     if self.theBackingMachine.__class__ != ProverStateMachine.__class__:
         GamerLogger.logError(
             "StateMachine",
             "Failsafe Machine: online failure for "
             + self.theBackingMachine.__class__
             + ". Attempting to restart with a standard prover.",
         )
         if attemptLoadingProverMachine():
             return
     self.theBackingMachine = None
     GamerLogger.logError("StateMachine", "Failsafe Machine: online failure for regular prover. Cannot recover.")
Example #22
0
 def process(self, receptionTime):
     """ generated source for method process """
     #  First, check to ensure that this abort request is for the match
     #  we're currently playing. If we're not playing a match, or we're
     #  playing a different match, send back "busy".
     if self.gamer.getMatch() == None or not self.gamer.getMatch().getMatchId() == self.matchId:
         GamerLogger.logError("GamePlayer", "Got abort message not intended for current game: ignoring.")
         self.gamer.notifyObservers(GamerUnrecognizedMatchEvent(self.matchId))
         return "busy"
     self.gamer.getMatch().markAborted()
     self.gamer.notifyObservers(GamerAbortedMatchEvent())
     try:
         self.gamer.abort()
     except AbortingException as e:
         GamerLogger.logStackTrace("GamePlayer", e)
     self.gamer.setRoleName(None)
     self.gamer.setMatch(None)
     return "aborted"
Example #23
0
 def readFrom(cls, theInput):
     """ generated source for method readFrom """
     try:
         return ProxyMessage(cls.theMessage, cls.messageCode, cls.receptionTime)
     except SocketException as se:
         GamerLogger.log("Proxy", "[ProxyMessage Reader] Socket closed: stopping read operation.")
         raise se
     except Exception as e:
         GamerLogger.logStackTrace("Proxy", e)
         GamerLogger.logError("Proxy", "[ProxyMessage Reader] Could not digest message. Emptying stream.")
         try:
             #  TODO: Fix this, I suspect it may be buggy.
             theInput.skip(Long.MAX_VALUE)
         except SocketException as se:
             GamerLogger.log("Proxy", "[ProxyMessage Reader] Socket closed: stopping read operation.")
             raise se
         except Exception as ie:
             GamerLogger.logStackTrace("Proxy", ie)
         return None
Example #24
0
 def process(self, receptionTime):
     """ generated source for method process """
     #  Ensure that we aren't already playing a match. If we are,
     #  ignore the message, saying that we're busy.
     if self.gamer.getMatch() != None:
         GamerLogger.logError("GamePlayer", "Got preview message while already busy playing a game: ignoring.")
         # gamer.notifyObservers(new GamerUnrecognizedMatchEvent(matchId));
         return "busy"
     #  Otherwise, if we're not busy, have the gamer start previewing.
     try:
         # gamer.notifyObservers(new PlayerTimeEvent(gamer.getMatch().getStartClock() * 1000));
         self.gamer.preview(self.game, self.previewClock * 1000 + receptionTime)
         # gamer.metaGame(gamer.getMatch().getStartClock() * 1000 + receptionTime);
     except GamePreviewException as e:
         GamerLogger.logStackTrace("GamePlayer", e)
         #  Upon encountering an uncaught exception during previewing,
         #  assume that indicates that we aren't actually able to play
         #  right now, and tell the server that we're busy.
         return "busy"
     return "ready"
Example #25
0
 def run(self):
     """ generated source for method run """
     while not isInterrupted():
         try:
             GamerLogger.log("Proxy", "[ProxyClient] Got message: " + theMessage)
             self.theCode = theMessage.messageCode
             self.notifyObservers(PlayerReceivedMessageEvent(in_))
             if isinstance(request, (StartRequest, )):
                 RequestFactory().create(theDefaultGamer, in_).process(1)
                 GamerLogger.startFileLogging(theDefaultGamer.getMatch(), theDefaultGamer.getRoleName().__str__())
                 GamerLogger.log("Proxy", "[ProxyClient] Got message: " + theMessage)
             outMessage.writeTo(self.theOutput)
             GamerLogger.log("Proxy", "[ProxyClient] Sent message: " + outMessage)
             self.notifyObservers(PlayerSentMessageEvent(out))
             if isinstance(request, (StopRequest, )):
                 GamerLogger.log("Proxy", "[ProxyClient] Got stop request, shutting down.")
                 System.exit(0)
             if isinstance(request, (AbortRequest, )):
                 GamerLogger.log("Proxy", "[ProxyClient] Got abort request, shutting down.")
                 System.exit(0)
         except Exception as e:
             GamerLogger.logStackTrace("Proxy", e)
             self.notifyObservers(PlayerDroppedPacketEvent())
     GamerLogger.log("Proxy", "[ProxyClient] Got interrupted, shutting down.")
Example #26
0
 def run(self):
     """ generated source for method run """
     try:
         while not self.pleaseStop:
             if next == -1:
                 break
             if not self.isPrintableChar(str(next)):
                 next = '@'
             self.theOutput.write(next)
     except IOException as e:
         GamerLogger.log("Proxy", "Might be okay:")
         GamerLogger.logStackTrace("Proxy", e)
     except Exception as e:
         GamerLogger.logStackTrace("Proxy", e)
     except Error as e:
         GamerLogger.logStackTrace("Proxy", e)
Example #27
0
 def run(self):
     """ generated source for method run """
     while self.theInput != None:
         try:
             if self.pleaseStop:
                 return
             GamerLogger.log("Proxy", "[PROXY] Got message from client: " + in_)
             if in_ == None:
                 continue 
             processClientResponse(in_, self.parentThread)
         except SocketException as se:
             if self.expectStop:
                 return
             GamerLogger.logStackTrace("Proxy", se)
             GamerLogger.logError("Proxy", "Shutting down reader as consequence of socket exception. Presumably this is because the gamer client crashed.")
             break
         except Exception as e:
             GamerLogger.logStackTrace("Proxy", e)
         except Error as e:
             GamerLogger.logStackTrace("Proxy", e)
Example #28
0
 def run(self):
     """ generated source for method run """
     GamerConfiguration.showConfiguration()
     GamerLogger.setSpilloverLogfile("spilloverLog")
     #  Start up the client manager
     self.theClientManager = self.ClientManager(Thread.currentThread())
     self.theClientManager.start()
     #  Start up the input queue listener
     inputQueue = ArrayBlockingQueue(100)
     inputConnectionQueue = ArrayBlockingQueue(100)
     theListener = QueueListenerThread()
     theListener.start()
     while True:
         try:
             #  First, read a message from the server.
             self.notifyObservers(PlayerReceivedMessageEvent(in_))
             GamerLogger.log("Proxy", "[PROXY] Got incoming message:" + in_)
             #  Formulate a request, and see how the legal gamer responds.
             try:
                 legalProxiedResponse = request.process(receptionTime)
             except OutOfMemoryError as e:
                 #  Something went horribly wrong -- our baseline prover failed.
                 System.gc()
                 GamerLogger.logStackTrace("Proxy", e)
                 legalProxiedResponse = "SORRY"
             latestProxiedResponse = legalProxiedResponse
             GamerLogger.log("Proxy", "[PROXY] Selected fallback move:" + latestProxiedResponse)
             if not (isinstance(request, (InfoRequest, ))):
                 #  Update the move codes and prepare to send the request on to the client.
                 self.receivedClientMove = False
                 self.currentMoveCode = 1 + self.theRandomGenerator.nextLong()
                 if isinstance(request, (StopRequest, )) or isinstance(request, (AbortRequest, )):
                     self.theClientManager.expectStop = True
                 #  Send the request on to the client, along with the move code.
                 self.theClientManager.sendMessage(theMessage)
                 if not (isinstance(request, (PlayRequest, ))):
                     self.currentMoveCode = 0L
                 #  the default gamer handle it by switching move code.
                 #  Wait the appropriate amount of time for the request.
                 proxyProcessRequest(request, receptionTime)
             else:
                 self.receivedClientMove = True
             #  Get the latest response, and complain if it's the default response, or isn't a valid response.
             if not self.receivedClientMove and (isinstance(request, (PlayRequest, ))):
                 GamerLogger.logError("Proxy", "[PROXY] Did not receive any move information from client for this turn; falling back to first legal move.")
                 GamerLogger.logError("ExecutiveSummary", "Proxy did not receive any move information from client this turn: used first legal move.")
             #  Cycle the move codes again so that we will ignore any more responses
             #  that the client sends along to us.
             self.currentMoveCode = 0L
             #  And finally write the latest response out to the server.
             GamerLogger.log("Proxy", "[PROXY] Wrote outgoing message:" + out)
             HttpWriter.writeAsServer(connection, out)
             connection.close()
             self.notifyObservers(PlayerSentMessageEvent(out))
             #  Once everything is said and done, restart the client if we're
             #  due for a restart (having finished playing a game).
             if self.needRestart:
                 self.theClientManager.closeClient()
                 self.theClientManager.pleaseStop = True
                 if GamerConfiguration.runningOnLinux():
                     #  Clean up the working directory and terminate any orphan processes.
                     Thread.sleep(500)
                     GamerLogger.log("Proxy", "[PROXY] Calling cleanup scripts.")
                     try:
                         Runtime.getRuntime().exec_("./cleanup.sh").waitFor()
                     except IOException as e:
                         GamerLogger.logStackTrace("Proxy", e)
                     Thread.sleep(500)
                 self.theClientManager = self.ClientManager(Thread.currentThread())
                 self.theClientManager.start()
                 self.theDefaultGamer = RandomGamer()
                 GdlPool.drainPool()
                 SymbolPool.drainPool()
                 GamerLogger.log("Proxy", "[PROXY] Before collection, using " + usedMemoryInMegs + "mb of memory as proxy.")
                 while i < 10:
                     System.gc()
                     Thread.sleep(100)
                     i += 1
                 usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()
                 usedMemoryInMegs = usedMemory / 1024.0 / 1024.0
                 GamerLogger.log("Proxy", "[PROXY] After collection, using a non-transient " + usedMemoryInMegs + "mb of memory as proxy.")
                 print "Cleaned up completed match, with a residual " + usedMemoryInMegs + "mb of memory as proxy."
                 self.needRestart = False
         except Exception as e:
             GamerLogger.logStackTrace("Proxy", e)
             self.notifyObservers(PlayerDroppedPacketEvent())
         except Error as e:
             GamerLogger.logStackTrace("Proxy", e)
             self.notifyObservers(PlayerDroppedPacketEvent())
Example #29
0
 def checkMachineConsistency(cls, theReference, theSubject, timeToSpend):
     """ generated source for method checkMachineConsistency """
     startTime = System.currentTimeMillis()
     GamerLogger.log("StateMachine", "Performing automatic consistency testing on " + theSubject.__class__.__name__ + " using " + theReference.__class__.__name__ + " as a reference.")
     theMachines = ArrayList()
     theMachines.add(theReference)
     theMachines.add(theSubject)
     GamerLogger.emitToConsole("Consistency checking: [")
     nRound = 0
     while True:
         nRound += 1
         GamerLogger.emitToConsole(".")
         while i < len(theMachines):
             try:
                 theCurrentStates[i] = theMachines.get(i).getInitialState()
             except Exception as e:
                 GamerLogger.log("StateMachine", "Machine #" + i + " failed to generate an initial state!")
                 return False
             i += 1
         while not theMachines.get(0).isTerminal(theCurrentStates[0]):
             if System.currentTimeMillis() > startTime + timeToSpend:
                 break
             #  Do per-state consistency checks
             while i < len(theMachines):
                 for theRole in theMachines.get(0).getRoles():
                     try:
                         if not (theMachines.get(i).getLegalMoves(theCurrentStates[i], theRole).size() == theMachines.get(0).getLegalMoves(theCurrentStates[0], theRole).size()):
                             GamerLogger.log("StateMachine", "Inconsistency between machine #" + i + " and ProverStateMachine over state " + theCurrentStates[0] + " vs " + theCurrentStates[i].getContents())
                             GamerLogger.log("StateMachine", "Machine #" + 0 + " has move count = " + theMachines.get(0).getLegalMoves(theCurrentStates[0], theRole).size() + " for player " + theRole)
                             GamerLogger.log("StateMachine", "Machine #" + i + " has move count = " + theMachines.get(i).getLegalMoves(theCurrentStates[i], theRole).size() + " for player " + theRole)
                             return False
                     except Exception as e:
                         GamerLogger.logStackTrace("StateMachine", e)
                 i += 1
             try:
                 while i < len(theMachines):
                     try:
                         theCurrentStates[i] = theMachines.get(i).getNextState(theCurrentStates[i], theJointMove)
                     except Exception as e:
                         GamerLogger.logStackTrace("StateMachine", e)
                     i += 1
             except Exception as e:
                 GamerLogger.logStackTrace("StateMachine", e)
         if System.currentTimeMillis() > startTime + timeToSpend:
             break
         while i < len(theMachines):
             if not theMachines.get(i).isTerminal(theCurrentStates[i]):
                 GamerLogger.log("StateMachine", "Inconsistency between machine #" + i + " and ProverStateMachine over terminal-ness of state " + theCurrentStates[0] + " vs " + theCurrentStates[i])
                 return False
             for theRole in theMachines.get(0).getRoles():
                 try:
                     theMachines.get(0).getGoal(theCurrentStates[0], theRole)
                 except Exception as e:
                     continue 
                 try:
                     if theMachines.get(i).getGoal(theCurrentStates[i], theRole) != theMachines.get(0).getGoal(theCurrentStates[0], theRole):
                         GamerLogger.log("StateMachine", "Inconsistency between machine #" + i + " and ProverStateMachine over goal value for " + theRole + " of state " + theCurrentStates[0] + ": " + theMachines.get(i).getGoal(theCurrentStates[i], theRole) + " vs " + theMachines.get(0).getGoal(theCurrentStates[0], theRole))
                         return False
                 except Exception as e:
                     GamerLogger.log("StateMachine", "Inconsistency between machine #" + i + " and ProverStateMachine over goal-ness of state " + theCurrentStates[0] + " vs " + theCurrentStates[i])
                     return False
             i += 1
     GamerLogger.emitToConsole("]\n")
     GamerLogger.log("StateMachine", "Completed automatic consistency testing on " + theSubject.__class__.__name__ + ", w/ " + nRound + " rounds: all tests pass!")
     return True