Universal Threes! (by Sirvo LLC)

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

  1. CzechCongo

    CzechCongo Well-Known Member

    Jul 17, 2013
    294
    0
    0
    Nicola, Ashervo, cloudpuff, congrats to you all on your accomplishments! Nicola for the AI, Ashervo for the excellent game, and cloudpuff for making it to the 1536 club!
     
  2. kamikaze28

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

    #502 kamikaze28, Feb 17, 2014
    Last edited: Feb 17, 2014
    First, I'd like to remind you that some people in this thread do not want to know the inner details of the card draw algorithm, we therefore use spoiler tags exhaustively for these discussions.

    Now, form your notes I'm taking a wild guess and say that you didn't consider the cards already on the board when you start. There are always 9 cards on the board and they come from the first stack the game creates. Here's a quick demonstration with an actual game:

    Cards on the board (sorted): 1,1,1,2,2,2,3,3,3. Next card is a white (so a 3).
    At this point I know that the stack contains another 1 and 2 (apart from the 3 that I am about to draw).
    I move, a 3 appears and the next card is blue (so a 1). I am now pretty sure that the card after that is going to be a red 2.
    I move, a 1 appears and, as expected, the next card is a red 2. Now, with my next move I will deplete the 12 card stack and a new one will begin. I can therefore not make any useful predictions.
    I move, the 2 appears and the next card is a blue 1, not very informative.
    I move, a 1 appears on the board - next card is also blue 1. 11 cards left in the stack (1 blue is already on the board, the second blue is appearing with my next move).
    I move, a 1 appears and the next card is a red 2. Stack is now at 10 cards (2 blue, 4 red [one is coming next] and 4 white).
    I move, a 2 appears and the next card is a blue 1. Stack is now at 9 cards: 2/3/4 (blue/red/white).
    I move, a blue 1 appears and the next card will be white. Stack down to 8 cards: 1/3/4.
    I move, a white 3 appears and the next card will also be white. Stack down to 7 cards: 1/3/3.
    Next move, white 3 appears and next is also white. Stack down to 6 cards: 1/3/2.
    Next move, white 3 appears and next one is again white. Stack down to 5 cards: 1/3/1. The next white card will be the last white of the stack, I can anticipate either blue or red after that (with red being 3 times as likely).
    Move, white 3 appears and as anticipated, the next card is red. Stack down to 4 cards: 1/3/0. Chances are the next card is also going to be red.
    I move, red 2 appears, next one is also red as predicted. Stack down to 3 cards: 1/2/0. The next card is a coin toss: blue and red are equally likely.
    I move, red 2 appears, next one is a blue 1. Stack down to 2 cards 1/1/0 - and the last 1 is coming up next, so the card after that will be red.
    I move, the blue 1 comes in and the next card is red as expected. This red card will again be the last of the stack and everything starts from scratch again.

    I do realize that nobody has to believe that I actually played these moves while writing these lines and that I could have easily made everything up. I haven't. Try it yourself! I do have to point out, however, that keeping track of the cards this way is very tedious and if you slip up once (or my concept of the algorithm is wrong), everything is out the window. I have yet to do the partner-game with my contact, hopefully this will allow me to make predictions in mid- and endgame and see how it goes and how I can correct my concept.

    Edit: Damn, this took too long to write and 3 people answered it already -.-
     
  3. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    #503 dabigkahuna, Feb 17, 2014
    Last edited: Feb 17, 2014
    No, I didn't include them. So they should be - thus count those plus the next 3 cards THEN start over.
     
  4. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    Well, at the moment (assuming that the simulation I made of the original game is good enough, of course!) the AI is certainly better than me :) The median score it achieved over 1000 games was 27387, which is about the same as my highest score (27450). I've never seen it make a 3072 yet, though, so it wouldn't beat y2kmp3 at least :)

    I suppose I should try letting it play a real game, just to prove that it's working correctly.
     
  5. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    Sorry about the spoiler stuff - I never followed it in detail and didn't realize that all of it was "hidden". Actually, the ones that were hidden kinda confused me since it didn't strike me as a spoiler in the traditional sense - I mean it isn't like telling someone how to solve a puzzle in most games - but I guess there are those who would want to figure out the inner workings on their own too.

    I also didn't see how the heck you did the spoiler stuff - just found it under the advanced options, which I had never used.
     
  6. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    #506 dabigkahuna, Feb 18, 2014
    Last edited: Feb 18, 2014
    This is what is kinda scary - if your simulation is a good match - that it gets higher scores consistently than we get! I mean, if occasionally it got a great score, that's one thing, but to do it so often is embarrassing!

    If you could plug it in with a real game's numbers and match let it tell you what move it will make (but you insert the actual card the real game provides at each step), that would be interesting to see how the results work out in supporting your formula for movement options.
     
  7. kamikaze28

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

    In all fairness to us mere mortals you have to keep in mind that a simulation can do a bunch of games in the time it takes you to do one move. The resulting figures are statistical values. A median of 27k means that half of the games were better and half of it were worse. Without changing the simulation, it would not improve whereas you (as a human) improve continuously with every game (whether you notice it in your thinking/scores or not) and by the time you finish your 10,000th or 100,000th game, you might have a 6144 tile while the simulation is still below 3072.

    To be completely thorough: many games have already been dismantled by machine learning in the sense that a human just flat out can't beat a computer because the game is "so simple" (like Reversi [that game where you flip chips that are white on one side and black on the other]). However, there are other games ("Go" is a notable example) where dedicated high-performance computers are still not even comparable to a novice human player. It all depends on the game.
     
  8. vicsark

    vicsark Well-Known Member

    Aug 22, 2011
    1,532
    0
    0
    I'm speechless o_O
    Congrats, this is an amazing idea.
    May I ask which language you used for your A.I.?
     
  9. CzechCongo

    CzechCongo Well-Known Member

    Jul 17, 2013
    294
    0
    0
    What's even scarier is that his algorithm doesn't even take into account what card is coming next before moving!
     
  10. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    C++, but just because it's the language I'm more proficient in.
     
  11. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    It does take the next card into account, though only the next one.

    Using the additional information of whether the next card is a 3 or >3 card actually made a significant difference to the performance of the AI.
     
  12. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    It would be interesting if the game were to collect and display some basic statistics about user play over time. In particular, for each nontrivial card (192 and higher, say), what percent of the time am I able to achieve that card, once I've achieved the card before it? In other words, e.g. for the 768 tile, what percent of the time am I able to make the leap from 384 to 768? This would provide some useful feedback and information, while properly ignoring low-scoring games (e.g. letting a friend play for the first time, or repeatedly attempting Threelock or Sixlock.)

    Nicola, I'd be fascinated to know how your algorithm improves if you adjust it to take into account the 12/13-stack theories, and weight the probabilities of upcoming cards based on that, combined with 2-3 move lookahead. One wonders whether there's a tipping point where 1536 or 3072 (or even 6144) suddenly becomes regularly achievable. Also, I found it insightful that your algorithm doesn't take into account the actual scoring; it prioritizes overall "board health" over simply mashing the two highest cards together. Still, incorporating some metric that adds value for having the two or three highest tiles close to each other on the board might yield a meaningful boost. Great stuff!
     
  13. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    I know, but that median is far above my best (a bit over 9000 and I also have to 7000+). That following a set formula does that well is darn impressive - though the real test is to apply the rules to real games since it is possible there are things in the real game that don't match his simulation.

    The computer vs human thing is often interesting, but the tests aren't always valid (in my opinion). At least not in chess. In that case when a computer beat the Russian champion, it actually only did it because between each game HUMANS reprogrammed it. I have no problem with reprogramming, but not between each game! Set up your programming and live with it until the whole series is over.
     
  14. jabbasoft

    jabbasoft Active Member
    Patreon Bronze

    Sep 29, 2012
    42
    4
    8
    Isn't this just TripleTown minus the graphics? Sorry if this was already commented, huge thread and small phone..
     
  15. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    Yes that would be interesting, though it would be substantially more complicated than what I'm doing at the moment.
    I suspect that due to the unavoidable randomness, even knowing exactly which cards will come might not change things too much, because you would know the card but not exactly where it will be inserted. So it seems to me that the AI just needs to keep the board in the best state possible, and deal with the cards when they arrive.

    I did try using the actual score to pick the best move, but as I expected, the performance was far worse.

    Like with "corner strategy" and "center strategy", there are two schools of thought regarding merges: some people say to merge high cards first to get them out of the way, other people say to merge low cards first because you get so many of them. My opinion is that neither strategy is better, and what really counts is to keep the board in a tidy state, with as many empty spaces as possible and many merges ready to be made.

    One of the things I wrote in my Stickets strategy guide was:

    Pretty much the same concept applies to Threes!. Every move you make increases your score, so the most important thing you need to do to get a high score is make the highest possible amount of moves before getting stuck. The goal is to make an average of one merge per move, so having more merges already prepared for the next moves is more important than making a merge immediately. The value of the tiles you merge is largely irrelevant, provided you keep the flow going. If there are two high cards on the board and you keep merging, sooner or later you'll merge them as well.
     
  16. gamecoder

    gamecoder Well-Known Member

    Oct 18, 2012
    45
    4
    8
    Male
    USA
    No it's not the same as Triple Town. In triple town you're placing things to make matches of threes. In Threes your shifting the whole board around to make matches of two items (that are the same, or 1's and 2's). Threes requires a different set of thinking and strategies than what you'd use in Triple Town.

    To say all that, I really liked Triple Town and I like this too, you'd probably enjoy this game if you like Triple Town.
     
  17. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    Another idea for Threes, though it may go against the grain of the game developers' philosophy...

    With practice, I've found that the early part of the game now goes faster and faster; I can blaze my way to a 96 tile, and only then have to slow down and think about what I'm doing. It could be fun to have GameCenter leaderboard categories for "Fastest time to 192 / 384 / 768", as an alternate way to play. It may not make sense for higher or lower tiles than this, because 1536 is nearly unachievable regardless of time spent, and 96 can typically be gotten by chance just by extremely fast swiping.
     
  18. iPadisGreat

    iPadisGreat Well-Known Member

    Dec 10, 2012
    2,390
    0
    0
    I downloaded Triple Town after reading your post. No, Threes is nothing like Triple Town.
     
  19. Scorpion008

    Scorpion008 Well-Known Member

    Jun 18, 2011
    602
    0
    0
    Hey Kamikaze28 and Nicola Salmoria, I think you guys have some more info based on tweets, care to share?

    Edit: This post just saved this thread from going 24 hrs without a post. Whew!
     
  20. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    Thanks for keeping the thread alive :)

    I made my AI play two real games yesterday, to verify that the simulation was working correctly. The AI scored 21,624 and 31,524, which is in accordance with what I expected. Actually even better, because the game doesn't yet show when a bonus card is coming next, and that makes a significant difference.

    Watching the moves that the AI chose was unsettling. A lot of the time, I was thinking "this can't be right" "this is suicidal" "it's obvious it should do that move, why is it doing this instead?". But obviously the AI was right and I was wrong, because it easily beat my high score.

    At one point it had a 768, a 384, and a 192 nicely in the center of the board, so I guess one could say it was employing the "center strategy".

    Most of the time, the AI would intentionally defer merging cards. It would make a couple of moves without merging anything, and I would think "is it nuts? It's going to lose soon". Then with the next move it would merge three tiles at once and have more cards ready to merge.

    I think this is a significant insight. If you have many cards ready to merge, it's as good as having empty spaces, because they don't block your moves. But you also have more control, because you delay the choice of which cards to merge.

    One significant moment that I took a screenshot of was this:

    Code:
    ___  12   3   2
      1 384  24   1
     48  48 768   6
    192  12   3 192
    
    next: white
    Here the obvious move for me was left, which would have merged the two 48 and put the 3 below the 1+2 ready to be merged. But the AI thought otherwise, and moved up.

    Code:
      1  12   3   3
     48 384  24   6
    192  48 768 192
    ___  12   3   3
    This move allowed the AI to prepare a series of merges on the top right: 3+3, 6+6, 12+12, 24+24. This wouldn't have been possible if it had moved left.

    In the end, the AI was able to do those merges and make that 48, but it lost before managing to put two 48 together.

    Code:
      1   1   6   1
     48 384  48 192
    192  48 768   2
      3  24  3  24
    
    Score: 31,524
     

Share This Page