Пример #1
0
    def __init__(self, depth, size, tt_file_name=None, count=1, mutation_rate=1e-2, best_percent=0.2, gene_size=7):
        self.count = count
        self.genes = None
        self.mutation_rate = mutation_rate
        self.best_percent = best_percent
        self.depth = depth
        self.size = size # Board size
        self.gene_size = gene_size
        self.tt_file_name = tt_file_name

        try:
            self.tt = TT.fromfile(self.tt_file_name)
            print("Loaded TT")
        except Exception as e:
            print("TT could not be found in memory")
            self.tt = TT()
Пример #2
0
depth = 4
NUM_PLAYERS = 30
SIZE = 5
NUM_GAMES_EACH = 1 # has to be odd number
MIN_WALL_SCORE_BOUND = 1
MAX_WALL_SCORE_BOUND = 2


players_list = []
wall_scores = np.linspace(MIN_WALL_SCORE_BOUND, MAX_WALL_SCORE_BOUND, NUM_PLAYERS)
player_scores = [0] * NUM_PLAYERS

for i in range(NUM_PLAYERS):
    try:
        str = f'TT_folder/size5/TT_depth{depth}/wall_score_{wall_scores[i]}.data'
        tt_loaded = TT.fromfile(str)
        players_list.append(Negamax(depth, tt=tt_loaded))
        print("loaded")
    except Exception as x:
        print(f"i dont have {wall_scores[i]} in memory")
        players_list.append(Negamax(depth, tt=TT()))

start_time = time.time()
#score_func consideres both player1 and player2!!! not only one player
for i1, player1 in enumerate(players_list):
    for i2, player2 in enumerate(players_list):
        if player1 == player2:
            continue
        curr_time = time.time()
        players = [players_list[i1], players_list[i2]]
        for j in range(NUM_GAMES_EACH):