Universal Threes! (by Sirvo LLC)

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

  1. vii-Lucky

    vii-Lucky Well-Known Member

    Jul 28, 2013
    1,611
    0
    0

    teach me, Master
     
  2. kamikaze28

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

    Hello thread,

    remember me?

    While this base-3 conversion is quite handy for reverse-engineering the board composition from the score, it does have its limitations. Mainly due to the fact that a card of rank n+1 is worth 3 times as much as a card of rank n. In other words, when there are 3 or more of one (valuable) card on the board, an overflow error occurs and your reverse-engineered board composition is wrong.

    Here's a quick example I produced to illustrate this.

    [​IMG]

    183 in ternary is 20210 which would leave you to believe there are 2 24's, 0 12's, 2 6's and one 3 on the board, which is wrong. The four 3's count as much as one 6 and one 3, and the 5 (4 on the board, 1 from the 3's) 6's together count as 1 12 and 2 6's. Now there are 3 12's, which are worth as much as a 24, which brings us to the final result with a total of 3 "overflows".

    In conclusion, this means that the lower end of cards (where it is more likely to have ≥3 on the board) can be a little wrong when reverse-engineering the board composition but in the higher region, it is most likely still accurate since these overflows don' usually cascade all the way to the more significant digits.
     
  3. dancj

    dancj Well-Known Member

    Jan 25, 2011
    967
    4
    18
    Good point. One thing that could help (with this slightly pointless but kind of fun to a maths geek like me) is that you know there must be 16 tiles on the board at the end of the game so if the calculation gives you less you know that you've got at least three of something somewhere. Of course it still doesn't tell you which tile you've got three of.
     
  4. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    Not necessarily, since there can also be a lot of 1's and 2's on the board. The lowest possible score is 12, which could be achieved e.g. as follows:

    Code:
    3 2 2 2
    1 3 2 2
    1 1 3 2
    1 1 1 3
    Note that the following board (score 9) is unachievable in practice, because it would require 7 more 1's than 2's, and the game limits the imbalance to a maximum of 4 in either direction:

    Code:
    1 3 2 2
    1 1 3 2
    1 1 1 3
    1 1 1 1
     
  5. EleArcade

    EleArcade Well-Known Member

    Mar 3, 2014
    271
    1
    18
    It's still nothing!
    Steam :D
    Is there a reason this got skipped over? ;(
     
  6. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    Ok, I've recorded a complete game start to finish (ended with 1536/768/192 on the board, score 82,833) and added some annotations (may only be visible when viewing on desktop). Let me know what you think!

    http://www.youtube.com/watch?v=qlEj1tdpywE
     
  7. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    I believe no one has legitimately earned it yet. Apparently the 12288 card reuses the same art as Volleo, with a big '1' on it.
     
  8. XaiaX

    XaiaX New Member

    Apr 26, 2014
    3
    0
    0
    I've been playing around with the possibility space for Threes scores, and it turns out it's pretty solvable. What I mean is, figuring out all possible valid Threes scores. (And conversely, all invalid scores that would *seem* to be possible)

    This is all assuming that 6144 is the largest scoring tile available.

    The max possible score with 16 6144s is 8503056. So, as a starting point, all valid scores must be that or lower. Since all scores are powers of 3, we can then eliminate anything that's not a multiple of 3. This leaves about 2.8 million possible scores.

    Not all of these scores can be achieved through a combination of 16 tiles, though.

    There are 12 scoring tiles and 2 non-scoring tiles, which makes for 14 states for each board, so a completed board has around 2.1 quintillion possible arrangements. (14 ^ 16) The vast, vast, vast majority of these are not "final" though, as there is some possibility of combination.

    Checking them all would obviously take a preposterous amount of time. Fortunately, if all we're interested in are the scores, we can do that *much* faster.

    Like this:

    Figure out all the possible scores for one tile, make a list of those.
    Now, take each of those scores, not tiles, and figure out all the possible scores you can make by adding an additional tile. Make a list of all those scores. Then repeat this with each list of scores until we've added a 16th tile. The reason this works is that "0" is a possible score for a tile, so we can have a board with 8 unscoring tiles on it, so the scores we discovered with 8 tiles are still possible scores with 16 tiles. -- I have since heard about the challenge that there is no way to have a differential greater than 4, which should mean that at most there are 5 0 scoring tiles. I can take this into account later once I've built up the master list.

    So, once we've run through 16 tiles this way, we have a huge list of all the scores that can be made with 16 tiles, and by exclusion we can find any multiple of 3 from 0 to 8503056 that is not in this list. If it's not in the list, it can't be made by any combination of 16 tiles, valid nor invalid.

    FWIW, the lowest end of this list of impossible scores looks like this:

    39363
    52485
    56859
    58317
    58803
    58965
    59019
    59037
    59043
    59046
    78729
    91851
    96225
    97683
    98169
    98331
    98385
    98403
    98409
    98412

    Now, this leaves a list of potentially valid scores. Validating that they are all possible will take a bit of work, I'm working on that right now, but not as much as you might think.

    There's 1064559 scores in my "possible" list, but that includes 0-9 which aren't possible, so we can knock that down to 1064555.

    We could perform an exhaustive search for each possible score, to see if we can create a board that fits it, but there's a way to shortcut that tremendously. If we look at any valid board, we can break it down into valid halves, valid quads, and valid pairs. So the code that I'm working on in my spare time right now starts with the assumption of valid pairs & quads. There are 29151 valid quads using the numbers 1,2,3-6144. 29151 ^ 4 is no small potatoes (7.22*10^17), but that doesn't matter because we can quickly exclude a large portion of combinations during any given test.

    E.g., for the upper left quad

    1 3
    6 12

    Any upper right quad

    3 ?
    ? ?

    or

    ? ?
    12 ?

    can't be valid, no matter what else is under those ? Which means that if we find a combining match, we can remove a ton of potential matches.

    What I did was build a hash of valid quad scores, and then the values of that hash are arrays with valid quads. So first the code looks at the valid scores and then tries to arrange a set of quads that can reach that exact score. (This part is already done, every single "possible" score passes this test, but it should because it's just the same as the 16 tile test to create scores in the first place -- none of the "invalid" ones do, that I've checked, but it takes longer to prove it invalid because it has to make an exhaustive search )

    The next logical step would be to take the potential quads and try to create a fully valid board, which would validate the score. This is the part I haven't got to yet. Now that I know about the 4-max discrepancy, I can add another check in there to shortcut the results.

    So far, in the completely invalid list there are 176794 scores (plus 4 for the 0,3,6,9 scores, I guess) which means the number of invalid scores is about 75% larger than the number of valid scores.

    Now that I see the ternary math up there, too, perhaps I can use that to speed up the valid board testing.

    Does anyone care about this or am I just amusing myself over here?
     
  9. kamikaze28

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

    Graduate student of discrete and combinatorial optimization here. At least you are amusing me. :)
     
  10. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    I think it can be tackled a bit more simply.

    Any valid score must have a ternary "popcount" of 16 or less. Thus, 1222222220 base 3 (39363) is the lowest clearly unachievable score, other than the trivial 0, 3, 6, 9.

    Note that in the real game, 6144 tiles do merge with each other, so a board with 16 6144's wouldn't be a finished board. The max score you could achieve with tiles of 6144 or less would thus be a checkerboard of 6144's and 3072's. In practice, since the board must contain the last card that comes in, and this card (even if a bonus card) maxes out at 1/8 of the high card value on the board, the highest achievable board would look something like this:

    6144 3072 6144 3072
    3072 6144 3072 6144
    6144 3072 6144 3072
    768 1536 3072 6144

    for a score of 7 * 3^12 + 7 * 3^11 + 3^10 + 3^9 = 5038848.

    You can replace the 768 by one of { 1, 2, 3, 6, 12, 24, 48, 96, 192, 384 } to find the next-highest possible scores.

    If you're allowing arbitrarily large cards, then I would venture that any score >=12 with a base-3 popcount of 16 or less is achievable as a finished (gridlocked) board, if you're sufficiently lucky with the bonus cards. (As in, if there is no restriction on the frequency of bonus cards.) If you have the constraint that only (say) 5% of the cards can be bonus cards, then that places a very high upper limit on the achievable score; in the neighborhood of 3^1000 I'd guess. I made a long post earlier on this subject.
     
  11. BenW

    BenW Well-Known Member

    Feb 15, 2014
    73
    0
    0
    On a related note, it would be fun if Game Center could somehow track the "lowest unachieved score", and offer a special achievement for being the first player to reach exactly that score. (At which point, you'd recalculate what the lowest unachieved score is.)
     
  12. XaiaX

    XaiaX New Member

    Apr 26, 2014
    3
    0
    0
    Hopefully my ramblings aren't too incoherent for you. My background is in linguistics, so I'm used to fuzzier and less coherent data than straight up integers. ;)

    I'm glad my method at least didn't come up with a wholly wrong number, even if it was probably several orders of magnitude slower about it. I wish I'd realized that I could just add up the trits and see if the sum was > 16 before you mentioned it, though. Seems obvious in retrospect, but lots of things do.

    I wonder if this provable in some non brute force kind of way. I know somewhere between jack and squat about graph theory, but that seems like the appropriate field for that, no, due to the spatial relationships?

    I think I'll re-write my script to start by converting a candidate score into trinary and then using the trits to build up a list of tiles for a candidate board. That should save a whole heck of a lot of work. It would be really neat if there were some "valid" score that can't be achieved due to some quirk of board arrangement constraints. (Though I don't expect there to be one.)
     
  13. kamikaze28

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

    It's all right, if you scroll a few pages back, we tried to prove the lowest number of cards that can be on the board and we didn't hold ourselves to academic standards when it came to form and detail.

    I'm not sure that you actually need graph theory. It's just a 16x16 grid where two neighboring fields may not have the same value. The problem is that the rules disallow certain boards (see above with the bonus cards).
     
  14. XaiaX

    XaiaX New Member

    Apr 26, 2014
    3
    0
    0
    #894 XaiaX, Apr 28, 2014
    Last edited: Apr 28, 2014
    So I wrote up a different script that simply takes a multiple of 3 and then sums the trits to get a count, and tosses anything > 16. It produced a large number of rejects, but not as large as the set I'd built with the more exhaustive tile addition method. (Iterating through possible scores)

    So either this new method misses a bunch of impossible scores, or the old method misses a bunch of valid scores. I haven't looked in too much detail, but I wonder if there's some other threshold that could apply, like if it doesn't sum to at least some number then it's invalid for a different reason.

    It starts to diverge around here:

    1594314 - 1594314
    1594317 - 1594317
    1594320 - 1594320
    1600881 - 1614003
    1605255 - 1627125
    1606713 - 1631499
    1607199 - 1632957
    1607361 - 1633443
    1607415 - 1633605
    1607433 - 1633659


    Looking at it, I think I see what happened. Where it diverges on the left is 1600881, which is 10000022222220 in ternary, which is fine, digit-wise, it just means that you'd have to have a 12288 tile. I didn't have the constraint of stopping at 6144 as I did in the original, it'd theoretically allow any max tile. I just only checked the multiples of 3 under 16 * ( 3 ^ 12 ).

    Right. I'm just thinking of something like the problem of trying to connect 3 dots to 3 other dots with lines that don't cross. (It's impossible) I know there's some more formal way of demonstrating why it's impossible, I just don't know what that is.
     
  15. Th3R3n3gad3

    Th3R3n3gad3 Well-Known Member

    Nov 4, 2012
    137
    0
    0
    Is it just me, or are other people getting low scores? Several games I get under 200 cause I keep running out of moves
     
  16. JCho133

    JCho133 Well-Known Member

    Jul 27, 2012
    7,907
    27
    48
    You'll get better, just keep at it and analyze your moves. Pay attention to the next card and where the next card will land.
     
  17. dancj

    dancj Well-Known Member

    Jan 25, 2011
    967
    4
    18
    Yeah. My main two tactics are
    1 - keep the biggest tile up in the top right hand corner and never slide it out. Try to have the other biggest numbers as clots to it as possible.
    2 - worry more about where you're bringing the new tile in than whee you're sliding tiles to - though getting the 1s and 2s together is the next most important priority.
     
  18. Photoniq

    Photoniq Member

    Nov 2, 2012
    24
    0
    1
    #898 Photoniq, May 26, 2014
    Last edited: May 27, 2014
    Strategy Question

    I've been playing Threes! for a while now, top score just shy of 41k, but I remain stumped on the best way to move those big "+" blocks toward other big blocks when they are 2 columns/rows apart.

    I've attached an example board position with 2 separated 24s on opposite sides of a 48. Can anyone give me specific moves for a situation like this? It seems to me whenever I fill up the board enough to slide separated pieces together I fill it up too much to continue afterward if I make it at all.

    In a real game with 24s I would not worry about it too much, but I've had (not quite so bad) situations with a pair of 768s and didn't handle it right, so I'm looking for specific techniques to use which I can practice on this example. So imagine the 24s are 384s and the 48 is a 768. What would you do then?
     

    Attached Files:

  19. dancj

    dancj Well-Known Member

    Jan 25, 2011
    967
    4
    18
    It's hard for me to say with your style of play as I'd have kept that 384 firmly in the top right (always the top right) corner. Generally though, with numbers as low as 24 I wouldn't sweat it. I'd just work on building that 6 up to 24 and merge it with the 24 above it - and try to do it in a way that moves the oer 24 closer when I merge them. Then I'd start building the remaining 24 up to 48 so I can merge it with the one I've just created.

    All that said, my top score is around 31k so what you're doing seems to be working better than what I'm doing.
     
  20. Photoniq

    Photoniq Member

    Nov 2, 2012
    24
    0
    1
    Yeah, with 24s I'm not sweating it too much, but I've had (not quite so bad) situations with a pair of 768s and didn't handle it right, so I'm looking for specific techniques to use which I can practice on this example. So imagine the 24s are 384s and the 48 is a 768. What would you do then?
     

Share This Page