Take the 2-minute tour ×
Board & Card Games Stack Exchange is a question and answer site for people who like playing board games, designing board games or modifying the rules of existing board games. It's 100% free, no registration required.

I decided to delve deeper into this question to discover exactly how effective certain strategies would have on your win percentage. This led me to this Stanford Computer Science project that pits students individual UNO strategies against each other.

This particular UNO simulator has some issues that I have corrected; a proper pseudo random number generator (PRNG-Mersenne Twister); support for 2-15 players; scoring for wins instead of points; proper rules implementation of initial special cards, handling of draw cards when going out. I opted not to add a "catch"/bluff mechanic when playing Wild-Draw4, so those can only be played when you don't have a matching color.

I have implemented some basic strategies that you will be playing against; play random legal; play most color; play most point; play highest rank in most color; call random; call color I have; call color most; call points most. These strategies will face off in 100,000+ games multiple times to get a Confidence Interval (CI) for how effective the strategy is. (I am open on direction of how to accomplish this best. Should it be a 4-player game, with 2 copies of the strategy seated non-adjacent to each other (ABAB)?)

So: what is your Uno strategy? Be specific: I'm going to write a program to execute your strategy, and since computers are dumb like me, instructions need to be specific. (If they are not, I will post comments for you to clarify)

Things to think about in your answer:

  • What card do you play next? Do you try to get down to one color or number, or always keep as much variety as possible in your hand? If you have a pair of 0's and a 9, do you play the 9 to reduce your point count, or play a 0 to keep up some variety in your hand? Do you play Skip, Reverse, Draw Two, Wild, and Wild Draw Four early or late, or does it depend on how many cards other people have?
  • What do you do if you must change color? Do you call a color with the most cards, most points, least variety in ranks? Do you think about what opponents might have, or only consider your own hand?
  • Does your strategy change if someone is very close to winning the entire match, i.e. somebody's close to 500 points? How close to 500 do they have to be for you to change how you play?
  • Does your strategy change if you're losing the hand? How do you decide if you're losing? (Do you start ditching the high-point cards like Wild and Draw Two?)

Don't worry about answering all of those questions, but if you change your play depending on circumstances around the table, please mention it in your answer. Being precise helps me program a strategy that matches what you do, but if you cannot, just give me a general idea and I will post pseudo code of what the computer will do.

Don't worry about having the absolute best answer. I will program your strategy, and edit your answer to show its actual win-rate against other strategies.

share|improve this question
    
Special thanks to @PaulMarshall who gave me a nice wording of the question. –  user1873 Oct 10 '13 at 15:19
    
One thing I do is try to peg back the leader, which can involve being nice to my immediate neighbours. in the ABAB seating arrangement this means I'd be helping to attack myself! I suggest playing three or four strategies against each other and varying the seating order and start player. I'll have a go at putting together an answer later - I'm interested to see whether it actually gives much of an advantage over play random! –  tttppp Oct 13 '13 at 8:57
    
@tttppp, I am not sure what you mean by "helping to attack myself." I chose 4-player ABAB seating for a reason. I suspect that 4-player is the most common number of players. 2-player suffers from special card Reverse having no meaning. 3-player ABB suffers from always being adjacent to an opponent (since I suspect 4+ players is more common) which might make certain strategies more powerful than they would be IRL. As for not using ABCD seating order, but instead using 2 copies of each strategy, that was becuase seating order does have an effect on win percentages. [...] –  user1873 Oct 13 '13 at 14:39
    
If I chose to pit 4 strategies against the others, it would require 6 times as long to test. I would need to test each seating order (ABCD, ABDC, ACBD, ACDB, ADBC, ADCB), and then average the win percentages across all 6. With 2 copies of each strategy, yes you are fighting against yourself, but I intend to sum both win percentages together versus the other two identical strategies. I don't think this simplification should have an adverse effect on the results. BTW, 100k hands takes about 2 mins, and 200 iterations takes 6.5 hours to get an accurate estimate –  user1873 Oct 13 '13 at 14:58
    
