Пример #1
0
        from keras.models import load_model
        model = load_model(MODEL)

    logging.debug("Keras imported")

    model.predict([
        np.random.randn(1, *(input_shape + (4, ))),
        np.random.randn(1, *(input_shape + (5, )))
    ]).shape

    logging.debug("Model loaded")

    my_id, gamemap = get_init()
    logging.debug("Got init")

    start = utils2.find_start(my_id, gamemap)
    momentum_map[start] = STILL
    logging.debug("Found Starting Position")
    logging.debug(start)

    prev_moves = np.zeros(input_shape + (5, ))

    send_init(MODEL.split('/')[-1])
    logging.debug("Sent init")

    turn = 0
    while True:
        turn += 1
        gamemap.get_frame()

        frame = gamemap_to_frame(gamemap)
Пример #2
0
    stdout, stderr = sys.stdout, sys.stderr
    sys.stdout, sys.stderr = open("fout", "wb"), open("ferr", "wb")
    from keras.models import load_model
    sys.stdout, sys.stderr = stdout, stderr

    logging.debug("Keras imported")

    model = load_model(MODEL)
    model_start = load_model("ML/model_start_1.h5")

    logging.debug("Models loaded")

    my_id, gamemap = get_init()
    logging.debug("Got init")

    start = utils2.find_start(my_id, gamemap)
    momentum_map[(start.x, start.y)] = STILL
    others_start = [
        utils2.find_start(player_id, gamemap)
        for player_id in range(gamemap.starting_player_count + 1)
        if player_id not in (0, my_id)
    ]
    logging.debug("Found Starting Positions")
    logging.debug(start)
    logging.debug(others_start)

    min_distance_to_others = utils2.get_min_distance(start, others_start,
                                                     gamemap)
    logging.debug("Found Minimum Distance")
    logging.debug(min_distance_to_others)
Пример #3
0

if __name__ == "__main__":

    target_reached = False
    momentum_map = {}

    my_id,gamemap = get_init()

    gamemap_stats = utils2.get_gamemap_stats(my_id,gamemap)
    logging.debug("Computed map stats")

    frontier = utils2.find_frontier(my_id,gamemap)
    logging.debug("Found frontier")

    start = utils2.find_start(my_id,gamemap)
    momentum_map[(start.x,start.y)] = STILL
    others_start = [utils2.find_start(player_id,gamemap) for player_id in range(gamemap.starting_player_count+1) if player_id not in (0,my_id)]
    logging.debug("Found Starting Positions")
    logging.debug(start)
    logging.debug(others_start)

    min_distance_to_others = utils2.get_min_distance(start,others_start,gamemap)
    logging.debug("Found Minimum Distance")
    logging.debug(min_distance_to_others)

    attr_map = utils2.map_attractiveness(my_id,gamemap,attractiveness_start)
    logging.debug("Mapped Attractiveness")

    smoothed_attr_map = utils2.smooth_map(attr_map,gamemap,kernel=[1.,1.5])
    logging.debug("Mapped Smoothed Attractiveness")