Exemple #1
0
def reportBestGait(player):
   if player.firstFrame():
      (bestGaitArray, gaitScore) = player.swarm.getBestSolution()
      bestGaitTuple = arrayToGaitTuple(bestGaitArray)

      print "best found gait's heuristic score was: ", gaitScore

      try:
         gaitScore = int(gaitScore)
         output = BEST_GAIT_FILE + str(gaitScore)

         i = 1
         while isfile(output):
            output = BEST_GAIT_FILE + str(gaitScore) + "." + str(i)
            i += 1

         print "best gait saved to file: ", output
         f = open(output, 'w')
         pickle.dump(bestGaitTuple, f)
         f.close()

      except:
         print "error pickling gait"

   return player.goLater('restartOptimization')
Exemple #2
0
def stopandchangegait(player):
    '''Set new gait and start walking again'''

    if player.firstFrame():
        setWalkVector(player, 0,0,0)

        gaitTuple = arrayToGaitTuple(player.swarm.getNextParticle().getPosition())

        setGait(player, gaitTuple)

    if player.counter == 50:
        return player.goLater('walkstraightstop')

    return player.stay()