Certainly! Here's the modified Python code based on the requirements outlined in the rubric:
```python
import random
def shuffle(deck):
random.shuffle(deck)
return deck
def p1_algorithm(p1_spades):
valid_spades = [card for card in p1_spades if card == 'spade']
if valid_spades:
return valid_spades[0]
else:
return p1_spades[0]
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("Middle card(s):", middle_cards)
print(" Player 1 available:", 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(" Player 2 bid:", player2_bid)
if player1_bid > player2_bid:
p1_capture.extend(middle_cards)
middle_cards.clear()
print(" Player 1 wins bid, has captured:", p1_capture)
elif player2_bid > player1_bid:
p2_capture.extend(middle_cards)
middle_cards.clear()
print(" Player 2 wins bid, has captured:", p2_capture)
else:
print(" Tie bid - middle card remains")
def determine_winner(p1_capture, p2_capture):
print("===GAME OVER===")
# Determine the winner based on the captured cards
if len(p1_capture) > len(p2_capture):
print("Player 1 is the winner!")
elif len(p2_capture) > len(p1_capture):
print("Player 2 is the winner!")
else:
print("It's a tie!")
# Set a specific seed for reproducibility
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)
```
These modifications should align the code with the provided rubric and ensure that it meets the requirements for full credit. Let me know if you have any further questions or need additional assistance!