Hacker News new | past | comments | ask | show | jobs | submit login
The Sinusoidal Tetris (andreinc.net)
168 points by nomemory 10 months ago | hide | past | favorite | 52 comments



Reminds me of quantum soccer [1] from a short story by Greg Egan

[1] https://gregegan.net/BORDER/Soccer/Soccer.html


> The pairs of modes involved depend on the player’s velocity; the exact rules are spelt out in the mathematical details, but it’s easy to experiment using trial and error.

Easy. This guy is truly in league of his own.


The quantum soccer league.


My first playthrough I quickly got it to where the amplitude was minimal, so then I just dropped low frequency low amplitude sinusoids for a while until I got bored. The following tries didn't go so well, but I guess even if I don't get the amplitude low I could still use the low frequency sines trick. I think this could be nice as a potential teaching tool for how sinusoids and waves combine. Sort of along the lines of this small game I made when I was a TA for an intro to acoustics class in college: https://goatesheard.com/ncg


This is wonderful. I think, ultimately it doesn't end up being a game as much as it is a wonderful way of looking at waveforms, simply because there is no goal except minimize. There should be an api so you can write code to pick the optimum changes for each drop.


Hello, this game is part of an article I am currently writing. I will add there the "optimal" sinusoid :). Thank you for the idea.


The goal is the same as Tetris – to last as long as possible before overflowing. This just doesn't have the mechanic of gradually getting faster.


I've added the feature so you can see the first 4 optimal sinusoids.


Fun but hard to control. Suggestions to improve:

1. Make it so two hands can be used. If have to keep repositioning my fingers then I can't remember what each key does. Perhaps WADS and IJKL.

2. Phase: should not bottom out, it should allow for unlimited movement in either direction (wrap around). Should have same spatial/screen movement regardless the frequency, so scale up the phase shift as frequency drops.

3. Frequency: Fix the curve at center of the screen when adjusting frequency, instead of the left edge. Currently imbalanced: the right side move a lot and the left is fixed. Hard to do fine adjustments.

And please make it go slower.


Also QUERTY vs QUERTZ keyboards, Y and Z are flipped so that A/Y makes no sense. That is a really common issue, for example also with programs that want to use the keyboard to play piano. Use scan codes instead of key codes. [1]

[1] https://hacks.mozilla.org/2017/03/internationalize-your-keyb...


Tapping quickly on iOS causes the page to zoom in... makes it hard to play.


For me as well.

I think making the controls into actual button elements would fix this. (Suspecting they are divs with onclick handlers now.)


They are rectangular shapes on the canvas.


Also, the Z key is a bad choice for controls, because in some parts of the world it is at an entirely different location on the keyboard.


> Perhaps WADS and IJKL.

I don't think 2 hands are needed, but WASD might be more intuitive. W/S to increase/decrease amplitude, A/D to decrease/increase frequency, Q/E to increase/decrease the phase.


Definitely agree on the slower bit. I would love to play a much slower version of this at least to learn the controls better and also think through some strategy.

If it sped up over the course of the game that would be great.


Implemented 2.

Now there's a turn-based mode so it stops and gives you time to think.


Thanks!!


I looked at it on mobile, so I couldn't actually play it, but can't you just fix a period and amplitude and alternate the phase forever or just set the amplitude to 0?


Yes, same frequency + smallest amplitude + phase adjustment is the optimal strategy


Arguably, minimal frequency + phase adjusted so the falling sinusoid has only negative values in the playing area is "more optimal" (more room for error).


Ha, clever. I guess the frequency should be limited so that the period can't be longer than the playing area.


Hello, I've added some buttons so you can look on it on mobile.


Seems like you can just increase the period arbitrarily large and then shift it in time such that the graph is entirely occupied by the values of the sinusoid less than zero.


The text says something about how you shouldn't make the waveform blow up outside the canvas, but I am not sure whether its measured or shown.


Do you always advance to the next stage? If so I appear to win by just clicking "drop" every time.


It returns to first stage after the wave hits the bounds


Reminded me of a question from my A-level maths exam at high school; it also managed to install the same sense of panic!


I meant instil...


This is one of the coolest things I've seen in a long time!


Very cool and creative!


Slow it down, call it Fourierdle.


FFTetris


Foutris


This is really good


x closes my tab on both FF and Chrome

EDIT: never mind, it was due to my Vimium extension


Cool idea, but pretty much impossible on iPhone safari.

Clicking the controls too fast just zooms in and out


Author here, I am not a webdev, and I have no idea how to fix that. Do you have any suggestions?


Add this to head:

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">


You can disable default touch actions on buttons like this:

https://stackoverflow.com/questions/10614481/disable-double-...


I think making the controls into actual button elements would fix this. (Suspecting they are divs with onclick handlers now.)


tested, meta is not enough

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum scale=1.0, user-scalable=0">

    <style> 
    body {
      touch-action: none;
    }
    <style>


If I put touch-action: none, the screen is frozen on my Galaxy, and I cannot zoom out to see the canvas.

I've tried touch-action manipulation instead.

Is it working better now?


Would be nice to play on mobile


I have added some buttons so you can play on mobile.


Please suppress "user-select" through CSS ao that rapid button tapping won't cause parts of the screen to be selected.


Try now.


This is too boring as you can drop a straight line every time that minimally changes anything. The game is extremely repetitive and doesn't require any thinking. It's like tetris but you always get the line piece and the speed ramps very slowly.


I agree, it needs scoring based on how much you actually manage to reduce the sinusoid. Currently you aren't punished for a null change.

Also the general game design is broken in a few other ways:

- no clear indication when a loss occurs. I played for a while and didn't realise a loss had occurred half way through my playing

- you quickly reach a single dominant frequency since you instinctively try to match the frequency of the current sinusoid

- you can control every parameter of the incoming wave, which means this isn't much like tetris, where you can't change one of the parameters of the incoming block (its shape). I would suggest locking some aspect of the incoming wave, which would also fix the next issue

- there are too many controls and they are also not easy to change quickly


Game has changed, no it's possible to actually win, if you reduce the signal very close to 0.

There's an indication for a loss and for a win.

There's a turn based mode implemented.

You can get hints for the best sinusoids.


> you can drop a straight line every time

The unreasonable effectiveness of linear regression...


Congratulations, you've beaten Fourier Tetris.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: