Stack Exchange network consists of 183 Q&A communities includingStack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange Player 1 will be controlled by the user, while Player 2 will be controlled by the computer. At the start of the game, Player 1 will receive a hand of five random cards. This hand must never contain any duplicate at any time during the game (e.g., The hand cannot contain two copies ofWR4). Only Player 1 has a hand, Player 2 will play randomly without any restriction.
If one of the two players wins a round, the card they played will be added to their winning pile.The winning pile can contain multiple copies of the same card and can contain cards that are also in Player 1's hand. Only the hand itself must have no duplicate. If there exists a set of three cards ofdiffering colors within the pile that either (a) all have the same element or (b) all have differing elements, the player wins the whole game and the program/function stops.A valid set of three cards must have cards with different colors every single time, with no exception.
Player 1 will be controlled by the user, while Player 2 will be controlled by the computer. At the start of the game, Player 1 will receive a hand of five random cards. This hand must never contain any duplicate at any time during the game (e.g., The hand cannot contain two copies ofWR4).
If one of the two players wins a round, the card they played will be added to their winning pile. If there exists a set of three cards ofdiffering colors within the pile that either (a) all have the same element or (b) all have differing elements, the player wins the whole game and the program/function stops.A valid set of three cards must have cards with different colors every single time, with no exception.
Player 1 will be controlled by the user, while Player 2 will be controlled by the computer. At the start of the game, Player 1 will receive a hand of five random cards. This hand must never contain any duplicate at any time during the game (e.g., The hand cannot contain two copies ofWR4). Only Player 1 has a hand, Player 2 will play randomly without any restriction.
If one of the two players wins a round, the card they played will be added to their winning pile.The winning pile can contain multiple copies of the same card and can contain cards that are also in Player 1's hand. Only the hand itself must have no duplicate. If there exists a set of three cards ofdiffering colors within the pile that either (a) all have the same element or (b) all have differing elements, the player wins the whole game and the program/function stops.A valid set of three cards must have cards with different colors every single time, with no exception.
You will display a Card-Jitsu card as the concatenation between the letter representing its element, the letter representing its color, and its value (e.g.,FB9 for a Blue Fire card with value 9). All possible values (198 cards in total (3x6x11)) can be combined in order to create a valid card, and all valid cards can be generated randomly in the game with equal probability.
You will display a Card-Jitsu card as the concatenation between the letter representing its element, the letter representing its color, and its value (e.g.,FB9 for a Blue Fire card with value 9). All possible values can be combined in order to create a valid card, and all valid cards can be generated randomly in the game with equal probability.
You will display a Card-Jitsu card as the concatenation between the letter representing its element, the letter representing its color, and its value (e.g.,FB9 for a Blue Fire card with value 9). All possible values (198 cards in total (3x6x11)) can be combined in order to create a valid card, and all valid cards can be generated randomly in the game with equal probability.
Part 1 is availablehere.
Card-Jitsu was a mini card-game based on Rock, Paper, Scissors available on the children MMO game Club Penguin.A lot of footageof this gameis available online, and may be useful if you want to know what the actual game looks like. However, you obviously don't need to know the rules in order to publish an answer. I will describe a short modified version of the rules that you will have to implement for this challenge. This second part is completely independent from the first one, so you don't need to complete Part 1 in order to write an answer for Part 2. However, Part 1 is easier to complete and explains with more details the Winning Conditions used for the end of the game, so it might be useful to check it out.
If you have any doubt about these rules, please ask about it in the comments section.
A card in Card-Jitsu is composed of three attributes:
You will display a Card-Jitsu card as the concatenation between the letter representing its element, the letter representing its color, and its value (e.g.,FB9 for a Blue Fire card with value 9). All possible values can be combined in order to create a valid card, and all valid cards can be generated randomly in the game with equal probability.
Input: Multiple inputs between 1 and 5 inclusive.
Output: Direct printing to STDOUT, a string or any similar data type.
Player 1 will be controlled by the user, while Player 2 will be controlled by the computer. At the start of the game, Player 1 will receive a hand of five random cards. This hand must never contain any duplicate at any time during the game (e.g., The hand cannot contain two copies ofWR4).
The game will have multiple rounds. At the start of each round, you will display the cards won by Player 1, the cards won by Player 2 (see Winning Conditions for more) and the current hand of Player 1. Player 1 will then input a number between 1 and 5 in order to select the card they want to play. You are allowed to receive every input at the beginning. It will then display the card chosen by Player 1, the card chosen by Player 2, which will be a random valid card (no extra condition, this can be any card), and will then display 1 if Player 1 won this round, -1 or 2 if Player 2 won (choose one or the other), or 0 in case of a tie. It will then start a new round by adding a new card to Player 1's hand. As previously stated, only one copy of each card is allowed in the hand.
A single round will be displayed like this:
[FO5,WG6,WY9] <- Cards won by Player 1[SY4] <- Cards won by Player 2[SG10,FB4,SR9,WY7,FO8] <- Player 1's hand2 <- User input (Between 1 and 5)FB4 <- Card chosen by Player 1 (The 2nd card in their hand)SY6 <- Card chosen by Player 2 (Random)1 <- Player 1 won this round (Fire beats Snow)You must follow this output format, with a line break separating each section of the output. However, you are allowed to display lists of cards however you want, as long as it is consistent and coherent. For example,SG10 FB4 SR9 WY7 FO8,[SG10, FB4, SR9, WY7, FO8] and{SG10/FB4/SR9/WY7/FO8} are all valid ways to display a list of cards. If you have any doubt, please ask about it in the comments. The hand will always have 5 cards. However, the winning pile for Player 1 and 2 can, in theory, have an infinite amount of cards. In order to simplify this for languages without easy access to dynamic memory allocation, a winning pile must be able to contain at least 99 cards without problem. You can of course exploit that for your own program.
In order to determine who won a specific round, you will have to compare the two cards chosen by Player 1 and 2 and follow these rules:
If one of the two players wins a round, the card they played will be added to their winning pile. If there exists a set of three cards ofdiffering colors within the pile that either (a) all have the same element or (b) all have differing elements, the player wins the whole game and the program/function stops.A valid set of three cards must have cards with different colors every single time, with no exception.
In other words, the elements and values are used in order to determine who wins a round, while the elements and the colors are used in order to determine who wins the whole game.
Here's a full example showing one possible outcome:
[][][SG10,FB4,SP9,WY7,FO8]2FB4IY61 <- First round ends here[FB4] <- Second round starts here[][SG10,SP9,WY7,FO8,WR2]3WY7WB82[FB4][WB8][SG10,SP9,FO8,WR2,FY5]1SG10WG101[FB4,SG10][WB8][SP9,FO8,WR2,FY5,WG7]5WG7WY41[FB4,SG10,WG7][WB8][SP9,FO8,WR2,FY5,FB3]3WR2WG20[FB4,SG10,WG7][WB8][SP9,FO8,FY5,FB3,WR7]1SR9WO101 <- Player 1 won the entire game (FB4,-,WG7,SR9)This iscode-golf, so the shortest answer in bytes will win. Good luck!
Thanks to Jonathan Allan for providing a better explanation for the Winning Conditions