Beta

Worthless Queen

Description:

The game

Worthless Queen can be played with 2 - 5 players. (You will be playing against 1-3 opponents)
Each player have 4 cards infront of them face down in a row. In the middle of the table is a pile with the rest of the deck, also face down and a pile with discarded cards, face up. In the begining of the game the top card of the deck is drawn and directly discarded so the discarded pile will always have atleast 1 card. The winner is the player with lowest sum of the cards infront of them when all cards have been drawn from the deck. It's played with a normal deck. Ace (A) is worth 1, Queens (Q) is worth 0 (ie. the "Worthless Queen"), 2 - 10, J is 11 and K is 13.

Each turn

Each player takes turn doing the following steps (You go first, I'm nice like that)

draw

The current player can either pick up the top card from the discarded pile or draw a random card from the deck.

switch

Now the player can

  • discard the card they picked up, the card is put on the top of the discarded pile and the players turn is over.
  • replace the picked up card with the leftmost card infront of the player. the picked up card will be placed face down in the leftmost place and the leftmost card will be the new card in the players hand. The player then keeps going right through the cards infront of it. players turn ends when the player chooses to discard its card or when all 4 cards have been replaced.

The Task

Your object is to implement 2 methods:

draw

  • Input: String discarded - The top card in the discarded pile.
  • Output: A string: "draw" - if you want to draw a random card from the deck or "discard" - if you want to pick up the top of the discarded pile.

switchCard

  • Input:
    • int tableCardNr - The index of the face down card infront of you that you can currently switch with (1 - leftmost, 4 - rightmost)
    • String hand - the card currently in your hand.
  • Output: A boolean: true if you want to switch the cards, false if you want to discard the current card in your hand.

Passing the tests

You will be playing full games against a random number of opponents (1-3). (full game = when all cards have been drawn from the deck)
Since even with a good strategy there is still a good bit of chance in this game so you will not be expected to beat your opponents but instead you need to be lower than or equal to a score dependent on number of opponents you face:

  • 1 opponent: 12
  • 2 opponents: 16
  • 3 opponents: 20

You will be subjected to 500 random games.

Example

EXAMPLE 1
Lets follow Bob. Bob is a gambler and risktaker.

Turn 1:
discard pile --> 6 ? <-- deck pile
Bobs table --> ? ? ? ?  (4 unknown cards)

Being a gambler Bob decides to draw from the deck

drawn: 5 (gambling payed off, it's less than 6)

discard pile --> 6 ? <-- deck pile
Bobs hand: 5
Bobs table --> ? ? ? ?  (4 unknown cards)

Bob decides to do a switch on the first leftmost.

Picked up: 2

Bobs hand: 2
Bobs table  --> (5)  ?  ?  ?  (We now know it's a 5 under the first card even if we cant see it)

Bob does another switch

Picked up: A  (Damn he is lucky)

Bobs hand: A
Bobs table --> (5) (2) ? ?

Bob does another switch

Picked up: K

Bobs hand: K
Bobs table --> (5) (2) (A) ?

Bob (being a bit stupid) does another switch

Picked up: Q 

Bobs hand: Q
Bobs table --> (5) (2) (A) (K)

As he now has no more cards to switch with Bob is left with no choice but to discard the Queen (poor Bob)

discard pile --> Q ? <-- deck pile
Bobs hand:
Bobs table --> (5) (2) (A) (K)

Overpowered with sadness of loosing the Queen, Bob just does draw and discard the rest of the game.

Bobs ending table: 5 2 A K
Score: 21 (5 + 2 + (A=1) + (K=13))

Better luck next time Bob

EXAMPLE 2
Now lets follow Sarah. Sarah is a sharp Codewarrior.

Turn 1:
Oh as chance would have it Sarahs premises is the same as Bobs

discard pile --> 6 ? <-- deck pile
Sarahs table --> ? ? ? ?  (4 unknown cards)

Sarah thinks 6 is meh! so she also wants a random draw

drawn: 5

discard pile --> 6 ? <-- deck pile
Sarahs hand: 5
Sarahs table --> ? ? ? ?  (4 unknown cards)

Sarah decides to do a switch on the first leftmost.

Picked up: 2

Sarahs hand: 2
Sarahs table  --> (5)  ?  ?  ? 

Sarah does another switch

Picked up: A

Sarahs hand: A
Sarahs table --> (5) (2) ? ?

Sarah does another switch

Picked up: K

Sarahs hand: K
Sarahs table --> (5) (2) (A) ?

Sarah decides to discard the King

discard pile --> K ? <-- deck pile
Sarahs hand:
Sarahs table --> (5) (2) (A) ?

The other players do their moves

Turn 2:

discard pile --> 3 ? <-- deck pile
Sarahs table --> (5) (2) (A) ?  (4 unknown cards)

Sarah decides to get the discarded card

Sarahs hand: 3
Sarahs table --> (5) (2) (A) ?

Sarah switches the first card

Sarahs hand: 5
Sarahs table --> (3) (2) (A) ?

Sarah does another switch

Sarahs hand: 2
Sarahs table --> (3) (5) (A) ?

Sarah does another switch

Sarahs hand: A
Sarahs table --> (3) (5) (2) ?

Sarah does another switch

Sarahs hand: 2
Sarahs table --> (3) (5) (A) ?

Sarah does another switch

Sarahs hand: Q
Sarahs table --> (3) (5) (A) (2)

Oh she also have to discard a Queen, but atleast it was with a 2

The other players do their moves

Turn 3:

discard pile --> J ? <-- deck pile
Sarahs table --> (3) (5) (A) (2)

Sarah decides to draw from the deck

drawn: Q

Sarahs hand: Q
Sarahs table --> (3) (5) (A) (2)

Sarah switches the first card

Sarahs hand: 3
Sarahs table --> (Q) (5) (A) (2)

Sarah does another switch

Sarahs hand: 5
Sarahs table --> (Q) (3) (A) (2)

Sarah decides to discard the 5

Sarah thinks she is happy and will do no more switches

End score: 6 ((Q=0) + 3 + (A=1) + 2)
Games

More By Author:

Check out these other kata created by LosBlobbos

Stats:

CreatedOct 4, 2023
PublishedOct 5, 2023
Warriors Trained10
Total Skips0
Total Code Submissions32
Total Times Completed4
Java Completions4
Total Stars0
% of votes with a positive feedback rating50% of 2
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes1
Total Rank Assessments1
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • LosBlobbos Avatar
Ad