def negatrans_lookup(board, moving_plr): global hits, misses hsh = zobrist(board, moving_plr) if hsh in ncache: hits += 1 return ncache[hsh] misses += 1 return None
def transposition_add(board, moving_plr, depth, score): # print(f"Hash size: {len(cache)}") hsh = zobrist(board, moving_plr) # if hsh in cache: # # print(f"Updating cache: had depth {cache[hsh][0]}, new depth {depth}") # # if cache[hsh] # if cache[hsh][0] >= depth: # if cache[hsh][1] != score: # print(f"Old score: {cache[hsh][1]}, new: {score}") cache[hsh] = (depth, score)
def transposition_lookup(board, moving_plr): global hits, misses hsh = zobrist(board, moving_plr) if hsh in cache: # if board != cache[hsh][2]: # raise RuntimeError("HAS HIS BAAAAAAD") hits += 1 return cache[hsh] misses += 1 return None
def negatrans_add(board, moving_plr, depth, score, node_type): hsh = zobrist(board, moving_plr) ncache[hsh] = (depth, score, node_type)