Ejemplo n.º 1
0
def reportBestGait(player):
   if player.firstFrame():
       (bestGaitArray, gaitScore) = player.swarm.getBestSolution()
       bestGaitTuple = arrayToGaitTuple(bestGaitArray)

       player.printf("best found gait's heuristic score was: %s" % gaitScore)

       try:
           gaitScore = int(gaitScore)
           output = BEST_GAIT_FILE + str(gaitScore) + ".py"

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

           player.printf("best gait saved to file: %s" % output)
           f = open(output, 'w')
           writeGaitToFile(f, bestGaitTuple, gaitScore)
           f.close()

       except:
           player.printf("error writing out gait")

   if RESART_PSO_ON_COMPLETION:
       return player.goLater('restartOptimization')
   else:
       player.printf("Finished optimization run, check out the gait!")
       return player.goLater('gamePenalized')
Ejemplo n.º 2
0
def stopChangeGait(player):
    '''Set new gait and start walking again'''

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

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

       setGait(player, gaitTuple)

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

    return player.stay()
Ejemplo n.º 3
0
def stopChangeGait(player):
    '''Set new gait and start walking again'''

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

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

        setGait(player, gaitTuple)

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

    return player.stay()
Ejemplo n.º 4
0
def reportBestGait(player):
   (bestGaitArray, gaitScore) = player.swarm.getBestSolution()
   bestGaitTuple = arrayToGaitTuple(bestGaitArray)

   player.printf("best found gait's heuristic score was: %s" % gaitScore)

   try:
      gaitScore = int(gaitScore)
      output = BEST_GAIT_FILE + str(gaitScore) + ".py"

      player.printf("best gait saved to file: %s" % output)
      f = open(output, 'w')
      writeGaitToFile(f, bestGaitTuple, gaitScore)
      f.close()

   except:
      player.printf("error writing out gait")
Ejemplo n.º 5
0
def reportBestGait(player):
    (bestGaitArray, gaitScore) = player.swarm.getBestSolution()
    bestGaitTuple = arrayToGaitTuple(bestGaitArray)

    player.printf("best found gait's heuristic score was: %s" % gaitScore)

    try:
        gaitScore = int(gaitScore)
        output = BEST_GAIT_FILE + str(gaitScore) + ".py"

        player.printf("best gait saved to file: %s" % output)
        f = open(output, 'w')
        writeGaitToFile(f, bestGaitTuple, gaitScore)
        f.close()

    except:
        player.printf("error writing out gait")