Ejemplo n.º 1
0
            possible_directions = pb.get_possible_move_directions()
            for choice in network_output:
                if directions[choice] in possible_directions:
                    pb.move_and_add_random_tile(directions[choice])
                    break
            """

    for i in range(50):
        pb = PowerBoard((4, 4))
        pb.add_random_tile()
        while True:
            if pb.is_game_over():
                pb.print_to_console()
                random_best_tiles.append(max(pb.get_board()))
                break
            possible_directions = pb.get_possible_move_directions()
            pb.move_and_add_random_tile(random.choice(possible_directions))

    print(ann_best_tiles)
    ann_mean = statistics.mean(ann_best_tiles)
    print("Mean best tile for ANN:", ann_mean)
    print(random_best_tiles)
    random_mean = statistics.mean(random_best_tiles)
    print("Mean best tile for random:", random_mean)
    print("Welch test score: ",
          ai2048demo.welch(random_best_tiles, ann_best_tiles))

    with open("play2048log.txt", "a") as logfile:
        timestamp = dt.fromtimestamp(start_time)
        readable_timestamp = timestamp.strftime('%Y-%m-%d %H:%M:%S')
        logfile.write("\n\nTest started at " + readable_timestamp)
Ejemplo n.º 2
0
            possible_directions = pb.get_possible_move_directions()
            for choice in network_output:
                if directions[choice] in possible_directions:
                    pb.move_and_add_random_tile(directions[choice])
                    break
            """

    for i in range(50):
        pb = PowerBoard((4, 4))
        pb.add_random_tile()
        while True:
            if pb.is_game_over():
                pb.print_to_console()
                random_best_tiles.append(max(pb.get_board()))
                break
            possible_directions = pb.get_possible_move_directions()
            pb.move_and_add_random_tile(random.choice(possible_directions))

    print(ann_best_tiles)
    ann_mean = statistics.mean(ann_best_tiles)
    print("Mean best tile for ANN:", ann_mean)
    print(random_best_tiles)
    random_mean = statistics.mean(random_best_tiles)
    print("Mean best tile for random:", random_mean)
    print("Welch test score: ", ai2048demo.welch(random_best_tiles, ann_best_tiles))

    with open("play2048log.txt", "a") as logfile:
        timestamp = dt.fromtimestamp(start_time)
        readable_timestamp = timestamp.strftime('%Y-%m-%d %H:%M:%S')
        logfile.write("\n\nTest started at " + readable_timestamp)
        logfile.write("\nHidden layer topology: " + str(hidden_layer_topology))