Universal Threes! (by Sirvo LLC)

Discussion in 'iPhone and iPad Games' started by killercow, Feb 5, 2014.

  1. spooky23

    spooky23 Well-Known Member

    Jun 30, 2011
    266
    0
    16
    It's the 'one last game' quality that is most telling.

    Anyone that plays Football Manager on a desktop knows what I mean.
     
  2. Tastyfish

    Tastyfish Well-Known Member

    Feb 26, 2011
    465
    3
    18
    Got a new high score over 27K that ended because a 12 showed up instead of a 3, ouch!

    I will reiterate my wish that Threes sees an update that has Three modes:

    1. Casual - exactly as it is now (or with the rumour that a white 3+ graphic be used).

    2. Strategic - the actual number of the next incoming cards be displayed.

    3. Analysis Paralysis - the next 3 incoming cards and their values be displayed.
     
  3. cloudpuff

    cloudpuff Well-Known Member

    Sep 12, 2013
    3,600
    0
    36
    lazy layabout
    uk
    +1

    I could play when my iPad is charging If the screen would auto rotate, I charge my iPad on a night when I'm in bed and because the way the cable bends it means I can't really play this game. I've damaged two cables already this way so I only play games that auto rotate when in bed.
     
  4. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    I am an experimental kind of person, so I decided to write a Threes! simulator and let a program play the game thousands of times to see what happened.
    Threes! doesn't actually leave much freedom to the player since there are never more than four possible moves, so it wasn't difficult to come up with a decent algorithm.

    The simulator was written using the current most likely assumptions, which even if not 100% accurate should be good enough:
    12-card deck with additional bonus card after reaching 48, equal probabilities for all random choices

    Additionally, the algorithm that chooses the next move assumes knowledge of whether the next card will be higher than 3 (as will be in the next update of Threes!).

    Let me just list the results first, because I think they are interesting. The percentage of games where my program was able to reach certain cards was:

    card 384: 51%
    card 768: 5%
    card 1536: 0.01%

    the program never reached card 3072, even after millions of attempts.

    I'd say that despite the simplicity of the algorithm (details in the spolier below), its scores are pretty good and on par with mine.

    Possibly even more interesting is how often the program did NOT go above certain cards:

    card 48: 1%
    card 96: 8%

    I would have to check some poor game in detail to see if the program made some obvious mistake, but my first impression is that these results prove that, even playing with a reasonably good strategy, the randomness of the game can frequently force an early defeat (or conversely that, even playing with a not so good strategy, the randomness allows to to achieve decent scores frequently).

    Now the details about how the algorithm works:
    What I did is define a way to calculate a score for each board position. I used something very simple:
    +4 points for each empty square
    +4 points for each pair of adjacent cards that can be merged
    -1 point for each card which is between two higher cards vertically or horizontally (-2 points if both)

    The reasoning behind the scoring should be clear: reward empty spaces or spaces which can be emptied later, and penalize checkerboard patterns which are harder to get rid of.

    The algorithm then simply tries all possible moves, computes the score of the possible resulting board positions (accounting for all possible positions where the next card can be inserted, and all possible values if it's a bonus card) and picks the move that gives the highest average score.

    That's all! So as you can see I don't care about "corner strategy" or anything like that, nor do I look at more than one move in advance: I just look at the empty space on the board, and that's enough to get pretty far into the game.
     
  5. kamikaze28

    kamikaze28 <a href="https://itunes.apple.com/us/app/hundreds/

    I would argue for sturdier cables, but whatever :D
     
  6. kamikaze28

    kamikaze28 <a href="https://itunes.apple.com/us/app/hundreds/

    #486 kamikaze28, Feb 17, 2014
    Last edited: Feb 17, 2014
    Very cool! Here are some ideas to improve your simulator's performance:
    -allow a certain number of undos (i. e., if the simulator notices that it got into a bad situation let it go back 3/5/10 moves, mark the path it chose as bad, so it would never again take it, and try a different move at that point. This is commonly known as 'backtracking'.)
    -tweak the heuristic (the function you use to grade the board situation. For example, penalize two high value cards which are far apart, reward high value cards which are close together but not yet neighbors.)
    -look more than one move ahead based on the card draw algorithm (and card counting). This is known as a Lookahead Search
    -apply it to goals like Threelock, Sixlock, Twelvelock, … (requires new heuristic)
    -hack a supercomputer, make your simulator interactive and brute-force your way to the best possible score.

    I expect results by next week! :D
     
  7. y2kmp3

    y2kmp3 Well-Known Member

    Jun 25, 2010
    1,784
    3
    38
    #487 y2kmp3, Feb 17, 2014
    Last edited: Feb 17, 2014
    Hi, Nicola,

    It is so completely awesome! ;)

    As kamikaze28 already suggested, it is important for the heuristic in your simulation to allow for evaluation of strategies that do not look for immediate matches when such strategies may reward later and better/more matches (in 1-3 moves) and more empty spaces. Likewise, sometimes, a better strategy is to sacrifice a immediate match so to position a high number tile card near a wall (especially if you know such a card is coming next, which I don't in my case) or to proactively avoid staggering.

    These were important strategies I commonly practiced in my run. There were other heuristics I used too that were not modeled in your simulation. Regardless, the general theme is that focusing only on short-term goals may cause your simulation to miss out on longer-term gains.

     
  8. ROGER-NL

    ROGER-NL Well-Known Member

    May 21, 2012
    4,030
    340
    83
    Male
    Gamer.
    THE NETHERLANDS
    Huh?
     
  9. jeandenishaas

    jeandenishaas Member
    Patreon Bronze

    Oct 29, 2010
    18
    0
    0
    Senior Lead Animator at ILM
    US
    Love the game, can't put it down! Great presentation and the animation when you push into the cards that can't move is a nice subtle touch. It's very satisfying to move the cards around from an animation point of view.
    I'd love a way to sign your scores only once so that you can instantly hit "replay" when you're done. Picky.

    Got my whole family hooked on it! :)
     
  10. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    Wow.

    I made a very simple change. Instead of computing the position score after the first move, I allowed another move to be made--without considering at all the card that would be added after the second move, simply leaving the space empty. So the position score would be the maximum of the 4 scores after the 4 possible second moves.

    The performance of the program increased just slightly...

    card 384: 92% (was 51%)
    card 768: 41% (was 5%)
    card 1536: 0.5% (was 0.01%)

    also the program always reached at least card 96.
     
  11. cloudpuff

    cloudpuff Well-Known Member

    Sep 12, 2013
    3,600
    0
    36
    lazy layabout
    uk
    Got my first ever 1,536 card. I'm one happy bunny.
     

    Attached Files:

  12. Ashervo

    Ashervo New Member
    Patreon Silver

    Feb 11, 2014
    3
    0
    0
    Hey guys! Co-creator of the game here ^.^

    Nicola this is amazing. I have a deep fondness for AI so this is just the most flattering thing possible.


    Just wanted to get in writing what I've been chugging away on and what will be in the upcoming update:

    + If the upcoming card is >3 it will show a "+" on the next card icon.
    + A "skip signing" option to speed up restarting games
    + Ability to play upside-down on the iPad
    + A spinner on the loading screen
    + Big bug fix: Tutorial will stop randomly starting for some people
    + Small bug fixes
    + Some anti-hacker stuff


    Glad you like the game, guys!! <3
     
  13. y2kmp3

    y2kmp3 Well-Known Member

    Jun 25, 2010
    1,784
    3
    38
    #493 y2kmp3, Feb 17, 2014
    Last edited: Feb 17, 2014
    Hi, Ashervo,

    Great to hear from the game's creator here! Thank you for making such an amazing game and allowing me to be part of the game's amazing history.

     
  14. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    And repeating two more times (the program becomes much slower this way so I only made it play 1000 games)

    card 384: 99%
    card 768: 74%
    card 1536: 7%

    and it always reached at least card 192.
     
  15. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    *blushes* :)

    Thanks for the game, it's a lesson in design for people like me that aspire to be a successful indie developer.
     
  16. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    Let me see if I can get some more insight into this.

    First, if I understand prior posts correctly, it is believed that there is a stack of twelve cards the game goes through and when done, it creates another stack of 12 (later 13 if you have a 48 showing). And those 12 cards have 4 of each color - the whites ones only 3's at first.

    Now, I'm just about positive I've done the first 12 cards and gotten more than 4 of one color - so do I have the rules for the stack wrong? My notes - hopefully accurate - show one game where I tracked the first 12 draws, next 12, and the 3rd set of 12.

    My numbers of 1, 2, and 3 cards came out to be:

    3,4,5
    3,4,5
    6,4,2

    Now, if I add up all the sets, I get this: 12, 12, 12 which does fit, but not for each stack of 12 cards.

    I need some clarification on this.
     
  17. Scorpion008

    Scorpion008 Well-Known Member

    Jun 18, 2011
    602
    0
    0
    Hey Nicola Salmoria, do you see yourself getting to the point were your AI can beat any human at this game, and thus by inputing each successive board to it and copying its choice you could get the top legitimate scores? That would be insane. You should make a video if you get there. I bet Ashervo would pay money to see it.:p

    Ashervo: Good on you for implementing anti-hacker stuff. You didn't have many loopholes before so it shouldn't be too hard. Btw, could you add a Gamecenter achievement sync button to the menu? It really sucks to not have the achievements show up properly, especially considering how hard most of the achievements are.
     
  18. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    Did you include the cards initially on the board in the first 12 draws?
     
  19. CzechCongo

    CzechCongo Well-Known Member

    Jul 17, 2013
    294
    0
    0
    Kamikaze's latest theory is (I think) that there is something to the algorithm that evens 1s/2s out, and I think we've determined stacks could be more than 13 cards, and even after 48 could be 12. Regarding that 1st point, notice your 3-stack totals are 12/12/12.
     
  20. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    Evidently, the initial 9 cards on the board are part of the first 12-stack. So the next three cards coming in will complete that stack of 12, and then a new one starts. Does that help?
     

Share This Page