Пример #1
0
def end_game():
  if settings.JS_REPLAY_FILE or settings.JS_REPLAY_FILENAME:
    jsplayer.save_world_turns(m.world_turns)
    jsplayer.end_world(m.world_data)

  last_ai_data = m.world_turns[-1][1]
  log.info("END GAME SCORES")
  for t in last_ai_data:
    team = t["team"]
    ai_class = m.world.team_map[team].__class__
    log.info("%s\t%s", team, ai_class.__name__)
    for k in t:
      log.info("  %s:\t%s", k, t[k])
Пример #2
0
def end_game():
    global CliWorld
    for ai in CliWorld.AI:
        log.info("%s:%s", ai.__class__, ai.score)

    if settings.NCURSES:
        ncurses.end()

    # Save the world information to an output file.
    if settings.JS_REPLAY_FILE or settings.JS_REPLAY_FILENAME:
        jsplayer.save_world_turns(CliWorld.world_turns)
        jsplayer.end_world(CliWorld.dumpWorldToDict())

    try:
        if settings.PROFILE_AI:
            CliWorld.printAIProfiles()
    except Exception, e:
        log.warn("""
There was a problem saving AI profile information. Profiling
information can get corrupted if the game is interrupted.
""")
Пример #3
0
def end_game():
  global CliWorld
  for ai in CliWorld.AI:
    log.info("%s:%s", ai.__class__, ai.score)

  if settings.NCURSES:
    ncurses.end()

  # Save the world information to an output file.
  if settings.JS_REPLAY_FILE or settings.JS_REPLAY_FILENAME:
    jsplayer.save_world_turns(CliWorld.world_turns)
    jsplayer.end_world(CliWorld.dumpWorldToDict())

  try:
    if settings.PROFILE_AI:
      CliWorld.printAIProfiles()
  except Exception, e:
    log.warn("""
There was a problem saving AI profile information. Profiling
information can get corrupted if the game is interrupted.
""")
Пример #4
0
        deadlined = True
    except Exception, e:
        traceback.print_exc()
    finally:
        for ai in w.AI:
            log.info("%s:%s", ai.__class__, ai.score)

        if not deadlined:
            with gcs.open(appengine_file_name, 'w',
                          content_type='text/html') as replay_file:
                settings.JS_REPLAY_FILE = replay_file
                if world_turns:
                    jsplayer.save_world_turns(world_turns)
                # Save the world information to an output file.
                if settings.JS_REPLAY_FILE or settings.JS_REPLAY_FILENAME:
                    jsplayer.end_world(w.dumpWorldToDict())

                replay_file.close()

    log.info("Saved as: %s", appengine_file_name)
    log.info("http://localhost:8080/replays/%s", appengine_file_name)

    end_time = time.time()
    run_time = end_time - start_time

    record_game_to_db(w, replay_blob_key, run_time, tournament_key)

    return w


if __name__ == "__main__":
Пример #5
0
    log.info("Finished simulating the world")
  except KeyboardInterrupt, e:
    raise
  except Exception, e:
    traceback.print_exc()
  finally:
    for ai in w.AI:
      log.info("%s:%s", ai.__class__, ai.score)

    with files.open(appengine_file_name, 'a') as replay_file:
      settings.JS_REPLAY_FILE = replay_file
      if world_turns:
        jsplayer.save_world_turns(world_turns)
      # Save the world information to an output file.
      if settings.JS_REPLAY_FILE or settings.JS_REPLAY_FILENAME:
        jsplayer.end_world(w.dumpWorldToDict())
      replay_file.close()


  files.finalize(appengine_file_name)
  replay_blob_key = files.blobstore.get_blob_key(appengine_file_name)

  log.info("Saved to: %s", replay_blob_key)
  log.info("Saved as: %s", appengine_file_name)
  log.info("http://localhost:8080/replays/%s", replay_blob_key)

  end_time = time.time()
  run_time = end_time - start_time

  record_game_to_db(w, replay_blob_key, run_time, tournament_key)