def run(col, tim): refer = get_ref() if col == True: old_bo = np.zeros((8, 8)) else: old_bo = new_board() while True: new_bo = read(ref=refer) print(old_bo, '\n ==============') print(new_bo, '\n ==============') if np.array_equal(old_bo, new_bo) == False: temp_bo = online_minmax(col, new_bo, refer, tim) #time.sleep(0.5) if np.array_equal(temp_bo, read(ref=refer)): old_bo = temp_bo
def online_minmax(col): #only play from bottom so white needs flip refer = get_ref() a = read(ref = refer) move = minimax_move(a,3,col,score_minimax,flip=col) mov = move[1][0] #print(mov) if col == True: f_mov = (mov[0][0]-2*(mov[0][0]-4)-1,mov[0][1]-2*(mov[0][1]-4)-1) t_mov = (mov[1][0]-2*(mov[1][0]-4)-1,mov[1][1]-2*(mov[1][1]-4)-1) #print(f_mov,t_mov) make_move(f_mov,t_mov,0.1,refer) #make_move(mov[0],mov[1],1,refer) print(np.flip(move[0])) else: make_move(mov[0],mov[1],0.1,refer) print(move[0])
def run(col, depth): refer = get_ref() if col == True: old_bo = None else: old_bo = chess.Board() while True: new_bo = read2(ref=refer, flip=col) print(old_bo, '\n_______________') print(new_bo, '\n_______________') if str(old_bo) != str(new_bo): new_bo.turn = col temp_bo = online_minmax(col, new_bo, refer, depth) read_bo = read2(ref=refer, flip=col) if str(temp_bo) == str(read_bo): old_bo = temp_bo
def run(col, depth): refer = get_ref() if col == True: old_bo = online_minmax(col, Board(), refer, depth) else: old_bo = Board() while True: see_bo = read2(ref=refer, flip=col) print(old_bo, '\n_______________') print(see_bo, '\n_______________') if str(old_bo) != str(see_bo): new_bo = old_bo.copy() new_bo.push(find_move(old_bo, see_bo)) move_bo = online_minmax(col, new_bo, refer, depth) read_bo = read2(ref=refer, flip=col) if str(move_bo) == str(read_bo): old_bo = move_bo
def mid_run(col, depth): refer = get_ref() old_bo = read2(ref=refer, flip=col) old_bo.turn = col old_bo = online_minmax(col, old_bo, refer, depth) while True: see_bo = read2(ref=refer, flip=col) print(old_bo, '\n_______________') print(see_bo, '\n_______________') if str(old_bo) != str(see_bo): new_bo = old_bo.copy() new_bo.push(find_move(old_bo, see_bo)) move_bo = online_minmax(col, new_bo, refer, depth) read_bo = read2(ref=refer, flip=col) if str(move_bo) == str(read_bo): old_bo = move_bo