留学生作业代写do not hesitate to contact me!
WeChat:lovexc60
Def phazed_is_valid_play (play, player_id, table, turn_history, phase_status,
hand, discard):
Write a function called phazed_is_valid_play that takes the following arguments:
play
A 2-tuple indicating the play type, and the content of the play, as follows:
1
Pick up a card from the top of the deck at the start of the player’s turn, with the play content being the card that was picked up (e.g. (1, ‘JS’)).
2
Pick up a card from the top of the discard pile at the start of the player’s turn, with the play content being the card that was picked up (e.g. (2, ‘2C’)).
3
Place a phase to the table from the player’s hand, with the play content being a 2-tuple containing the intended phase ID (as an integer, based on the IDs from Q2) and actual phase (as a list of groups) (e.g. (3, (1, [[‘2S’, ‘2S’, ‘2C’],[‘AS’, ‘5S’, ‘5S’]]))).
4
Place a single card from the player’s hand to a phase on the table, with the play content being a 2-tuple made up of the card the player is attempting to play, and the position they are attempting to play it in, itself in the form of a 3-tuple indicating: (1) the player ID of the phase the card is to be placed on; (2) the group within the phase the card is to placed in; and (3) the index of the position within the group the card is to be played to. For example, (4, (‘AD’, (1, 0, 3)))indicates that an Ace of Diamonds is to be placed on the phase of Player 1, in Group 0 and index position 3 (i.e. it will be the fourth card in the first Group).
5
Discard a single card from the player’s hand, and in doing so, end the turn (e.g. (5, ‘JS’) indicates that a Jack of Spades is to be discarded).
player_id
An integer between 0 and 3 inclusive, indicating the ID of the player attempting the play.
table
A 4-element list of phase plays for each of Players 0—3, respectively. Each phase play is in the form of a 2-tuple indicating the phase content (as an integer or None, consistent with the output of phazed_phase_type) and a list of lists of cards (of the same format as for phazed_phase_type, but possibly with extra cards played to each of the groups in the phase). An empty phase for a given player will take the form (None, []). As an example of a full 4-player table, [(None, []), (1, [[‘2S’,‘2S’, ‘2C’], [‘AS’, ‘5S’, ‘5S’, ‘5D’]]), (None, []),(None, [])] indicates that Players 0, 2 and 3 are yet to play a phase for the hand, and Player 1 has played Phase 1, in the form of a set of Twos and a set of Fives, the latter of which has had one extra card added to it.