Hacker News new | past | comments | ask | show | jobs | submit login
Quantum Game with Photons (quantumgame.io)
154 points by JepZ on Dec 12, 2017 | hide | past | favorite | 50 comments

Author here. Really excited to see Quantum Game on HN! :)

Just in case, project repo is here: https://github.com/stared/quantum-game

For more on learning (and teaching) quantum mechanics, see: http://p.migdal.pl/2016/08/15/quantum-mechanics-for-high-sch...

And BTW: a question to you (as I guess there are many JavaScript whizz kids): how to make it more reactive?

@stared Thanks for that wonderful game. I played through all levels some months ago and really liked it. When I saw that interactive quantum link [1] on the front page today, I was reminded of your game and thought some other might like it too.

Thanks again for building it, it was the first time I could actually bring my mind to embracing quantum mechanics :-)

[1] https://news.ycombinator.com/item?id=15902190

found a bug: if i click next after completing a level before the "you won" screen pops up and subsequently click next level on the "you won" screen i can skip two levels ahead

I was just about to comment the same thing. :)

Thanks for the game. I am playing through the levels and it is a lot of fun. But so far I have not found an effect that cannot be calculated with the classical Maxwell equations in matter.

A single photon QM is basically classical wave mechanics.

My original intention was to do many-photon QM game (and wrote game engine for that). But in development I discovered that even wave mechanics offer quite a lot interesting, and counterintuitive, puzzles.

With one photon there the only thing that does not have a classical analogues is https://en.wikipedia.org/wiki/Elitzur%E2%80%93Vaidman_bomb_t..., which can be easily assembled from the blocks (well, the idea for using a light-sensitive bomb comes from there!).

omg, i <3 love this... esp cool that you included technical details like the amount of rotation caused by glass slabs.

As a physics student I always hated quantum optics. IMHO the by far least intuitive field in undergrad physics. I never got. Not even a bit. Circuits, Special relativity and quantum physics in the context of atoms was so much more approachable to me. I mean, I like physics. I wonder why optics is so different.

In the end all I did was learning some standard configurations of optical instruments. That and ray optics made me pass. Of course i forgot almost everything almost instantly.

I really love the idea to get a better intuition for what is going on by a game.

By level 30 I thought I understood how the Faraday rotator works in this game. In level 32 I feel like my solution should work, but it doesn't. It behaves completely different that I think it should. The help page don't help me at all.

I'd like to see some "debug" mode where I can freeze time and inspect the quanta.

Also I feel that the simulation sometimes "gives up" too early, and i can't see why something isn't working because it ends too early.

It looks like it ends when the 'chosen' path clicks for that round. That is, if you have a 75% chance of going on a long path and a 25% chance of hitting a rock immediately, 25% of the time it will end quickly (and not show the possible, but not chosen, path).

I, too, found that annoying.

I can't really make sense of interference. I made it to level 6, but I didn't understand the solutions for any of the 3 previous levels. I found some of the online help, but I'm not really making any sense of what it's saying.

I also found the interference in the beam splitters surprising, although experimenting in the game let me work out enough of the logic to finish the levels.

I found an article on Wikipedia that, from the pictures, seems to be describe the process... I assume this is the simulated effect?


I don't Hong-Ou-Mandel is a two-photon interference. So far in this game there is only a single photon, so you get https://en.wikipedia.org/wiki/Mach%E2%80%93Zehnder_interfero... and https://simple.wikipedia.org/wiki/Michelson%E2%80%93Morley_e... interferometers.

This game isn't writing the numbers (complex-valued probability amplitudes of states, classical EM vectors even) anywhere so it's going to be pretty hard to relate what you're seeing here to the math that you'll find if you look up interference elsewhere.

I'll make an attempt here, though. I think the effect on level 4 is totally classical so it shouldn't take too much background.

