How to write a SRS wall kick algorithm?

Thread in 'Discussion' started by lilo, 23 Oct 2008.

  1. lilo

    lilo Unregistered

    Hello everyone I'm new here and I've been reading the TetrisWiki here recently.
    I'm trying to implement a simple Tetris clone according the Tetris Guideline but I get stucked on writing the Wall Kick/Floor Kick algorithm.
    I used a simple one that on clockwise rotation try to move the tetromino on step left,if failed try to move one step right.If both of them failed check if floor kick is necessary and then move the tetromino one step up.
    This works fine with easy T-Spins and wallkicks and floorkicks are just fine.
    But I figured it can't do complex twists that listed in the Wiki Twists page.
    Can somebody share the secret of the SRS rotation system here.
    I'd appreciate very much...
    and sorry for my poor english...
     
  2. Muf

    Muf

    I'm not too knowledgeable on SRS, but are you considering symmetrical rotation states? For instance, you have to rotate an I piece 4 times to cycle through all the rotation states, instead of just two times for ARS. Some of the kicks require the symmetry shift to work right. Just a thought.
     
  3. Zaphod77

    Zaphod77 Resident Misinformer

    EDIT: never mind what I wrote. that srs_study is wrong.

    The simple fact is no one really is sure how the wallkick tabls really work, and they aren't consistent with different games using srs. especially with the I piece.
     
  4. lilo

    lilo Unregistered

    thank all you guys
    in fact i just try to write a algorithm to handle all six type tetrominos and perform most of the twists listed in the wiki
    the srs_study helped a lot but i think i still need some help to figured it out.......
     
  5. jujube

    jujube Unregistered

    i'm pretty sure the srs_study at the_shell is correct for TDS. tepples used it for implementing SRS in Lockjaw, and only altered the I-kicks. i've played tons of TDS and Lockjaw, and never noticed any inconsistencies with J,L,S,T,Z.
     
  6. Strong words for poor jago who patiently made each setup, exactly as you see it, in ACE.
     
  7. K

    K

    yup, yeah i don't remember exactly but it tooks me a shitload of time.
    those SRS wall-kicks table were analysed from TGM-ACE, so i can't guaranty they are the same for other game.
    furthermore, there is no "gameplay" useful situation compiled data (eg T-spin Triple) for players, but they are mostly presented for coding implementation. i'm glad if someone was effectively able to reuse those data...
    So if you want to check how work any of the new Official tetris game SRS wall-kick system, this is a previous of what is awaiting you...
     
  8. Muf

    Muf

    If you look in the Hebo Mini code comments you'll see that they used jago's SRS study to implement Ti-World rotations. Actually, looking at that code might help you as well, the kick tables are all listed in code form there.

    Code:
    //???????
    //prefix:srs
    //All kick tables based on "TGM-ACE SRS study" (http://www.the-shell.net/img/srs_study.html)
    // ??????? ???????
    int srsBlkDataX[7 * 4 * 4] = // ???????????????????(7??/4??/4????)
    {
     0, 1, 2, 3,   2, 2, 2, 2,   3, 2, 1, 0,   1, 1, 1, 1, // I
     2, 2, 1, 0,   2, 1, 1, 1,   0, 0, 1, 2,   0, 1, 1, 1, // L
     1, 2, 2, 1,   2, 2, 1, 1,   2, 1, 1, 2,   1, 1, 2, 2, // O
     0, 1, 1, 2,   2, 2, 1, 1,   2, 1, 1, 0,   0, 0, 1, 1, // Z
     1, 0, 1, 2,   2, 1, 1, 1,   1, 2, 1, 0,   0, 1, 1, 1, // T
     0, 0, 1, 2,   2, 1, 1, 1,   2, 2, 1, 0,   0, 1, 1, 1, // J
     2, 1, 1, 0,   2, 2, 1, 1,   0, 1, 1, 2,   0, 0, 1, 1, // S
    };
    
    int srsBlkDataY[7 * 4 * 4] = // ???????????????????(7??/4??/4????)
    {
     1, 1, 1, 1,   0, 1, 2, 3,   2, 2, 2, 2,   3, 2, 1, 0, // I
     0, 1, 1, 1,   2, 2, 1, 0,   2, 1, 1, 1,   0, 0, 1, 2, // L
     0, 0, 1, 1,   0, 1, 1, 0,   1, 1, 0, 0,   1, 0, 0, 1, // O
     0, 0, 1, 1,   0, 1, 1, 2,   2, 2, 1, 1,   2, 1, 1, 0, // Z
     0, 1, 1, 1,   1, 0, 1, 2,   2, 1, 1, 1,   1, 2, 1, 0, // T
     0, 1, 1, 1,   0, 0, 1, 2,   2, 1, 1, 1,   2, 2, 1, 0, // J
     0, 0, 1, 1,   2, 1, 1, 0,   2, 2, 1, 1,   0, 1, 1, 2, // S
    };
    
    // I???????????????
    int srsOtherBlockKickTable[4 * 4 * 2 * 2] = {
     // ???
      1, 0,   1, -1,   0, 2,   1, 2,  // 0>>3
      1, 0,   1, 1,   0, -2,   1, -2,  // 1>>0
     -1, 0,  -1, -1,   0, 2,  -1, 2,  // 2>>1
     -1, 0,  -1, 1,   0, -2,  -1, -2,  // 3>>2
    
     // ???
     -1, 0,  -1, -1,   0, 2,  -1, 2,  // 0>>1
      1, 0,   1, 1,   0, -2,   1, -2,  // 1>>2
      1, 0,   1, -1,   0, 2,   1, 2,  // 2>>3
     -1, 0,  -1, 1,   0, -2,  -1, -2   // 3>>0
    };
    
    // I?????????????
    int srsIBlockKickTable[4 * 4 * 2 * 2] = {
     // ???
      2, 0,  -1, 0,  -1, -2,   2, 1,  // 0>>3
      2, 0,  -1, 0,   2, -1,  -1, 2,  // 1>>0
     -2, 0,   1, 0,  -2, -1,   1, 1,  // 2>>1
      1, 0,  -2, 0,   1, -2,  -2, 1,  // 3>>2
    
     // ???
     -2, 0,   1, 0,  -2, 1,   1, -2,  // 0>>1
     -1, 0,   2, 0,   2, 1,  -1, -2,  // 1>>2
      2, 0,  -1, 0,  -1, 1,   2, -1,  // 2>>3
     -2, 0,   1, 0,   1, 2,  -2, -1   // 3>>0
    };
    
    // 180???????????I???
    int srsOtherBlock180KickTable[11 * 2 * 4] = {
      1, 0, 2, 0, 1, 1, 2, 1, -1, 0, -2, 0, -1, 1, -2, 1, 0,-1, 3, 0, -3, 0,  // 0>>2??
      0, 1, 0, 2, -1, 1, -1, 2, 0,-1, 0,-2, -1,-1, -1,-2, 1, 0, 0, 3, 0,-3,  // 1>>3???
     -1, 0, -2, 0, -1,-1, -2,-1, 1, 0, 2, 0, 1,-1, 2,-1, 0, 1, -3, 0, 3, 0,  // 2>>0???
      0, 1, 0, 2, 1, 1, 1, 2, 0,-1, 0,-2, 1,-1, 1,-2, -1, 0, 0, 3, 0,-3   // 3>>1???
    };
    
    // 180???????????I?
    int srsIBlock180KickTable[11 * 2 * 4] = {
      -1, 0, -2, 0, 1, 0, 2, 0, 0, 1,  0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
      0, 1, 0, 2, 0,-1, 0,-2, -1, 0,  0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
      1, 0, 2, 0, -1, 0, -2, 0, 0,-1,  0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
      0, 1, 0, 2, 0,-1, 0,-2, 1, 0,  0,0, 0,0, 0,0, 0,0, 0,0, 0,0
    };
     
  9. Zaphod77

    Zaphod77 Resident Misinformer

    Well, I just tested in tetris DS myself.

    The wiki is not correct.

    the wiki is correct in that rotate right, rotate left kicks up, but rotate left, rotate left kicks down!

    And with the first case, rotate left, rotate right kicks down.

    but rotate right, rotate right kicks up!

    I don't have ACE, so i'm guessing that the tables on that site are correct for ACE, but that means ace ALWAYS prefers to kick up!

    And I think tetris worlds has diffrent kick rules for the I piece.

    I plan to test tetris friends next.

    Okay, checked. Same rules.
     
  10. K

    K

    I didn't knew about this [​IMG]
     
  11. Zaphod, 2 things:

    1: Make sure you are reading the diagrams correctly. The way it is presented is not obvious at first, but the imformation is all there.

    2: I spins in SRS are known to vary by game. LJ's implementation isn't used elsewhere, but is still in the spirit of SRS. See the wiki page.
     
  12. Zaphod77

    Zaphod77 Resident Misinformer

    I am reading the diagrams correctly. ACE ALWAYS prefers to rotate around the TOP instead of the bottom when performing an end rotation.

    but that's nto waht happens in tds. rotated from. depending on whether i's rotated from

    Code:
    .I..
    .I..
    .I..
    .I..
    
    or
    ..I.
    ..I.
    ..I.
    ..I.
    
    it will prefer rotating around the top or the bottom.
    If rotated from the first one of those, it will prefer rotating arond the bottom square.
    if rotated from the second one, it will prefer the top square.
     
  13. jujube

    jujube Unregistered

    zaphod, the I can kick down from either one of those states in TDS (if the setup and directions rotated are correct), and i assume in ACE too because jago demonstrates it here
    http://www.the-shell.net/img/i_piece.html

    in each of I1 from I2, I1 from I4, I3 from I4, and I3 from I2, there's a diagram showing the I kicking down.

    try these setups in TDS:
    kicking down from state 2
    kicking down from state 4

    mirrored setups/rotation directions won't always yield mirrored results, which i believe is why tepples changed the I kicks in Lockjaw SRS. but the point i'm trying to make is that the I can kick down from either vertical state (in every SRS game i've played). it can also kick up, depending on the situation.
     
  14. Zaphod77

    Zaphod77 Resident Misinformer

    In ace it will only kick down if the up kick fails.

    In other official games, when rotation from CCW once, it will prefer to kick down.

    this means you can chose your preferred direction of kicking by rotating either clockwise or ccw first.

    Every non JP game with SRS i've tried does this.
     
  15. jujube

    jujube Unregistered

    ok, i think i see what you're getting at, that the I kick order is different in ACE and TDS.

    it might be useful to show all the differences between I behavior in ACE and TDS or other games for someone wanting to emulate a certain game as closely as possible.
     

Share This Page