Fastest possible 40 lines time?

Started by simonlc, March 10, 2013, 08:18:47 PM

Previous topic - Next topic

simonlc

So I've been thinking, since lots of actions are based on frames, that would be the limiting factor. So if you played the most strategic and accurate game, with no delay of pressing keys, what's the hard time limit?

I'm no tetris expert, but I tried out some estimates that maybe someone else can refine. Now I know there's lots of ways that you could cut this time down if you had the right order of tetrominos, but for the sake of keeping this simple lets just give averages.

One frame at 60 FPS is 16.666 ms. Lets say on average you need to move/rotate a piece (2 frames) then move the piece two more times (one to adjust and one to place it). So in total you have 4 frames to place a piece. We need 100 pieces to clear 40 lines. I'm not sure if that's exactly how many frames it could take, but an average could be made with all the finesse moves possible. Next, we need 100 pieces to clear 40 lines so if we put that all together we get:

16.666 x 4 x 100 = 6666.666 ms = 6.667 s

So that is the fastest feasible time, unlikely to be possible by a human, I'm not sure if there's any bots that have solved the 40 lines game but that would be interesting to see. This would give the player 15 pieces per second.

For a human I would add in two frames, which would give you 10 seconds, and a pps of 10.

Edit: fixed pps.

myndzi

>882 pieces per second

You might need to re-check your math there

Integration

#2
Currently we have no sprint time below 20 seconds. I doubt there'll ever be a sub 17 seconds sprint in future.

Quote from: simonlc16.666 x 4 x 100 = 6666.666 ms = 6.667 s

So that is the fastest feasible time, unlikely to be possible by a human, I'm not sure if there's any bots that have solved the 40 lines game but that would be interesting to see.
Those 6.667 seconds are a good estimation in my opinion. To be sure that NullpoMino registers a key you have to press it down for at least 17 ms. If you'd set DAS to 2, 17 ms could also lead to an unintended autorepeat to the wall. So DAS values smaller than 3 are not usable, even for bots.

Here's a sprint bot of mine. It uses 2 step finesse, but no finesse between pieces (diagonal movement).



The same bot in Keyblox.



And a bot by Orich playing Cultris 2 (before cheat protection was introduced).


Panda

#3
First off, Welcome to HD Simon! I'd highly recommend making an official introduction on our forums and getting to know the community better

Secondly, WOW, your analytical thirst and curiosity pleases me  I've also pondered this question myself, but it's refreshing to see you have tackled it very nicely.

My 2cents, it is indeed literally impossible for a human to achieve a Perfect Sprint. The microscopic fractional unnoticeable pauses we take to subconsciously process our next move, already this minuscule pause in itself wastes countless precious frames and renders the game utterly imperfect. But regardless of the actual feasibility, this has certainly been an interesting topic to explore, and I encourage/anticipate your future contributions!

simonlc

Quote from: myndzi
>882 pieces per second

You might need to re-check your math there

Yup, fixed it lol.

Quote from: Integration
Currently we have no sprint time below 20 seconds. I doubt there'll ever be a sub 17 seconds sprint in future.
Those 6.667 seconds are a good estimation in my opinion. To be sure that NullpoMino registers a key you have to press it down for at least 17 ms. If you'd set DAS to 2, 17 ms could also lead to an unintended autorepeat to the wall. So DAS values smaller than 3 are not usable, even for bots.

Here's a sprint bot of mine. It uses 2 step finesse, but no finesse between pieces (diagonal movement).
I totally forgot to factor in DAS! That's an awesome bot you have, I'd love to see the source code. The description says you wrote it with autohotkey? Seems like a quick and dirty way to make a bot.

Quote from: Panda
First off, Welcome to HD Simon! I'd highly recommend making an official introduction on our forums and getting to know the community better

Secondly, WOW, your analytical thirst and curiosity pleases me  I've also pondered this question myself, but it's refreshing to see you have tackled it very nicely.