@tttppp, I am interested if you have a suggestion for how to run the simulator that replicates real life games more accurately though. For one, I would prefer not having to simulate all the basic strategies against answer strategies. Random call, random play is a very bad strategy (initial testing puts it at 40%:60% versus the least capable strategy and it loses twice as often against the best. –  user1873 Oct 13 '13 at 15:00
show 3 more comments

2 Answers

I play the largest number I can and save my draws, skips, and reverses for when they can be used against a winning opponent. I really don't worry about number variety. However, I try to keep a low number of high value cards in my hand, namely reverses, wilds, and skips, in that order, so if someone manages to win I don't give them too many points.

call color: No Strategy (color i have?)

play: 
if hand has X or more Special Cards (SC), 
    play SC(if possible): priority Reverse, Wild, Skip, (Wild Draw-4, Draw-2), 9-0
else if opponent has Y or fewer cards
    if opponent next and hand has Draw-2 or Skip (or Wild Draw-4)
        play Draw-2, Skip, (or Wild Draw-4)
    else if opponent last and hand has Reverse and (Draw-2 or Wild Draw-4)
        play Reverse
    else
        play 9-0, Draw-2, Skip, Reverse, (Wild, Wild Draw-4)
else
    play 9-0, Draw-2, Skip, Reverse, (Wild, Wild Draw-4)
share|improve this answer
    
Some clarification: you say you save draw, skip, reverse to be used against a winning opponent (What constitutes winning, fewer cards, or more points than anyone else but under 500)? Then you say you keep a low number of high value cards, how many 2,3,4? Which is higher priority when you have 2 special cards, a Blue9 or BlueReverse? –  user1873 Oct 10 '13 at 16:23
    
I have added some pseudo code to clarify some points. The default behavior as you explained it is to play the highest point card, then Special cards. Priority is left to right always, so if you have a Draw-2 and Reverse in the same color, you will play the Draw-2. (Wilds played as a last resort). I need values for X & Y, and I assumed you wanted to reduce point cards over attacking a winning player (assumed cards in hand defines winning). Made some other assumptions if the winning player isn't adjacent to return to default behavior. –  user1873 Oct 10 '13 at 17:32
add comment

Getting the excuses out of the way early: I don't play much Uno at all, and when we do play we typically aim to win a hand, rather than keeping score over several hands. My strategy doesn't take any account of how near to 500 a player is, but presumably you should, as in the optimal Pig strategy.

I aim to get rid of high value cards, but keep a wild card for the end. I also included a 'panic' strategy for when I've been hit with a Wild Draw-4.

One interesting feature is that I occasionally choose to draw a card rather than play a wild card. I'm not sure whether you're allowed to do this according to the official rules, but we allow it.

Notation:
P - Previous opponent
N - Next opponent
O - Opposite opponent
M - Me
C(X) - The number of cards in player X's hand
min(C) - The number of cards in the leading player's hand

Call:
If I don't only have black cards left:
    Filter out colours I don't have
# Vaguely try to annoy other people
Name the one I have seen the most of so far (including my current hand)
Tie break by colour I have most of, then most recently played
If this is the first turn and I've only been dealt black cards, then pick red because it's my favourite.

Play:
If min(C) <= C(M) / 2 and min(C) < C(M) - 3:
    # I'm about to be trounced - throw away high points
    Play +4, change colour, +2
    If C(P) > C(O):
        Play change direction, skip a turn, 9-0
    Else:
        Play skip a turn, change direction, 9-0
Else if I have more than one black card left:
    # Try to save a black card for the end
    Play +4, change colour
Else if I have more than one +2 or C(N) < 3:
    # Very occasionally try to save a +2 in case there's one left over on top of the deck
    Play +2
Play skip turn, +2, change direction, 9-0, +4
If min(C) > 2 and min(C) > C(M) - 1:
    # I've got a wild card, and there's not much chance I won't get to play it
    Choose to draw a card
Play change colour

Additional 'strategies' that presumably aren't relevant in the AI tester:
If I play my second to last card call "Uno".
If an opponent fails to do this then point it out at the appropriate moment.
share|improve this answer
    
The official rules allow drawing when you have a legal play (Renegging). The initial UNO simulator doesn't actually even check of you make legal plays, but it comes with a tester app that considers not making a legal play an error. I have corrected this so the simulator plays with the official rules, with the exception of the "catch" mechanism for playing WildDraw4 (which I chose not to implement). –  user1873 Oct 13 '13 at 18:54
    
@user1873 I intended that to be the code for when I have some cards that don't go, and a wild card that I want to save. If I have multiple wild cards I should play them in either the block labelled"I'm about to be trounced" or the block labelled "try to save a black card for the end". Let me know if you want me to check your code (or if you're using a documented rules engine I might be able to code it for you?) –  tttppp Oct 20 '13 at 2:06
    
Having thought about it a bit I realised that the language isn't the main barrier to coding an ai player, it's the interface that I'd need to know. Anyway, I'm happy for you to do it, I just thought my pseudo code might be easier for me to interpret! –  tttppp Oct 20 '13 at 2:22
    
I will code it up, I was just trying to point out some (possible errors) in your code. The interface only requires two functions, Play() returns the index of the card you will play next (-1 means draw). Callcolor() returns an enum that represents on of the 4 colors (wilds are considered to not have a color). The buggy one linked in the OP will show you what else you have access to (I can add additional info if you need it). The problem I see is that you said your rules flow top to bottom, left to right. Your second to last rule has you playing all cards except wilds (should I comment clarify) –  user1873 Oct 20 '13 at 3:43
    
The second to last rule is only meant to play those cards if they're actually valid. Looking through I've been a bit vague on how to proceed if none of the cards in an if block are valid. I think in those cases the execution should try the next else block. More complicated than I gave it credit for though! –  tttppp Oct 20 '13 at 7:18
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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