I am designing a card game playable against the computer.

The rule is very simple

  • Both player and CPU gets 10 cards of 1 to 10.
  • Player and CPU plays a single card at the same time, every round.
  • The one who plays the bigger number wins the round.
  • Repeat this for 10 times.
  • At the end of the 10th round, the one who won the most rounds is the winner.

So the problem is, I cannot figure out the logic of the program. The first round was easy. I had figured of 3 characters, one is bold (he draws one of 8,9,10 at the first round) and timid (he draws one of 1, 2, 3 at the first round), and for the last, this is not confirmed but a character who randomly draws like bold and timid, so a player cannot be sure whom he is playing against.

But I could not figure out the logic after the first round. Each character must have a logic or pattern so player feels like he's playing against another player.

enter image description here

  • Hmmm sounds like a complex game theory problem. I guess optimal play is to play your 1 first, but then if you know that you would play your 2....
    – Ewan
    May 29, 2015 at 12:50
  • 1
    can you force a draw, by playing 10,9,8,7....? hmm no beaten by 1,10,9,8,...
    – Ewan
    May 29, 2015 at 12:56

2 Answers 2


Working out a winning strategy to this game is going to be a very hard problem and it will probably turn out to be something like choose a 'high' card 34.6% of the time.

consider the following game where timid plays bold

B 10,9,8,7
T  1,2,3,4

at this point B has won 4 hands, but T is guaranteed win of 4 with his 7,8,9,10 which he has yet to play. It all comes down to the 5 and 6.

if T expects B to play

B 6,5,4,3,2, 1 .. he should break pattern and play 
T 7,6,5,8,9,10

for 6 wins and the game. B can only draw at this stage by either matching his 6 with T's 5 or matching both 6's and 5's eg.

B 1,2,6,5,3, 4 
T 7,6,5,8,9,10

So in general we can see the best play is to make each of your cards 1 higher than your opponents and lose only one round with your 1 vs their 10

as play proceeds you gain knowledge about the cards your opponent has remaining. In order to try and work out stratagems I would start with a condensed version of the problem.

say we only have 2 cards each. 1,2. then we should always play 2 first. which guarantees a win or draw

say we have 3 cards 1,2,3.

B 3,2,1  is beaten by
T 1,3,2

in fact we don't even need to consider the 2nd and 3rd moves. T is guaranteed 1 more win with his 3. what about

B 2,?,?
T 1,?,?

the remaining combinations are in B's favour

B 2,3,1 win - 2,1,3 draw - 2,3,1 draw - 2,1,3 win
T 1,2,3     - 1,2,3        1,3,2        1,3,2

If I understand you correctly, each player gets 10 cards numbered 1 through 10. During each round, the player picks one of his cards to match against the other player.

Pretend for a minute that you are the bold player. You'll pick "8" as your first card, leaving you with 1,2,3,4,5,6,7,_,9,10.

The human player will pick a number that's either lower than, the same as, or higher than your number.

In each of the 3 cases, what would you do next?

  1. Human picked lower: you won. Since you are "bold", you'll probably want to pick another "high" number.
  2. Human picked the same: tie. Since you are "bold", you'll probably want to pick another "high" number.
  3. Human picked higher: you lost. Since you are "bold", you'll probably want to pick another "high" number.

You can probably group your numbers into "Low" (1,2,3), "Medium" (4,5,6,7) and "High" (8,9,10). Use a random number generator to pick from the right group if you still have any cards in that group. If that group is empty, move to the next group and try again.

ps - The 3 cases listed above currently all have the same action - "you'll probably want to pick another 'high' number". As you work on the game, you'll probably want to start thinking of different actions for each case.

To figure out the logic, pretend you are that player and play the game very slowly. Another way to figure it out is to pretend you have someone acting as that player. That person does not know the game and will not do anything unless you tell them what to think and what to do.

  • Thank you so much for the answer! I am making this game to apply for a job in game company! It was very helpful! May 29, 2015 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.