My 2cents, it is indeed literally impossible for a human to achieve a Perfect Sprint. The microscopic fractional unnoticeable pauses we take to subconsciously process our next move, already this minuscule pause in itself wastes countless precious frames and renders the game utterly imperfect. But regardless of the actual feasibility, this has certainly been an interesting topic to explore, and I encourage/anticipate your future contributions!

Hi, thank you for the welcome, I'll check out the introduction forum.

I also don't think it'll be possible to hit the very fastest limit, but I do think breaking 17 s would be possible. If someone plays purely on patterns, you only have to look at what pieces are coming. Get good enough at this and you're queuing up what keys you need to press eliminating that delay of thinking. The next step would be to get some Korean APM, and you've got a record. That's how Integration's bot works right?

Integration

Quote from: simonlcI totally forgot to factor in DAS! That's an awesome bot you have, I'd love to see the source code. The description says you wrote it with autohotkey? Seems like a quick and dirty way to make a bot.
Yes, AutoHotKey is a simple way to simulate keystrokes or analyze pixels' color. However, it's a bit slow to program a real bot. Perhaps you can call c++ / c# code via DLLs (see sleepy function), so that just the know-your-field-data / simulate-keystrokes part is done by AutoHotKey itself (I have no clues in this regard though). For a real bot you'd have to analyse the goodness of a stack to find a good spot. And that's the hard part. I didn't have that problem because this sprint bot follows a predefined setup, which is only adjusted by the order in which you get O, J and L pieces.

I won't share the NullpoMino version, because I don't want to cause more issues with fake sprint times in NullpoMino League Edition. I see no problem posting the Keyblox version, though: Click me. Deep drop must be enabled and you might have to change qy and qw so that it is working properly.

This script sends infinite short keystrokes. Those keystrokes are still registered, because KeyBlox is event based. For frame based games, the send code must look different. Here an extract from my NullpoMino version:


qh := 58; hold sleep time
qt := 23; tap sleep time
qw := 23; wait sleep time for double taps
ql := "Left"; left move
qr := "Right"; right move
qd := "R"; drop piece
qs := "Space"; sonic move piece down

moveO:
if ( bag >= 13 )
{
    send {%qd% down}
    sleepy(qt)
    send {%qd% up}    
}
else if ( JLO = "JLO" OR JLO = "LJO" OR JLO = "OJL" OR JLO = "OLJ" )
{
    send {%qr% down}
    sleepy(qh)    
    send {%qr% up}    
    send {%ql% down}
    send {%qd% down}    
    sleepy(qt)    
    send {%ql% up}    
    send {%qd% up}            
}
else if ( JLO = "JOL" )
{
    send {%qr% down}
    sleepy(qh)    
    send {%qr% up}
    send {%qs% down}    
    sleepy(qt)    
    send {%qs% up}                
    sleepy(qw)
    send {%ql% down}
    send {%qd% down}    
    sleepy(qt)    
    send {%ql% up}    
    send {%qd% up}                
}
else if ( JLO = "LOJ" )
{
    send {%qr% down}
    sleepy(qt)
    send {%qr% up}
    sleepy(qw)
    send {%qr% down}
    send {%qs% down}
    sleepy(qt)
    send {%qr% up}
    send {%qs% up}
    sleepy(qw)
    send {%qr% down}
    send {%qd% down}    
    sleepy(qt)    
    send {%qr% up}    
    send {%qd% up}        
}
return

That's what's happening in that part of the code:

[fumen]110@JeD3hbH3hbH3hbH3hbD3pbDPwJAiSZTASouABLAAAA?7eBDhBAgbZeYihbIwDAhb4GBAoUDAhb5GpUpbDXpZAtnceE?FbsiDvEXNEuoo2AQDckDlEtJEUBAAA7eDDpbjobjdBAAAZe?Qp0lMR4GlbQpNR4GlbQpoU5GpbDXpZAPoo2AiomoElIpTAS?4WSASoiJEkoo2AsAAAA7eDDpbDDdjiBAAAZe5GZilb4GNRY?ilb4GNRYipbDXpZAPoo2AiomoElIpTASYbSASoiJEkoo2Aq?AAAA7eDjnbDCdjiBAAA[/fumen]