1. The solution to a problem involving light is called a wavefunction, which is just a name assigned to functions that map position and time onto what the wave is doing at that position and time. I.E. for a sound wave, W(x: position, t: time) => p: air pressure.

2. The meat of a "wave equation" is essentially also a function, but it's higher-order. It maps wavefunctions onto wavefunctions, I.E. consider high-order function L, such that L(W: wavefunction) => X: wavefunction. The name for this map is an "operator," by the way.

3. We can set up operators L(W) so that they map all "true and physical" wavefunctions on to the zero-function, f(x,t) = 0. This contrivance is the job of physicists to design; so for our discussion let's just take it that for every physically possible W(x,t), it is the case that L(W(x,t)) = 0. (And vice-versa, every solution to that equation is physically possible.) The equation L(W) = 0 is called the "wave equation," by the way.

3. It is a property of L that L(W + Q) = L(W) + L(Q) for wavefunctions W and Q. This implies that if L(W) = 0 and L(Q) = 0, then L(W + Q) = L(W) + L(Q) = 0+0 = 0. Therefore, since physical possibility <-> L(W) = 0, then we may conclude that the sum of any two physically possible wavefunctions W and Q is another physically possible wavefunction, W+Q.

4. Ignore time and look at my nice graph[0]. This illustrates adding two functions (there A(x) and B(x) ) which also happen to be solutions to the wave equation. Play around with the parameter p, (whose purpose is to let you select A to be one of many horizontally offset versions of itself) and see if you can make A + B do anything noteworthy.

[0] https://www.desmos.com/calculator/iwa3auxvuz

5. Hopefully in looking at my graph, you have noticed that for some values of p, A+B became flat everywhere. Now, I can finally explain what's going on with level 4. When the beamsplitter produces two beams from one, the two functions it shoots out have two different values of p, the dynamics detailed in [1]. If two beams are incident on the splitter, four beams will shoot out, and since some of them are overlapping in space they will add and you'll see the superposition effects. See my drawing [2]. (By the way, the parameter p is called phase, and the verb for the thing the waves to under superposition is called interference.)

[1] https://en.wikipedia.org/wiki/Beam_splitter#Phase_shift

[2] I've drawn it here. Please don't over-interpret it, I just sketched it in paint without a lot of attention to detail. https://imgur.com/a/7YLMa

Hopefully this is helpful and sheds some light on the underlying physics!

Thanks for the great explanation! If you don't mind, I had a question about '3.' I get how it's used in making your larger argument, but as a thing in itself I'm kinda lost. Part of what I'm wondering is how it's okay to say 'L(W) = 0' when earlier you described L(W) like 'L(W: wavefunction) => X: wavefunction'; so is the zero in 'L(W) = 0' just shorthand for something like 'L(W) = (f(x,t) = 0)'?

