Fix this code

import random

# given an input list of cards, shuffle them and return a new shuffled list
def shuffle(deck):
# STUDENT WILL COMPLETE THIS METHOD
deck1 = len(diamonds)
deck2 = len(p1_spades)
deck3 = len(p2_clubs)
deck4 = len(p1_capture)
deck5 = len(p2_capture)
deck6 = len(middle_cards)
return deck

# ensure the human player picks a valid spade from the remaining cards in hand
def p1_algorithm(p1_spades):
# STUDENT WILL COMPLETE THIS METHOD
while True:
try:
bid = int(input("Enter player 1 bid: "))
if bid in p1_spades:
return bid
else:
print("Invalid bid. Please choose a card from the available spades list: ", p1_spades)
except ValueError:
print("Invalid input. Please enter a number.")

return p1_spades[0] # replace this line with student code

# given the complete state of the game, this AI algorithm will make a choice
# for the computer player and return the resulting selection.
def p2_algorithm(middle_cards,diamonds,p1_spades,p2_clubs):
# this simple algorithm just makes a random selection from the available cards

# STUDENT WILL COMPLETE THIS METHOD

return p2_clubs[0] # replace this line with student code

def play_round(diamonds, p1_spades, p2_clubs, p1_capture, p2_capture, middle_cards):
# STUDENT WILL COMPLETE THIS METHOD
middle_card = diamonds.pop(0);
middle_cards.append(middle_card);
print(str.format("Middle card(s): {0}", str(middle_cards)));
print(str.format(" Player 1 available: {0}", str(p1_spades)));
player1_bid = p1_algorithm(p1_spades);
p1_spades.remove(player1_bid);
player2_bid = p2_algorithm(middle_cards,diamonds,p1_spades,p2_clubs);
p2_clubs.remove(player2_bid);
print(str.format(" Player 2 bid: {0}", str(player2_bid)));
if (player1_bid > player2_bid):
while len(middle_cards) > 0:
value = middle_cards.pop(0);
p1_capture.append(value);
middle_cards.clear();
print(str.format(" Player 1 wins bid, has captured {0}", str(p1_capture)));

if (player2_bid > player1_bid):
while len(middle_cards) > 0:
value = middle_cards.pop(0);
p2_capture.append(value);
middle_cards.clear();
print(str.format(" Player 2 wins bid, has captured {0}", str(p2_capture)));

if (player2_bid == player1_bid):
print(" Tie bid - middle card remains");
return

def determine_winner(p1_capture, p2_capture):
print("===GAME OVER===")

# STUDENT WILL COMPLETE THIS METHOD

# MAIN PROGRAM LOGIC
# NO STUDENT CHANGES BELOW THIS POINT

# randomize random number generator with a known seed for repeatability
seed = int(input("Enter random seed: "))
random.seed(seed)

# initialize 3 hands, each with cards 2 - 10
diamonds = [2,3,4,5,6,7,8,9,10]
p1_spades = [2,3,4,5,6,7,8,9,10]
p2_clubs = [2,3,4,5,6,7,8,9,10]

# initialize empty lists of cards that each player captures or that are in the middle
p1_capture = []
p2_capture = []
middle_cards = []

# shuffle the deck of diamonds
diamonds = shuffle(diamonds)

# game continues while diamonds are left
while len(diamonds) > 0:
play_round(diamonds, p1_spades, p2_clubs, p1_capture, p2_capture, middle_cards)

# all diamonds are gone, so game is over - time to determine winner
determine_winner(p1_capture, p2_capture)

import random

def shuffle(deck):
return random.sample(deck, len(deck))

def p1_algorithm(p1_spades):
while True:
try:
bid = int(input("Enter player 1 bid: "))
if bid in p1_spades:
return bid
else:
print("Invalid bid. Please choose a card from the available spades list: ", p1_spades)
except ValueError:
print("Invalid input. Please enter a number.")

def p2_algorithm(middle_cards,diamonds,p1_spades,p2_clubs):
return random.choice(p2_clubs)

def play_round(diamonds, p1_spades, p2_clubs, p1_capture, p2_capture, middle_cards):
middle_card = diamonds.pop(0)
middle_cards.append(middle_card)
print(str.format("Middle card(s): {0}", str(middle_cards)))
print(str.format(" Player 1 available: {0}", str(p1_spades)))
player1_bid = p1_algorithm(p1_spades)
p1_spades.remove(player1_bid)
player2_bid = p2_algorithm(middle_cards,diamonds,p1_spades,p2_clubs)
p2_clubs.remove(player2_bid)
print(str.format(" Player 2 bid: {0}", str(player2_bid)))
if player1_bid > player2_bid:
while len(middle_cards) > 0:
value = middle_cards.pop(0)
p1_capture.append(value)
middle_cards.clear()
print(str.format(" Player 1 wins bid, has captured {0}", str(p1_capture))

if player2_bid > player1_bid:
while len(middle_cards) > 0:
value = middle_cards.pop(0)
p2_capture.append(value)
middle_cards.clear()
print(str.format(" Player 2 wins bid, has captured {0}", str(p2_capture))

if player2_bid == player1_bid:
print(" Tie bid - middle card remains")

def determine_winner(p1_capture, p2_capture):
print("===GAME OVER===")

seed = int(input("Enter random seed: "))
random.seed(seed)

diamonds = [2,3,4,5,6,7,8,9,10]
p1_spades = [2,3,4,5,6,7,8,9,10]
p2_clubs = [2,3,4,5,6,7,8,9,10]
p1_capture = []
p2_capture = []
middle_cards = []

diamonds = shuffle(diamonds)

while len(diamonds) > 0:
play_round(diamonds, p1_spades, p2_clubs, p1_capture, p2_capture, middle_cards)

determine_winner(p1_capture, p2_capture)