simonlc

#6
Quote from: Integration
Yes, AutoHotKey is a simple way to simulate keystrokes or analyze pixels' color. However, it's a bit slow to program a real bot. Perhaps you can call c++ / c# code via DLLs (see sleepy function), so that just the know-your-field-data / simulate-keystrokes part is done by AutoHotKey itself (I have no clues in this regard though). For a real bot you'd have to analyse the goodness of a stack to find a good spot. And that's the hard part. I didn't have that problem because this sprint bot follows a predefined setup, which is only adjusted by the order in which you get O, J and L pieces.

I won't share the NullpoMino version, because I don't want to cause more issues with fake sprint times in NullpoMino League Edition. I see no problem posting the Keyblox version, though: Click me. Deep drop must be enabled and you might have to change qy and qw so that it is working properly.

This script sends infinite short keystrokes. Those keystrokes are still registered, because KeyBlox is event based. For frame based games, the send code must look different. Here an extract from my NullpoMino version:

That's what's happening in that part of the code:

[fumen]110@JeD3hbH3hbH3hbH3hbD3pbDPwJAiSZTASouABLAAAA?7eBDhBAgbZeYihbIwDAhb4GBAoUDAhb5GpUpbDXpZAtnceE?FbsiDvEXNEuoo2AQDckDlEtJEUBAAA7eDDpbjobjdBAAAZe?Qp0lMR4GlbQpNR4GlbQpoU5GpbDXpZAPoo2AiomoElIpTAS?4WSASoiJEkoo2AsAAAA7eDDpbDDdjiBAAAZe5GZilb4GNRY?ilb4GNRYipbDXpZAPoo2AiomoElIpTASYbSASoiJEkoo2Aq?AAAA7eDjnbDCdjiBAAA[/fumen]
Awesome, thanks for sharing. I'm actually surprised at how simple that is, using autohotkey got rid of a lot of the complexities though. I don't think I would have a hard time making that work with NullpoMino, so maybe it's a good idea to not share it if cheating is a concern. I might have to adapt this script on Tetris Friends since everyone here seems to hate it.

On second thought maybe I should just work more on my clone.

XaeL

As i said 10000 times already, Event based ftw, that way you can reduce minimal time to like 0.0001s



QuoteLike many setups here, it is useful if your opponent doesn't move and you get 4 Ts in a row.

Integration

Quote from: simonlcI might have to adapt this script on Tetris Friends since everyone here seems to hate it.

On second thought maybe I should just work more on my clone.
Second thought sounds much better. This bot was just a try to write a basic AI and make a video of it. There's no real usefulness for it. More explicitely, it's not worth porting it to Tetris Friends. TF has much slower DAS and runs with 40 frames per second. So this bot wouldn't be able to sub 20 s there. Additionally, TF has VERY slow softdrop speed. This bot softdrops an O every 3rd bag in average, so you'll lose a lot of time. And you'd need to introduce a variable telling you how high the JLO stack is, so that you know how long you have to press down softdrop key.

Ravendarksky

Kitaru has a TAS video clearing in 2.75seconds if it is at all relevant: http://www.youtube.com/watch?v=7glxpv5BELM...gQ&index=12

UJS3

I put the 2 step finesse stuff from the wiki in a spreadsheet to see how many KPT are needed on average (assuming all orientations are equally likely, 180 rotate is used).

I = 43/17
J, L, T = 3
O = 7/3
S, Z = 44/17

So assuming each piece is equally likely, average KPT is about 2.72. My new estimate would then be (2.72/4)*6.667 = 4.533 s

That TAS is a good indication of how far you can push the time. By choosing low KPT piece placements and using DAS preservation you can get well below this average. If we're only interested in the fastest possible time, then you can choose the piece order yourself (as long as it obeys bag).

Anonymous

