Question: Overview For this assignment, you will be writing a program to play the card game Intensity . The Rules of Intensity Intensity is an unusual
Overview
For this assignment, you will be writing a program to play the card game Intensity.
The Rules of Intensity
Intensity is an unusual card game which is thought to have originated in post-WWII buffalo hunting camps in Australia's Northern territory. The name intensity is thought to derive from numbers in groups of ten being important.
Cards
It is played with a deck of 40 cards.
The cards are numbered 10 to 49.
No two cards have the same number.
11 cards have special significance. They are the cards numbered 30 to 39, usually called the calves, and the card numbered 47, usually called the buffalo.
Game Play
Intensity is played by four players sitting around a circular table. These players are numbered clockwise: 0, 1, 2 and 3. The deck is divided randomly among the 4 players. So each player starts with a hand of 10 cards.
Stage 1: Discarding
In the first stage of play, each player selects three cards from their hand to be passed to the player on their left (clockwise). They, of course, then receive three cards from the player on their right. So player 0 passes to player 1, player 1 to player 2, player 2 to player 3 and player 3 to player 0.
The four players simultaneously select the three cards to be passed on. Each player must pass on 3 cards, before receiving the three cards from the player on their right. Hence, you must select the three cards you will pass to the player on your left before you know which three cards you have been given by the player on your right.
Stage 2: Playing Cards
The second stage of play consists of a series of 10 rounds. The goal of the game is to avoid penalty points during these ten rounds.
A round begins with a designated player selecting a card from their hand and playing it. Then proceeding clockwise, the other players, in turn, each select a card from their hand and play it.
Hence for the first round, each player will have ten cards in their hand to select from, for the second round they will have nine cards in their hand and so on. For the tenth and last round, each player will have only one card and hence, no choice in the card they play.
Playing a Card
The first digit of the first card played in a round is important. The subsequent players must play a card of the same first digit as the first card if possible.
For example, if the first card played in a round is the 17, the other 3 players must play a card with a first digit of '1' if they have one in their hand.
If one of the players does not have a card with a first digit of '1' in their hand they may play a card of another first digit. The following players are still required to play a card with a first digit of '1' card if they have one.
Winning a Round
A round is won by the person who plays the card of the same first digit as the first card in the round with the largest number. For example, if the first card in a round is the 24, the card with the largest number with first digit '2' will win the round. If no other card with the first digit '2' played the 24 wins.
Player 0 plays the first card of the first round. Subsequently the winner of each round plays the first card of the next round.
If, for example, player 2 won the last round, then player 2 would play the first card of the next round and then players 3, 0 and 1 would play in that order.
Buffalo and Calves
One restriction to the above rules is that a player is not allowed to play a calf (a card in the range 30..39) as the first card in a round unless a calf has been played in any of the previous rounds or they have only calves in their hand. This restriction does not apply to playing a calf as the second, third or fourth card in a round.
In other words, if no cards in the range 30..39 have been previously played, a card in the range 30..39 can not be played as the first card of a round unless the player has no choice.
There is no restriction on when the buffalo can be played as the first card.
Penalty Points
The aim of Intensity is to avoid penalty points. A player scores penalty points if certain cards occur in rounds they have won. Each calf is worth one penalty point and the buffalo (47) is worth 7 penalty points.
Hence, generally players try to avoid winning rounds which contain calves and they particularly try to avoid winning rounds which contain the buffalo.
If a round doesn't contain a calf or the buffalo it doesn't affect the score.
When all 10 rounds are played the penalty points are calculated for each player. The winner of the game is the player with the fewest penalty points.
If a player attempts to play an illegal card they receive five penalty points. The referee will instead select a legal card from their hand at random. This same applies to discards.
To fully understand these rules, it might be worth watching this tutor-made video which runs through an example game of intensity.
// intensity.c // Assignment 2, COMP1511 18s1: Intensity // // This program by YOUR-NAME-HERE (z5555555) on INSERT-DATE-HERE // // Version 1.0.1: Minor changes to wording of comments. // Version 1.0.0: Assignment released. #include#include // SOME USEFUL #defines - YOU WILL NEED MORE #define ACTION_PLAYER_NAME 0 #define ACTION_DISCARD 1 #define ACTION_PLAY_CARD 2 #define ACTION_UNIT_TESTS 3 #define N_CARDS 40 #define N_CARDS_INITIAL_HAND 10 #define N_PLAYERS 4 #define N_CARDS_DISCARDED 3 #define CARD_MIN 10 #define CARD_MAX 49 // ADD EXTRA #defines HERE void print_player_name(void); void choose_discards(void); void choose_card_to_play(void); void run_unit_tests(void); // ADD PROTOTYPES FOR YOUR FUNCTIONS HERE // You should not need to change this main function int main(void) { int which_action = 0; scanf("%d", &which_action); if (which_action == ACTION_PLAYER_NAME) { print_player_name(); } else if (which_action == ACTION_DISCARD) { choose_discards(); } else if (which_action == ACTION_PLAY_CARD) { choose_card_to_play(); } else { run_unit_tests(); } return 0; } void print_player_name(void) { // CHANGE THIS PRINTF TO YOUR DESIRED PLAYER NAME printf("COMP1511 Student"); } void choose_discards() { // ADD CODE TO READ THE CARDS OF YOUR HAND INTO AN ARRAY USING SCANF // THEN ADD YOUR CODE HERE TO CHOOSE AND PRINT THE CARDS YOU WISH TO DISCARD // NOTE: THE PROVIDED CODE DOES NOT MAKE A LEGAL MOVE. YOU MUST CHANGE IT TO // DISCARD CARDS FROM YOUR HAND. printf("43 44 45 "); } void choose_card_to_play(void) { // ADD CODE TO READ THE FIRST THREE NUMBERS (NUMBER OF CARDS IN YOUR HAND, // NUMBER OF CARDS PLAYED THIS ROUND, TABLE POSITION) // ADD CODE TO READ THE CARDS OF YOUR HAND INTO AN ARRAY USING SCANF // ADD CODE TO READ THE CARDS PREVIOUSLY PLAYED THIS ROUND INTO AN ARRAY USING SCANF // ADD CODE TO READ THE CARDS PLAYED IN THE HISTORY OF THE GAME INTO AN ARRAY USING SCANF // ADD CODE TO READ THE CARDS YOU DISCARDED AT THE START INTO AN ARRAY USING SCANF // ADD CODE TO READ THE CARDS YOU RECEIVED AT THE START INTO AN ARRAY USING SCANF // THEN ADD YOUR CODE HERE TO CHOOSE AND PRINT THE CARD YOU WISH TO PLAY // NOTE: THE PROVIDED CODE DOES NOT MAKE A LEGAL MOVE. YOU MUST CHANGE IT TO // PLAY A CARD FROM YOUR HAND. printf("42 "); } // ADD A COMMENT HERE EXPLAINING YOUR OVERALL TESTING STRATEGY void run_unit_tests(void) { // PUT YOUR UNIT TESTS HERE } // ADD YOUR FUNCTIONS HERE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