(I'm also curious why mapping to the zero function ends up being the central criterion for physical possibility—but I'm guessing that's a rather deep subject ;))

Edit: NVM I see what's going on with 'L(W(x,t)) = 0' now: the equation is equating the full evaluation of the nested functions on the left (using the x,t params) with zero. When written like 'L(W) = 0' it looks like it's equating the function returned by L(W) with zero.

>it looks like it's equating the function returned by L(W) with zero

There is a deeper point to be made here that I'm glad you brought up. Functions form a vector space (because they satisfy the axioms of vector behavior, basically because they can be added to each other and scaled by constant multiples). In linear algebra the symbol 0 often does double-duty as the zero vector, which is defined as the vector that doesn't change other vectors when it's added to them. So, here, when I write L(W) = 0 I'm implicitly invoking 0 = f_zero(x,t) = 0.

As for why "mapping to zero" has a physical basis, well, it's really more of a thing we're always guaranteed to be able to do. You can always subtract everything from the right-hand side of an equation! For example, Wikipedia introduces the one-dimensional wave equation as D_t^2 u = a^2 D_x^2 u. I can also write that as L[u] = D_t^2 u - q^2 * D_x^2 u = 0, so L[u] = 0. (In my notation, D_x is the derivative with respect to x, and D_x^2 is the second derivative with respect to x.)

The real question is why the addition thing works; if I had to try explaining it I would just say it's just fundamental that Maxwell's equations are linear, and when dealing with things that aren't, we usually approximate them with linear functions anyways[0]. That's how gravitational waves emerge from GR, by the way: at low energies the nonlinear equations behave nearly linear, and in that approximation the familiar wave equation falls out.

[0] If you zoom in to a small enough range in the graph of all but the most esoteric functions, the thing on your screen will look like a line. Try it, it's a good intuition to have.

Okay, that makes a lot more sense. Thanks. I missed this in your original phrasing, "We can SET UP operators L(W) so that they..."—but I think I see now: equating L(W) with the zero function is algebraically convenient, since we want to solve for an unknown function/vector, and using zero there allows us to be 'agnostic' about what that unknown function/vector is (any other value would 'say something' about the unknown).

> The real question is why the addition thing works

Unfortunately I'm still at the point where I can't see why it should be surprising that it works. I'm assuming that by the 'addition thing' you are referring to the fact that adding two wave functions always produces another wave function—or maybe it's something about the characteristics of the wave function produced through adding? I'm not sure how linearity plays into things here. Maybe it's surprising that it's possible to form a linear operator (I'm assuming the "operator" you mentioned is this: https://en.wikipedia.org/wiki/Linear_map) for wave functions? I guess not though since it's probably just using the structure of those functions as vectors and it doesn't matter what they're 'about'. Nope, not sure :)

While the wavefunctions are vectors by virtue of being functions, it still remains to be seen that the set of "physically possible" wavefunctions is also a vector space. For example, if the physics were such that we were equating the local kinetic energy of a string to, I don't know, it's position or something, we would end up with an equation looking like (D_t f(x,t))^2 - f(x,t) = 0. It still can be written as an operator (not all operators are linear), but the addition thing wouldn't work anymore. It's a remarkable pattern in physics that those squared terms tend not to appear in reality.

If you turn on the JS console, you will get quantum state printouts (with all nifty complex numbers and polarization vectors).

Vertical and horizontal here seem quite confusing. The absorptive polarizer with vertical lines drawn on it passes through photons passing through PBS, which game calls horizontal. So either the polarizer lines have negative logic (indicating what is absorbed, not passed through), or there is some inconsistency. Similarly, the horizontal polarization is represented as photon bouncing up and down ("vertically") if it travels right. This can get confusing.

I wonder if some polarization arrow can be drawn somehow, like: https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTAlDUU...

I admit I had a big struggle with visualizing polarizers. It is easy to do in 3D or some 2.5D. In 2D every visualization was confusing (the one we use is the least confusing).

Any ideas are welcome here (as long they work for every possible orientation and are 2D).

@stared Great game, much appreciated! I have a question about level 20. If I put a sugar glass behind the laser and then two directly at the two outputs of the PBS, it doesn't work (interference triggers the bomb). If I move the two sugar glasses after the PBS behind the two respecitive mirrors next in each path (so the paths become Laser->SG->PBS->Mirror->SG in each arm), the interference works correctly and I pass the level. I just can't wrap my head around why the phase is different in each case. It would be really helpful to be able to inspect the quanta at each point in time so you can see how each element affects phase and polarization exactly.

Could you send a screenshot?

In any case:

Reflection changes "left-right". So effectively, a sugar solution (rotating polarization) before mirror rotates it in the opposite direction (vs a sugar solution after a mirror). Actually it is a tricky thing I realised while testing this game. I thought it was an error in code. But nope - it was how does physics work. :)

Tip for those lost on level 1 - you can actually click on the mirrors itself to rotate them. Took me a while to figure that out...

And use Firefox.

Can confirm: clicking mirrors registers as a drag in Chrome 62.0.3202.94 under every circumstance I can find.