Forgive me for the thread jack, but I thought that this was kind of relevant to the topic. Feel free to move the post to a new thread, Myndzi.

I also think it'd be interesting to see how fast a human could theoretically go by doing something along the lines of using the same random seed* (i.e. playing the same piece sequence over and over in multiple games) and seeing how fast they could finish 40 lines.

The reason for this is because 40 lines times are limited by two main factors:
- mental speed (which includes good stacking, how fast you can think to place pieces, etc)
- finger speed (which includes finesse, how fast you can place down pieces, etc)

By providing the same seed (and same piece sequence), the player should be able to create the same stack each game (since he has the same piece sequence). This should effectively cut out the mental speed aspect, since he doesn't have to think as much about what pieces are coming up. In effect, the only real factor is finger speed.

Players could possibly use this to see how fast they could theoretically go based on just finger speed. Likewise, there are games such as keyblox*, where finger speed is not as important as mental speed. Players could potentially use both of these options, which could improve their overall 40 lines skills.

Anyway, this is all conjecture, but I think it'd be interesting to see.

*For those who haven't programmed much, the seed determines how the random number generator creates the random numbers (and in Tetris's case, the piece sequence).

*keyblox is a tetris clone, except each piece placement is mapped to an individual key reducing the key presses per piece to 1.
My awesome downstacking guide, last updated (Jan 29, 2013): Downstacker's Guide to the Galaxy
Tired of the same old Tetris games? Read my idea for a revamped Tetris game! The Next

Integration

#12
Quote from: UJS3I put the 2 step finesse stuff from the wiki in a spreadsheet to see how many KPT are needed on average (assuming all orientations are equally likely, 180 rotate is used).

I = 43/17
J, L, T = 3
O = 7/3
S, Z = 44/17

So assuming each piece is equally likely, average KPT is about 2.72. My new estimate would then be (2.72/4)*6.667 = 4.533 s
It's interesting to see the average KPT numbers for 2 step finesse, but you cannot make the assumption, that 1 keypress = 1 frame. Sometimes, you can press keys simultaneously (moving and rotating), but sometimes you need more than 1 frame (DAS and doubletaps).

Let's take the O piece as example. Let's assume, you harddrop 1 frame after your last movement. Those are the frames you need at least (no DAS preservation) for certain spots (without harddrop):

on wall: DAS = 3 frames
1 step away from wall = DAS + tap = 3 + 1 frames
2 steps away from wall = tap + wait + tap = 1 + 1 + 1 frames
1 step away from middle = tap = 1 frame
stay in middle = wait = 1 frame

Now let's take the average (don't forget to add 1 frame for harddrop).

average # of frames = (2*3 + 2*4 + 2*3 +  2*1 + 1) /9 + 1 frames = 3 + 5/9 frames

That are 2.333 KPTs but at least 3.555 frames with 2 step finesse.

UJS3

Quote from: Integration
It's interesting to see the average KPT numbers for 2 step finesse, but you cannot make the assumption, that 1 keypress = 1 frame. Sometimes, you can press keys simultaneously (moving and rotating), but sometimes you need more than 1 frame (DAS and doubletaps).
Yes, good point. I didn't realize you need to wait between double tapping, but on second thought it makes sense

For keyblox, the fastest humanly possible time would come down to typing a known string of 100 characters as fast as possible. Apparently 1280 characters per minute has been done, that would give a time of about 4.688 s.

XaeL

Quote from: UJS3
For keyblox, the fastest humanly possible time would come down to typing a known string of 100 characters as fast as possible. Apparently 1280 characters per minute has been done, that would give a time of about 4.688 s.
Thats for words though. Keyblox has ;1'23154 all over the place.

You'd have to optimize the piece sequence significantly to get something that was wordy.

Here's an example of something i semi-optimized (tehres like no numbers pressed.. but I didn't optimize it to make it wordy. Also only tried about 20 times):



QuoteLike many setups here, it is useful if your opponent doesn't move and you get 4 Ts in a row.