1 kyu

Puzzle Fighter

49 of 176docgunthrop
Description
Loading description...
Games
Logic
Game Solvers
Algorithms
  • Please sign in or sign up to leave a comment.
  • Yo-Landi Avatar

    So after reading all of the other questions, and not really finding an answer to the one I had, I thought I'd ask it

    In the context of Power Gems What would the power gem look like in the following situation

      RRR
    RRRRR
    RRRRR
    

    if the formed power gems look like

      S11
    22S11
    22S11
    

    1's and 2's being the power gem id and the S's being single. The explanation of the game mentioned how when power gems are formed, the higher elevation takes priority, and when a gem wants to 'grow' it tries to form a new power gem and then combine with others at the same level, but what if the gems are already formed, and there are 2 options for 'growing'?

    Would the formation of power gems look like

      111
    22111
    22111
    

    or

      S11
    22211
    22211
    

    assuming they are the same color

  • Kacarott Avatar

    Should be updated to Python 3.8

  • MobulaKuhlii Avatar

    This comment has been hidden.

  • scarecrw Avatar

    Awesome kata! I downloaded the game to try it out myself, and I'm definitely of the opinion that the kata is the more entertaining of the two.

  • cwtester Avatar

    Python translation: uncommenting see_states = True doesn't seem to work (I'm only told my solution was wrong and the expected final answer, but no step-by-step info to help me debugging), at least for tests (I did not submit my solution). Or, is it designed to work with "real" test cases only so I have to debug the example tests on my own?

  • cwtester Avatar

    This is an intersting problem and I've already started coding. However, it's not very clear to me that how to expand exsiting Power Gems. Suppose the following board just after dropping the pair (I don't know whether it's a reachable state, but...)

    0000033
    0000033
    0000033
    0011133
    2211133
    2211133
    

    All the gems are red, the number denotes the id of power gems (0 are indivial, 1 is the 1st power gem, 2 is the 2nd power gem). After merging individual gems:

    4444433
    4444433
    4444433
    0011133
    2211133
    2211133
    

    Now, will all the gems (2 individual gems + 4 power gems) merge into a giant power gem? If not, what's the exact rule of merging? Thanks!

    EDIT: board in the last edition was wrong...

  • doooom Avatar

    Finished all doc's purple katas. Enjoyed every of them. Many thanks.

  • Ysrael Avatar

    I exceed the time limit :( How much I can do 130

     STDERR
    Execution Timed Out (12000 ms)
    

    My Graphic Test ◄

    I have randomly tried the tests and had no errors

  • user9644768 Avatar

    Seems after the last markdown update, the images are displaced from their intended position. Quite clear from this screenshot:

  • Hamezii Avatar

    I have a question: the power gem behaviour is quite confusing, but if you have the board state of where all the colours are, are you able to unambiguously tell where the power gems are, or do you have to keep track of them also, in order to manage merging behaviour?

  • user9644768 Avatar

    What is the meaning of "elevation" in this context?

  • G_kuldeep Avatar

    i am confused in this scenario

    
    for this board 
       012345
      ---- --- 
    0 |      |  
    1 |      | 
    2 |      | 
    3 |      |
    4 |      |  
    5 |      |  
    6 |B   B | 
    7 |R   YG|  
    8 |YB BYB|  
    9 |YYYBGG|  
    10|BRRBRY|  
    11|BGYYRG| 
      --------
    
    pair = b B movement = AAA (after movement : Bb pos:(1,2),(1,3) respectively)
    
       012345
      ---- ---  --------
    0 |      |  |      |
    1 |      |  |      |
    2 |      |  |      |
    3 |      |  |      |
    4 |      |  |      |
    5 |      |  |      |
    6 |B   B |  |B   B |
    7 |R   YG|  |R   YG|
    8 |YBB YB|  |Y   YB|
    9 |YYY GG|  |YYY GG|
    10|BRR RY|  |BRR RY|
    11|BGYYRG|  |BGYYRG|
      --------  --------
    

    left side is mine and right side is expexted but i dont understand why

    when b decend on B((8,3)) it will directly destroy releated colors and thenB will decend on Y(8,2)

  • G_kuldeep Avatar

    does we have to apply movement along with descending pair(like in real game) or we have to do all the movements first then descend on playfield??

  • HugoBricoult Avatar

    I don't understand the rule for this (9th of the Fixed test)

    32 th move

       ___ __
     0|      |
     1| Y    |
     2| RR   |
     3| RY   |
     4| BB   |
     5| BB   |
     6| rY y |
     7| GB BG|
     8|GGBYYY|
     9|RGGYGY|
    10|BGGGGG|
    11|YY GGG|
       ------
    
    
    -Move 33 =>  0G RRA
    
       ___ __
     0|      |
     1| Y    |
     2| RR   |
     3| RY   |
     4| BB   |
     5| BB   |
     6| rY y |
     7| GB BG|
     8|GGBYYY|
     9|RGGYGY|
    10|BGGGGG|
    11|YY GGG|
       ------
    

    The expected result is like if the move 33 was canceled. But i not understant why (which rules applied here ?)

    "If at any point in the game a stack of Gems goes above the top row, terminate the process and return the game state before the last move. This applies to Crash Gems and Rainbow Gems as well; their position is taken into account before their effect."

    But the stack of Gems goes never above the top row

  • SavageFire Avatar

    This has so much text at the beginning I'm not even gonna touch it.

  • ALowVerus Avatar

    Holy GOD that was a slog. 10/10 10 hours well-spent.

  • ALowVerus Avatar

    I'm confused by this transition:

       ___ __ 
     0|      |
     1|      |
     2|      |
     3|      |
     4|RRB   |
     5|GRY   |
     6|BRY Y |
     7|RRRBR |
     8|RgRRR |
     9|RYRYG |
    10|RYRGR |
    11|YYGGGY|
       ------ 
    
    PAIR 27: R0 | MOVE:LRR
       ___ __ 
     0|      |
     1|      |
     2|      |
     3|      |
     4|      |
     5|R     |
     6|G     |
     7|B B R |
     8|RRR R |
     9|RRR R |
    10|RRRBG |
    11|RRRRR |
       ------ 
    

    In the first step, there are cannot be any Power Gems, as they are no squares of 4 or more blocks. Thus, the formation of all Power Gems seem in the second step must take place during this single transition. A Rainbow gem falls on Row 4, hitting the Yellow atop column 4. A Red hits atop that Rainbow Gem, but does not form any Power Gems. All Yellows simultaneously break, leading to this:

      ___ __ 
     0|      |
     1|      |
     2|      |
     3|      |
     4|RRB R |
     5|GR    |
     6|BR    |
     7|RRRBR |
     8|RgRRR |
     9|R RYG |
    10|R RGR |
    11|  GGG |
       ------ 
    

    The gems fall, settling to this conformation.

      ___ __ 
     0|      |
     1|      |
     2|      |
     3|      |
     4|      |
     5|R     |
     6|G B R |
     7|BRRBR |
     8|RRRRR |
     9|RRRYG |
    10|RRRGR |
    11|RgGGG |
       ------ 
    

    Power gem formation takes place, leading to a 2x2 Red in rows 7 and 8 atop a 3x3 Red in rows 9 and 10. Note that the bottom 2x3 Power Gem lies atop a single Red in the bottom left corner. The green Crash Gem triggers, leading to the bottom falling out of the picture, but because of the 2x3 Power Gem, the Reds should not fall. Why does the answer show the Reds falling?

  • OmarC Avatar

    really enjoyed this kate. would rate it 2kyu though

  • Blind4Basics Avatar

    ...phew... Finally got through this... x/

    java translation, please review and approve.

    Note:

    • I set the default version to java 8 because there is something unidentified that has been deprecated from java 8 to 11 and I cannot get the info from the compiler on cw... I suspect it's something related to the parametrized classes for the tests... :/ Nothing important or problematic, but using java 8 avoid the warning message at the end of the console log (tho, all works fine with java 11 so, if a user wanna use it, no problem).
    • since java is a bit faster, I increased the number of random tests (50 more "long instruction sets")

    cheers!

  • Blind4Basics Avatar

    ruby translation, please review and approve.

    (Note: double rainbow gems added in the random tests)

    cheers!

  • gdbaldw Avatar

    Order of crash gem and rainbow gem destruction is unspecified in the description. If crash gems destroy first, they can eliminate the gem below the rainbow gem, with the rainbow then falling further onto another gem or the bottom. I suppose one could reason that rainbow gems should process before crash gems.

  • Blind4Basics Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    X-/

    Description really needs clarifications:

    seq 9 
          
         B | 6
         B | 7
         B | 8
     RG  R | 9
    GBYRYR | 10
    YYBBrB | 11
    ======
    
    
    R0 ALLL gives:
          
         B | 6
         B | 7
     0   B | 8
    RRG  R | 9
    GBYRYR | 10
    YYBBrB | 11
    ======
    
    Mine:      *   Yours:
               *   
    |     B|   *    6|      |
    |     B|   *    7|      |
    |     B|   *    8|     B|
    |  G  R|   *    9|  G  B|
    |GBYRYR|   *   10|GBY  B|
    |YYBBrB|   *   11|YYBBYB|
     ======    *      ------ 
    

    Description:

    Rainbow Gems are a rare type of special Gem that destroy all Gems of whichever color Gem they land on, while self-destructing in the process. If it lands on the floor of the playfield, no other gems will be destroyed.

    But I understoof that as "of whichever color Gem they land on", not "all Gems of the color of the one they land on".

    Kata was fun... Now it isn't really anymore, when I have to dig tens of minutes in huge debug console printing to realize this type of things... :/ (the fixed tests really need a rainbow gem, so).

  • Blind4Basics Avatar

    Meh! Here I feel a bit deceived...! ;o

    You need to add more informations about the methods resolution order in the description: You didn't explain anywhere that you expect that the power gems have to be formed BEFORE the crash and rainbow gems explode. Actually, that's in contradiction with what I said below about the MRO:

    1. explode r+R
    1. drop all the gems around
    2. only now try to do a powaGem with Y (if still possible)

    and to what you seemed to agree to (even if the case is not fully the same, yes: there, we were talking about creating gems after droping of the gems):

    Yes, the r and any interconnected Rs will explode, after which any suspended Gems will fall. If the Y Gem can form an n x m (where n >= 2 and m >= 2) block with other Y gems, then it forms a Power Gem.

    But I just encountered that case:

    PAIR 20 (X = just dropped 'G' / x = just dropped 'b')
       ___ __ 
     0|      |
     1|      |
     2|      |
     3|      |
     4| RGX  |
     5| YGG  |
     6|YYRG  |
     7|YYBB  |
     8| YBBx |
     9|YYBRR |
    10|YYBRY |
    11|RRRRB |
       ------ 
    
    PAIR 21
       ___ __ 
     0|      |
     1|      |
     2|      |
     3|      |
     4| R    |
     5| Y    |
     6|YYGG  |
     7|YYGG  |
     8| Y G  |
     9|YY RR |
    10|YYRRY |
    11|RRRRB |
       ------ 
    

    So,

    • either you effectively form the power gems first,
    • or it's even worst and you form power gems while the individual gems are dropping (I believe not but if it were the case, the implementation would become completely unpredictable for the warriors without a full MRO as soon as two or more crash gems would explode at the same round)
  • Blind4Basics Avatar

    fixed tests that would be nice to have in the sample tests:

    • a test with a tile moving against the border, then rotating 2 times (so need an adjustment of the positions so that it stays in the board after the first rotation) and then dropping: will indicate the "problem" to people (like me...) who implemented the moves with a comlpete loop over the moves and only then applying the corrections to stay in the board (my code made the vertical tile drop in the first column while it should be in the second one).
    • a test with a rainbow gem?
    • EDIT: a test where the game is stopped because of a tile crushing in other gems before dropping would be nice too.
  • Blind4Basics Avatar

    for debugging, you should display the tile used at each round with its moves. Because currently, when gems disappear, one has no idea of the reason why except that a crash or a rain gem landed somewhere.

    (Really hard to debug, for now... ;o )

    Also, it would be VERY useful that you do use test.expect(..., allow_raise=True) so that the test suite is stopped at the first failed assertion. It will make it far easier to follow where the problems are.

  • Blind4Basics Avatar

    hi,

    |Y     |   ->   |      |
    |b     |   ->   |      |
    | R    |   ->   |      |
    | RR   |   ->   |      |
    |BBR   |   ->   |      |
    |BBRR  |   ->   | RR   |
    |BYBR  |   ->   | RRR  |
    |BBBB  |   ->   |YYRR  |
    

    In a case like this, which square would have the precedence for making a power gem?

  • Blind4Basics Avatar

    If we get a pair with 2 crash gems "ry", for example, and that it lands touching respectively R and Y groups of gems, what is the order of resolution of the actions? I suppose we explode both groups before making the remaining gems drop?

  • docgunthrop Avatar

    This comment has been hidden.

  • ZED.CWT Avatar
    [ [ 'R0', 'BBBRRR' ],
      [ 'bG', 'BRR' ],
      [ 'G0', 'AAARRR' ],
      [ 'BB', 'AAA' ],
      [ 'RG', 'AA' ],
      [ 'BY', 'BBRR' ],
      [ 'RR', 'AARRR' ],
      [ 'BY', 'R' ],
      [ 'RG', 'BBB' ],
      [ 'YB', '' ],
      [ 'yR', 'BLLL' ],
      [ 'GY', 'BBR' ],
      [ 'RR', '' ],
      [ 'GG', 'AA' ],
      [ 'Y0', 'BBLL' ],
      [ 'gB', 'AL' ],
      [ 'rr', 'ALL' ],
      [ 'BR', 'RR' ],
      [ 'Rr', 'BB' ],
      [ 'RG', 'AAARR' ] ]
    Incorrect result. Your result:
      ╔═══ ══╗
     0║      ║
     1║   B  ║
     2║   G  ║
     3║   G  ║
     4║   R  ║
     5║   R  ║
     6║   YY ║
     7║   BGB║
     8║   RGR║
     9║  rGBR║
    10║  gRYR║
    11║  BBRY║
      ╚══════╝
    Expected:
      ╔═══ ══╗
     0║      ║
     1║      ║
     2║   B  ║
     3║   G  ║
     4║   G  ║
     5║   R  ║
     6║   R  ║
     7║   BGR║
     8║   RGB║
     9║  rGGR║
    10║  gRBR║
    11║  BBRR║
      ╚══════╝
    

    This one is caused by

    --------Applying  Y0 BBLL
    ----Put blocks in the top
    00  0
    01  Y
    02    G
    03    G
    04    R
    05    R
    06    YY
    07    BG
    08    RG
    09    GBR
    10    RYR
    11 RyBBRY
    

    where there are both 0 and y can destory blocks, but results different if you calculate in different order (0 first, or y first), which should be put in description, or did i miss it.

  • docgunthrop Avatar

    To help with debugging, I've added a variable seeStates to the preloaded section. If set to true, the test results will show the current game state for each Gem pair. This applies to all tests except the 10 fixed tests in the final test suite.

  • ZED.CWT Avatar

    This comment has been hidden.

  • ZED.CWT Avatar

    This comment has been hidden.

  • ZED.CWT Avatar

    This comment has been hidden.

  • ZED.CWT Avatar
    [ [ 'YB', 'AALL' ],
      [ 'RY', 'AAARRR' ],
      [ 'GR', 'BL' ],
      [ 'GR', 'AR' ],
      [ 'BG', 'BLLL' ],
      [ 'RG', 'BBRR' ],
      [ 'RG', 'AARR' ],
      [ 'RY', 'LLL' ],
      [ 'BB', 'BBBL' ],
      [ 'RB', 'BRRR' ],
      [ 'GG', 'AA' ],
      [ 'YG', 'ARR' ],
      [ 'GB', 'R' ],
      [ 'GG', 'L' ],
      [ 'BG', 'AR' ],
      [ 'RR', 'AARR' ],
      [ '0G', 'AARR' ],
      [ 'RY', 'BBBLL' ],
      [ 'BB', 'AA' ] ]
    Incorrect result. Your result:
      ╔═══ ══╗
     0║      ║
     1║      ║
     2║      ║
     3║      ║
     4║      ║
     5║    B ║
     6║    G ║
     7║  YBBG║
     8║ RGBYG║
     9║ BGGBG║
    10║YBBGGG║
    11║GYGBYG║
      ╚══════╝
    Expected:
      ╔═══ ══╗
     0║      ║
     1║     R║
     2║     R║
     3║     G║
     4║     G║
     5║    BR║
     6║    GG║
     7║    BR║
     8║ BG YG║
     9║RRGGBR║
    10║YBBGGR║
    11║GYGBYR║
      ╚══════╝
    

    I reach the expected state just before action 0G AARR, and as you can see that the right most column is full for a vertical piece, so what should i do?

    Also, it is a nightmare to debug, you may kindly output states after every action if some assertions failed. I am okay if figuring it out is part of the game but at least please add this hint for fixed tests. If you are going to add hints for all tests, because the output may be huge if some solution fails on every tests, you can choose only output the first ten hints.