In LLAMA, you want to dump cards from your hand as quickly as you can, but you might not be able to play what you want.
Each player starts a round with six cards in hand; the deck consists of llama cards and cards numbered 1-6, with eight copies of each. On a turn, the active player can play a card or draw a card. To play a card, you must play the same number as the top card of the discard pile or one number higher (for simplicity, we will follow the rule that if you can play a card of the same number, you will play that card, if not, play the higher card). If a 6 is on the discard pile, you can play a 6 or a llama, and if a llama is on top, you can play another llama or a 1. If you cannot play any cards, you must draw a card.
The round ends when one player empties their hand, who is pronounced as the winner of that round.
Some specifications: 1. The llama cards may have any name, but must be stored as a string (e.g. simply using the value 7 as the llama card is not permitted) 2. If a player draws a card, they may not play the drawn card in the same round again, i.e. their turn ends after drawing a card. 3. We will play the game with four players.
The output should list the turns taken by each player in the following fashion:
1 - 1
2 - 1
3 - 1
4 - 2
1 - 3
2 - draw
3 - 3
4 - 4
.
.
.
1 - 6
2 - llama
game over, 2 wins.
As always in code-golf, the program with the lowest number of bytes wins.
Edits:
In response to the comments, here are a few additional specifications.
- The output may have any format as long as it contains the player number and their action.
- The llama card should be a string composed only of letters, no numbers allowed.
- At the start of a game, there is a single card on the discard pile, i.e. player 1 cannot play any card.
- If the draw deck is empty, the played cards should be reshuffled. As the official rules of the game do not specify what should happen if all cards are drawn and there are no cards in the discard pile, this case does not need to be accounted for.
- There is no input, i.e. the shuffled deck and dealing the hand cards must all be done in the program.
"7"
is a string. ;) I assume you want to say the llama card can be any string except for numbers? Maybe it's better to only allow letters[a-zA-Z]
for the llama card (i.e."A"
)? \$\endgroup\$game over, # wins.
? Would it be allowed to simply output a list of pairs (i.e. your example would be[[1,1],[2,1],[3,1],[4,2],[1,3],[2,"draw"],[3,3],[4,4],...,[1,6],[2,"llama"]]
)? \$\endgroup\$7
or0
), which, since we take no input and "The output may have any format as long as it contains the player number and their action" seems somewhat moot. I'd suggest allowing anything which cannot be confused with the other cards (on a slightly separate note I'd also suggest allowing 0-indexing of players and cards). \$\endgroup\$