Works fine on 63.0.3239.84 / macOS.

Chrome 62.0.3202.94 on Ubuntu 16.04 works fine for me.

Yup, I was using chrome and was totally lost.

happens in chrome as well.

Not always. Seems like under some conditions Chrome is interpreting it as a drag no matter what I do. Seems to depend on the window size, or maybe what monitor I have it on...

Reminds me of spending hours upon hours on Chip's Challenge. Unfortunately this doesn't seem mobile friendly.

Have you ever tried Chip's Challenge 2? Chuck finally got the rights back and released it recently[1]. I actually thought the second one had even more interesting computer-themed mechanics than the first one, it's a shame it was released so late. There's also a nostalgic tileset you can drop in for CC2 (depending on which version you consider nostalgic)[2].

[1] http://store.steampowered.com/app/348300/Chips_Challenge_2/

[2] https://drive.google.com/file/d/0B0klXLq7HW8sTzNhWTY3clo5Xzg...

I had no idea there was a 2, thanks for sharing. Opening up that tileset brought memories of hours spent on certain levels flooding back!


Can anyone explain why these two arrangements are not equivalent? They seem to both cause same phase shift and reflections, but the first one causes the photon to pass to the right, and the second - to split.



Reflection changes "left-right". So effectively, a sugar solution (rotating polarization) before mirror rotates it in the opposite direction (vs a sugar solution after a mirror).

Actually it is a tricky thing I realised while testing this game. I thought it was an error in code. But nope - it was how does physics work. :)

Still trying to reconcile what's going on in level 2. Do I need to accomplish this over multiple attempts?

The game is trying to teach you how basic rules of quantum mechanics work. In reality, emitting a single particle leads to probability of it reaching multiple detectors with a given chance. You have to set the splitters in such a way, that all detectors can be reached with a chance greater than 0.

Try using a straight beamsplitter to send the photon back somewhere it's already been.

Reminds me of Light House game that I used to have on my phone.


If this was available as a mobile app, I would totally play it - nice little time waster.

Very cool! I enjoyed playing a little during my lunch break. I've got to say, for what it is, it's very fun. I don't feel like I'm learning, but I also feel like I'm learning. :)

Hi, I believe, I am able to skip levels. If I finish a level, I can forward before the popup, and then again press next level on the popup window.

You can just click the level number in the list on the left side. No need to trick.

I am stuck at 25, 31 and 34. Does anyone has a cue ?

25.1-25.2: Avoid the left bomb first. Cut the right bomb risk to 50%.

25.3-25.5: Photons don't care about the direction of time. Fire one backwards in time from the detector to the emitter.

31.1-31.2: To avoid the bomb, the light must be polarized horizontal ASAP.

31.3-31.4: A sugar and a rotator in series, or a rotator and a mirror will preserve polarization going one way and rotate 90 degrees the other way. You may have to flip the rotator over by clicking on it.

31.5-31.9: Go backwards from the detector to figure out where the polarization has to be horizontal, and where it has to be vertical. You never need to consider interference.

34.1: Without rotating the polarization somehow, you'll never get enough photons through the filter.

34.2-34.3: Avoid hitting the rock and the top bomb.

34.4-34.5: You only have one option left for reflecting away from the bottom bomb. And you'll need vertical polarization to use it.

34.6-34.8: You can only absorb 25%, and it should be obvious by now which path you have to absorb from. Now arrange glass and vacuum to produce the correct interference.

Here's my solution to 25:


Dear lord, please tell me where the cheat or hint pages are for this. I'm stuck.

97.9% against 100% and I simply don't know what to do.


Great game! :)

I don't understand what the point of having two adjacent lemonades is.

Each lemonade rotates polarization of light by 45 degrees. Two rotate by 90 degrees, i.e. changing from horizontal to vertical and vice versa.

Thought was Firefox related.

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