Universal Threes! (by Sirvo LLC)

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

  1. cloudpuff

    cloudpuff Well-Known Member

    Sep 12, 2013
    3,600
    0
    36
    lazy layabout
    uk
    Off topic I know but just wanted to let you guys know that the fractal app mentioned earlier in the thread is now 69p.

    App info is currently processing and/or the app is not yet fully available for sale on the US App Store.


    I'm having great fun messing around with it so thanks to the dev.
     
  2. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    Cloudpuff, you're very welcome!! The sale is for Pi Day (worldwide, not just UK), and also applies to the iPad version (Frax HD) for £1.49, here:

    https://itunes.apple.com/gb/app/frax-hd-first-realtime-immersive/id529646208

    The sale runs 3.13 - 3.16, because Pi is approximate after all :D
     
  3. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    The speed of achieving 1536 is primarily determined by the luck of the bonus tiles, though if you maintain a "tidier" board you can achieve it slightly sooner. Not counting the bonus cards, the quickest you could reach 1536 would be roughly 768 moves. Given that the bonus cards come approximately every 21 cards, and are uniformly distributed in [6, 12, .., High / 8], then the "average value" of the Nth card is roughly as follows:

    High card 24: average 2.00 (no bonus cards)
    High card 48: average 2.19 (bonus card always a 6)
    High card 96: average 2.33 (bonus card in [6, 12] )
    High card 192: average 2.57
    High card 384: average 2.98
    High card 768: average 3.68
    High card 1536: average 4.90
    High card 3072: average 7.09
    High card 6144: average 11.01

    So the game speeds up "exponentially" as play progresses, though it's quite a slow ramp. Estimates of an approximate time to each new high card (with a very tidy board) can be extrapolated from this:

    High card 48: 24 moves
    96: 46 moves
    192: 87 moves
    384: 161 moves
    768: 290 moves
    1536: 499 moves
    3072: 812 moves
    3072 + 1536: 1028 moves
    6144: 1245 moves
    12288: 1803 moves

    A consequence is that it takes slightly over 1000 moves to produce a board with 3072 + 1536, and we know that the most difficult times during play are when you're on the verge of creating the next high number (because it entails a long chain of high cards clogging up the board: in this case [3072, 768, 384, 192, 96, 48, ...] ), which is roughly the same "difficulty" as creating the first 3072 in the first place. So this is a reasonable explanation for why Nicola's bot tends to fall somewhat short of 1000 moves on average.

    Of course, a messy board (with several extraneous large cards) will take longer to produce a new high card, and a lucky run of bonus cards will get you there quicker. Nicola, how do the above estimates square with how your bot has done in practice?
     
  4. CzechCongo

    CzechCongo Well-Known Member

    Jul 17, 2013
    294
    0
    0
    Thanks Ben (for the app, pi day sale, and your contributions to this thread) and cloudpuff (for bringing it to my attention), I just bought the HD version. I suggest that you create a post in the Price Drop forum.
     
  5. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    Done. Thanks for the tip!
     
  6. BTG-XCELL

    BTG-XCELL Well-Known Member

    Jan 11, 2014
    90
    0
    0
    So, just double-dipped on this for Android, and first game played I finally got a 768! Thanks to everyone who gave advice and tips! :D
     

    Attached Files:

  7. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    I'll need to log the time taken to reach each card, but your explanation looks spot on.
     
  8. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    Median moves to reach each card in a test run of 1000 simulation for the 1+2+2 configuration:

    48: 25 moves
    96: 51 moves
    192: 97 moves
    384: 177 moves
    768: 314 moves

    the following are not reliable (probably underestimates) because the card wasn't reached every time:
    1536: 527 moves (over 722 runs)
    3072: 837 moves (over 138 runs)
    3072+1536: 1027 moves (over 58 runs)
    6144: 1030 moves (ony 1 run)

    I'd say that the values are in the ballpark of Ben's estimates but slightly higher, with an increasing difference (both in absolute and relative terms).

    Surely this is because not every new card contributes to the highest card, but there are other cards on the board as well.

    Also, shouldn't we consider in the calculations that the game starts with 9 cards already on the board?
     
  9. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    Nice results! The difference from my estimates are presumably due to having a few 12's and 24's lying around when the big numbers are reached. I didn't count the nine cards on the board at the start because we've pretty much established that it's only possible to reduce the number of cards on the board to 7, so when you make a new high card there will invariably be several other small cards on the board. I took this to roughly cancel out the first 9.

    The fact that your 6144 was reached after only 1030 moves indicates that that run had a very lucky streak of high bonus cards, which is also something I would expect. Likewise for the 3072 + 1536, which you typically only reach if you've been "luckier than average". I suspect if you were to run the simulation until you achieved a 12288 (which may take many thousands of runs), it would also appear significantly sooner than the "expected" 1800th move, due to lots of high bonus cards.
     
  10. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    I think it would need a lot more than many thousands runs to reach 12288 :)

    I've let it run for 100,000 simulations to get some better figures for the higher cards (the values for the low cards are confirmed).

    1536: 531 moves (over 72333 runs)
    3072: 838 moves (over 14831 runs)
    3072+1536: 1043 moves (over 5365 runs)
    6144: 1210 moves (over 190 runs)
     
  11. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    Maybe it would be nice to have an update that counts the moves - maybe even giving points for number of moves (if more is "harder").

    I finally got 768 so I'm way behind but I am in first place of my "friends" and 28,455th out of almost half a million. Had two 96 and two 48 cards at the end I couldn't get together.
     
  12. jkadams

    jkadams New Member

    Mar 17, 2014
    1
    0
    0
    I love this game!

    I've been playing around with writing a javascript implementation with an AI here: http://jkadams.github.io/meld/ - you can watch it go if you check Auto-move, which is probably my favorite part.

    It's still pretty slow because javascript is tricky to get fast and it's not as good as the other AIs already mentioned in this topic - it still loses with a high card of 384 on rare occasions! I consistently get high cards of 768 and 1536 and the occasional 3072 but I've only had it play ~50 games.

    I haven't implemented any advanced board scoring other than # pieces + game over, since it's hard to do a test on 100 games every time I change a scoring mechanism when it takes 5-10 minutes for the AI to complete the game.
     
  13. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    Maybe this has been mentioned with all the analysis, but has anyone noticed any trends in how the cards come out? I mean, without having actually kept track, I seem to run in to a lot of times when I'll get like 3-4 reds in a row or alternating red/blue. Just seems like it happens more often than random chance would allow for.

    If there is a pattern, maybe that could be included in some simulations. For example, maybe if there are 2 reds in a row, there could be a 50% chance the next one is also red as opposed to 25% for a blue or white card. That could lead to a better "guess" of where to move.
     
  14. kamikaze28

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

    Let's see what probability theory has to say about these chances. We take the 12-card 4/4/4 stack as a baseline and let's just focus on the 4 same-color cards in a row for the moment.

    Within one stack
    For simplicity, let's formulate the chance for the 4 same-color cards appearing at the beginning of the stack:
    4/12*3/11*2/10*1/9*1 (I don't care about the other cards, so I can multiply with 1)​
    Now, this pattern can shift down the stack until it looks like this:
    8/12*7/11*6/10*5/9*4/8*3/7*2/6*1/5*4/4*3/3*2/2*1/1​
    For a reason I don't understand with my morning-brain, both of these (and any of the 6 steps in between) come out as 1/495. Adding all 8 scenarios together gives us:
    8/495=0,01616...​
    But we're not done yet. These runs of 4 cards can cross from one stack into another.

    Across two stacks
    Here, we only have 3 cases (3/1, 2/2, 1/3 [#cards in one stack/#cards in next stack]). Let's write them out (note that one, two or three of the desired cards have moved into the "other"-category of the first stack):
    9/12*8/11*7/10*6/9*5/8*4/7*3/6*2/5*1/4*3/3*2/2*1/1*4/12
    10/12*9/11*8/10*7/9*6/8*5/7*4/6*3/5*2/4*1/3*2/2*1/1*4/12*3/11
    11/12*10/11*9/10*8/9*7/8*6/7*5/6*4/5*3/4*2/3*1/2*1/1*4/12*3/11*2/10​
    Summing these three cases together comes out to be:
    1/660+1/726+1/660=8/1815​

    Result
    Putting these two results together we get a total chance of:
    112/5445 = 0.020569329660238751147842056932966023875114784205693296602387...​
    In conclusion: you can expect a consecutive run of 4 same-color-cards in roughly 2 in 100 stacks if there is no other mechanic at play.
     
  15. Scorpion008

    Scorpion008 Well-Known Member

    Jun 18, 2011
    602
    0
    0
    I love your sim! It is very visual. I almost want to tell you to rip off the game and get the adorable characters moving in double-time on your board. Please keep working on it and hopefully we'll see some 6144's. Also, let it stop and not immediately restart when the AI wins a game please.
     
  16. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    Well, this is weird. On the board I saw "Result" underlined but no details. Then I selected "quote" to reply and I see a bunch of stuff about details of the one and two stack stuff. Never experienced this before. I thought maybe some stuff that shows in the quotes was accessible as a link in your post, but clicking on it didn't do anything (at least not with Firefox).

    Anyway, just getting to the summary - that four in a row would happen twice out of 100 stacks (or 1200 cards), that seems pretty rare yet I feel I see it more than that. Was hoping someone experienced it too. Guess I'll have to start writing down my games when I can to see.

    Update: Note that when I posted this, again all your detail was missing but does show up when editing this.

     
  17. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    #797 BenW, Mar 18, 2014
    Last edited: Mar 18, 2014
    A quick independent analysis: there are (12! / (4! * 4! * 4!)) = 34650 ways to arrange a stack. Out of these, there are 9 * (8 choose 4) = 630 ways to have 4 red cards in a row, and 630 ways to have 4 blue cards in a row. So the expected number of 4-card runs in a single stack is 1260 / 34650 ~= 3.6%.

    4-card runs across adjacent stacks must also be counted. The chance that the boundary between any given pair of stacks will be inside a 4-card run is roughly 3%, and in most of these cases, neither of the stacks separately contain a 4-card run, so we can safely ignore double-counting. Calculation as follows:

    Red-only: the card adjacent to the boundary on either side is red, p 1/9. If the two adjacent cards are also red (total p 1/121 ~= 0.008), there is a 4-card run. Otherwise (p 48 / 121) one of the cards is red. If its neighbor is also red (p 1/5), total p 48 / 5445 ~ 0.009, we have a 4-card run, so the combined total is ~0.017 = 1.7%. Doubling this to account for blue, we have 3.4%. To compensate for double-counting, i.e. runs of longer than 4 cards, let's lower this (handwaving) to 3.0%. So the expected number of such 4-card runs per stack is about 3%.

    Combining these figures, we get about a 7.6% chance per 12 cards that there will be a 4-card run. This means that we can expect to see one such run every 160 cards or so, or about twice in the course of making a 768. This seems consistent with my experience. Nicola, can you do a quick monte-carlo check of these figures?

    Incidentally, the probability of getting 8 red cards in a row, or 8 blue cards in a row, across two adjacent stacks is 2 * ((4 * 3 * 2 *1) / (12 * 11 * 10 * 9))^2, or about 1 out of 125,000. So if you're a decent player (typically getting 384 or 768, playing through about 25 stacks), you'd expect to see this happen in about one out of 5000 games. Maybe this should be an "Achievement"? :)
     
  18. Nicola Salmoria

    Nicola Salmoria Well-Known Member

    Over 1000 simulations, I got an average of one 4-card run every 185 cards.

    This doesn't account for bonus cards, however. Considering bonus cards, it was one run every 211 cards.
     
  19. dabigkahuna

    dabigkahuna Well-Known Member

    Mar 5, 2011
    848
    0
    16
    Retired
    Hawaii
    Hmmm, once out of 185 (or 211). Maybe that's what I've seen but it seems more often than that. I'll have to try checking precisely when I get a chance.
     
  20. VirtualBoyFreak

    VirtualBoyFreak Well-Known Member
    Patreon Bronze

    Apr 26, 2011
    4,788
    75
    48
    Spain
    @Devs: bug report: after playing a few times and exiting the game, sometimes the sound disappears and the sound control, instead of controlling the multimedia sound, controls the phone ring sound. I'm forced to reboot the phone to get it back to normal. Aside from this small issue, fantastic game :)
     

Share This Page