Def phazed_is_valid_play (play, player_id, table, turn_history, phase_status,
Write a function called phazed_is_valid_play that takes the following arguments:
A 2-tuple indicating the play type, and the content of the play, as follows:
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’)).
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’)).
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’]]))).
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).
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).
An integer between 0 and 3 inclusive, indicating the ID of the player attempting the play.
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.
A list of all turns in the hand to date, in sequence of play. Each turn takes the form of a 2-tuple made up of the Player ID and the list of individual plays in the turn (based on the same format as for play above, with the one difference that for any draws from the deck, the card is indicated as ‘XX’ (as it is not visible to other players). For example, [(0, [(2, ‘JS’), (5, ‘JS’)]), (1,[(2, ‘JS’), (3, (1, [[‘2S’, ‘2S’, ‘2C’], [‘AS’, ‘5S’,‘5S’]]))])] indicates that the hand to date is made up of two turns, on the part of Players 0 and 1, respectively. Player 0 first drew the Jack of Spades from the discard pile, then discarded the Jack of Spades (presumably they had a change of heart!). Player 1 then picked up the Jack of Spades from the discard pile, and played a phase, in the form of two sets of three cards of the same value (i.e. Phase 1).
A 4-element list indicating the phases that each of Players 0—3, respectively, have achieved in the game. For example, [0, 4, 0,0] indicates that Players 0, 2 and 3 have not got any phases, but Player 1 has achieved up to Phase 4. At the start of a game, this is initialised to [0, 0, 0, 0].
The list of cards that the current player holds in their hand, each of which is in the form of a 2-element string.
The top card of the discard stack, in the form of a 2-element string (e.g. ‘3D’) or None in the case the discard pile is empty (e.g. if the first player picks up from the discard pile and hasn’t finished their turn).
本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: email@example.com 微信号:vipnxx