Question: # opponent(G) should take a game description G (a dictionary of the # type produced by newGame()) and return the index of the player who
# opponent(G) should take a game description G (a dictionary of the # type produced by newGame()) and return the index of the player who # is not currently playing (hint: an appropriate solution might employ # the % operator).
Use Python
These are the instructions for the NewGame Function. I posted this as another question on Chegg not too long ago but have not recieved any help.
# A game is represented as a dictionary with keys # stacks = list of player stacks, where each stack is a list of cards # table = list of cards currently on table (initially []) # next = index of player next to play (0 or 1, initially 0) # debt = penalty cards owed by next player (initially 0) # # newGame() should first create a new shuffled deck using createDeck() # and simpleShuffle(). It should then return a dictionary describing # the initial state of the current game, where the shuffled deck has # been evenly divided amongst the players. So, for example (linefeed # added for clarity): # # >>> newGame(2, S=('spades, 'hearts')) # { 'table':[], 'next':0, 'debt':0, # 'stacks':[[(2, 'spades'), (1, 'hearts')], [(2, 'hearts'), (1, 'spades')]]} # # Note the division of the shuffled deck into two equal stacks, one # for player 0 and one for player 1. def newGame(N=13, S=('spades', 'hearts', 'clubs', 'diamonds')): pass
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
