Go Fish - Rules for playing cards. Task “Card game “Go fish” Go fish card game

from 2 to 6 players, best from 3 to 6.

Deck

Standard deck for 52 cards.

Target

To complete most sets of four.

Settings

Five cards are dealt to each player if there are three to six players involved. With two players, seven cards are dealt.

All remaining cards are placed face down in the draw pile.

Gameplay

Randomly select a player to go first.

In turn, ask the player to indicate a specific card rank. For example: “Barb, please give me your 9.” You must have at least one card of the required rank.

If the player you are asking has cards of the required rank, she must provide you with all of her cards of that rank. In this example, Bars should have given you all of his 9s.

If you receive one or more cards from the player you are asking, you get another turn. You can ask any player for any level you already have, including the one you just asked for.

If the person you ask doesn't have the appropriate cards, they say, "Go fish." You then draw the top card from the draw pile.

If you get a rank request card, show it to other players and you will get another turn. However, if you draw a card that you did not specify, it will become another player. You keep the back card, regardless of its rank.

NOTE: The "next player" is the one who said, "Go fish."

When you collect a set of four cards of the same rank, immediately show the set to the other players and place the four cards face down in front of you.

Victory

Go Fish continues until someone has no cards left in their hand or the game ends in a tie. The winner is the player who has the most sets of four at that time.

Option one: specific card

Instead of asking for a rank, you should ask for a specific card. You must already hold at least one card of this rank.

For example: “Charlie, please give me the king of clubs.” If Charlie has it, he'll give it to you and you'll go again. Otherwise he says, "Go fish" and you draw from the draw. If you get the card you asked for, you will get another spin. If you draw anything else, it is now the next player's turn.

Before playing this way, all players must agree whether you can ask for a card you already have in your hand. (If you ask for such a card, you will have to fish and your turn will end, but it may be useful for you to do this so that other players will think that you are not holding that particular card.)

Option Two: Keep playing

When a tie ends, continue playing until all cards are grouped into four. When no one's thread is exhausted, no one says "Go fish." If you ask someone for a card that she doesn't have, it will be her turn.

Is fishing part of your life? Main character This gamer also loves to go fishing and almost every day he fishes on the lake located near him. This morning he decided to go fishing to get his maximum catch. If you want to keep him company, press start and join the game. First you need to choose the most convenient place where you can sit comfortably with your new acquaintance. Look closely at the screen and you will see that it is divided into two parts. At the top there will be your fisherman, and at the bottom there will be a fish swimming in the pond. Your goal is to catch as many fish as possible, but you need to pay attention to the fact that there are also other objects floating in the water that you don’t want to hook with a fishing rod. If you touch any piece of iron, you may well break the fishing line, which is very undesirable. Cast your fishing rod as far as possible and try to catch the biggest fish.

Task

Refactor the C code that implements the children's card game Go Fish.

Source

  • fish.c – program code in one of the old C dialects, but, nevertheless, compiled with minimal modifications by modern compilers.

Description

Since the game is not very widespread in Russia, we present short description rules

  • The game involves from 2 to 10 players (2 players are implemented in this program).
  • The game is played with a standard 52 card deck.
  • The goal of the game is to collect as many piles as possible with cards of the same value (all twos, all aces, all tens, etc.)
  • At the beginning of the game, players are randomly dealt 7 cards (or 5 cards if there are 5 or more players).
  • The remaining cards are placed face down into a common pile. This stack is called "ocean" or "pool", i.e. "ocean" or "pool", i.e. a place where you can catch fish.
  • Players take turns.
  • The player to whom the turn has passed asks the opponent a question about cards of a certain value, for example, “Do you have sevens?”
    • The player must have at least one card of the value he is requesting from his opponent.
    • If the opponent does not have the requested cards, then he replies “Go fish” - “go catch”, and the player takes out 1 card from the “ocean” - the common deck.
    • If the opponent has cards of the requested value, then he gives them to the questioner.
    • If a player takes the requested cards from the opponent, then the move remains with him, and he can make another request for a card of any value.
    • If a player takes out a card of the requested value from the common stack - the “ocean”, then he receives the right to take another card from the common stack. Thus, a situation is possible when a player draws up to 4 cards in a row from the common deck.
  • After a player “fishes out” from the common deck a card of a different value than he requested, the turn passes to the next player.
  • As soon as a player has 4 cards of the same value, he places them next to him in a separate pile face up. These cards are "won" by the player, and in further game do not participate.
  • The game ends after all cards have been "won" by the players. The one who "wins" more cards wins.

During the refactoring process you need to:

  • Rewrite the code in C++ (declaring variables not at the beginning of the block, but where they are actually used, remove anachronisms of the C language, etc.)
  • Get rid of defines (declaration of constants) and global variables.
  • Get rid of goto .
  • Text input/output is done via std::cout, etc. Separate text input/output into a separate class/module.
  • Error handling should be transferred to the exception mechanism and std::exception .
  • If possible, replace primitive data structures like arrays with std::array or std::vector , std::stack , std::queue or others.
  • Select a player class that deals with input/output and transmitting user instructions.
  • Select a computer player class that implements some AI.
  • Implement a game class that will implement the rules of the game, call players, and provide available information to players.
  • Can be used
Different games