Assessment
Your function should return a Boolean indicating whether the play is valid or not given the current game state (i.e. the combination of the plays made to date, the content of the player’s hand, and the groups on the table). In this, you only need to validate the state of the table (using comp10001huxxy_vall &table from Q2, which you are provided with a reference implementation of) if the play ends the player’s turn and they have played to the table. Note that play_hi story, hand, and table all represent the respective states prior to the proposed play being made (e.g. play_hi story will not contain play).
The composition of the 3-tuple used to represent each play is (player_turn, play_type, play_details), where player_turn is an integer (between 0 and 3 inclusive) indicating which player is attempting to play, and play_type and play_details are structured as follows, based on the play type:
• pick up a card from stock (and thereby end the turn): play_type =y 0, play_detaills = None; • play a card from the hand to the table: play_type = 1, play_details = (card, to_group) where card is the card from the hand that is to be played, and to_group is the (zero-offset) index of group in table to play to; in the instance that the card is to start a new group, to_group should be set to the
WE WRITE ESSAYS FOR STUDENTS
Tell us about your assignment and we will find the best writer for your project
Write My Essay For Me11play a cara rrom tne nano to me tame: p Lay…type = play.detalls = (card, to…group) where card is the card from the hand that is to be played, and to…group is the (zero-offset) index of group in table to play to; in the instance that the card is to start a new group, to…group should be set to the one more than the index of the last group on the table (i.e. if there are three groups, the last group will be index 2, so 3 would represent that the card is to be used to start a new
group);
!1,01.01.41, 441
;1.00q104*
• play a card from one group on the table to another: play…type
4″-ei:07.40,104$4,V{
2,play_details = (card, from_group, to.group) where card is the card to be played from the group, from_group is the (zero-offset) index of the group in table to play card from, and to_group is the index of the group in table to play card to (and, similarly to above, a value of one more than the index of the last group indicates that a new group is to be foryned) end the turn, after playing from the hand or play between groups on the table: play_type = 3, play details = None.
Note that picking up a card (ptay_type = 0) implicitly ends the turn, whereas if plays are made from the hand/between groups on the table, an explicit “end of turn” play (play_type = 3) must be used to confirm that the player is ending their turn.
Write a function comp10001huxxy.vali &play which takes five arguments:
• play, a 3-tuple representing the play that is being attempted; see below for details; • playivi story, a list of 3-tuples representing all plays that have taken place in the game so far (in chronological order); each 3-tuple is based on the same structure as for play; • active_player, an integer between 0 and 3 inclusive which represents the player number of the player whose turn it is to play; • hand, a list of the cards (each in the form of a 2-character string, as for QI) held by the player attempting the play; • table, a list of list of cards representing the table (in the same format as for Q2).
Your function should return a Boolean indicating whether the play is valid or not given the current game state (i.e. the combination of the plays made to date, the content of the player’s hand, and the groups on the table). In this°! you only need to validate the state of the table (using comp10001huxxy_valid_table from Q2, which you are provided with a reference implementation of) if the play ends the player’s turn and they have played to the table. Note that play_hi story, hand, and table all represent the respective states
Write a t unction comp10001huxxy_vall d_table which takes a single argument:
• groups, a list of lists of cards (each a 2-element string, where the first letter is the card value and the second letter is the card suit, e.g. 3H for the 3 of Hearts), where each list of cards represents a single group on the table, and the combined list of l&s represents the combined groups played to the table.
Your function should return a boot, which evaluates whether the table state is valid or not. Recall from the rules of the game that the table is valid if all groups are valid, where a group can take one of the following two forms:
• an N-of-a-kind (i.e. three or more cards of the same value), noting that in the case of a 3-of-a-kind, each card must have a unique suit (e.g. [ 2S 25 , 2C is not a valid 3-of-a-kind, as the Two of Spades has been played twice), and if there are 4 or more cards, all suits must be present.
• a run (i.e. a group of 3 or more cards, starting from the lowest-valued card, and ending with the highest-valued card, forming a continuous sequence in terms of value, and alternating in colour; note that the specific ordering of cards in the list is not significant,
[Button id=”1″]
If you are seeking for fast and reliable essay help, you got on the right page. You can order essays, discussion, article critique, coursework, projects, case study, term papers, research papers, reaction paper, movie review, research proposal, capstone project, speech/presentation, book report/review, annotated bibliography, and more. From now on, you can stop worry and forget about writing assignments: your college papers are safe with our expert writers