Showing posts with label paradox. Show all posts
Showing posts with label paradox. Show all posts

Thursday, May 7, 2015

The Critical Hit Paradox

Occasionally, while browsing 4chan's /v/ or a similar board, I'll see a thread beginning with the following game-themed math problem:
"You hit an enemy twice. At least one of the hits is a crit. Assuming a 50% crit chance, what is the probability both hits are crits?"
A crit, of course, is a "critical hit" and so a 50% crit chance is rather high, but that's not important. This is basically a variant of the second question of The Two Children Problem, also known as the Boy or Girl paradox:
"Mr. Smith has two children. At least one of them is a boy. What is the probability that both children are boys?"
We could also ask the same question in terms of coin flips:
"Two coins are flipped. At least one comes up heads. What is the probability that both coins come up heads?"
This last version, in my opinion, is far less contrived than one involving critical hits or child gender. Any variation of the question, however, is bound to lead to extensive debate despite its seemingly trivial nature. The question as written is ambiguous, hence the controversy surrounding the original formulation of the Boy or Girl paradox, and hence the nauseating debate that ensues whenever the game-themed version of the problem is posed to the denizens of /v/. The person starting the thread always knows this will happen, too. Much like the moving portal paradox, this problem serves little purpose other than to cause trouble and to make people angry.

But I'm more intrigued than angry. Why exactly does such a seemingly simple question cause so much confusion? Why are different people so absolutely certain of so many completely different answers? A math problem like this should have one unambiguous and provable solution, but I count three common answers on which people seem willing to bet their lives: 1/4, 1/3, and 1/2.

In an attempt to lessen the confusion, I will attempt to explain the justifications for each of these answers below. First, however, I'll summarize what we know to be incontrovertibly true about the given scenario. And, because this is a video game blog, I will be working with the "critical hit" variation of the problem, even though I think coin flips are easier to explain.

The Facts (and One Assumption)


The problem, as written, specifies a 50% critical hit chance. In other words, each attack has a 1/2 probability of producing a critical hit (or "Crit"), and a 1/2 probability of producing a non-critical hit (which I will call simply "Hit"). We are given no other combat-related probabilities, so we will have to assume that "Crit" and "Hit" are the only possible results of an attack (i.e., we cannot "miss" or anything else). This seems reasonable, as the problem is very obviously meant to be a variant of the Boy or Girl paradox, and the original question which is the subject of that paradox does not allow any genders other than boy or girl.

In summary, the possible outcomes of a single attack (with associated probabilities) are
Crit - 1/2
Hit - 1/2
Therefore, if we were simply to attack twice, we would expect the possible outcomes (with associated probabilities) to be
Crit Crit - 1/4
Crit Hit - 1/4
Hit Crit - 1/4
Hit Hit - 1/4
where we have listed Crit Hit and Hit Crit separately to preserve information about the order of the attacks (in case we need it) and, perhaps more importantly, to demonstrate more clearly that getting one Crit is twice as likely as getting two Crits. Alternatively, if we really don't care about the order in which the attacks took place, we could write the very same result as
Two Crits - 1/4
One Crit - 1/2
No Crits - 1/4
but the probability of getting two Crits remains the same, and getting one Crit is still twice as probable.

No matter how we write it, one should note that the set of outcomes described above is based solely on the stated 50% critical hit chance for every attack. Let's not forget that we also have some additional information about a particular pair of hits. According to the problem, we hit an enemy twice and at least one of those hits is a critical hit. However, we are not being told which hit is critical.

If we were told that, say, the first hit is critical, the probability of two critical hits would be exceedingly easy to find: It would simply be the probability of the second hit being critical, so 1/2 would be the answer. Equivalently, in terms of our four equally probable outcomes (see above), we can see that two of them would be ruled out, leaving only two equally probable outcomes remaining:
Crit Crit - 1/2
Crit Hit - 1/2
Hit Crit
Hit Hit
Unfortunately, this is not how the problem is phrased. We are only told that at least one hit is critical — it could be one or the other, not necessarily the first — and because of this, depending on how you understand the question, you might get an answer which is very different from 1/2.

Guaranteed Critical Hit: The "1/4" Interpretation


One fairly common interpretation of the problem (with which, for the record, I strongly disagree) is that "at least one Crit" is some kind of gameplay mechanic which is enforced during combat. In other words, in this interpretation, it is predetermined that we are guaranteed one Crit when attacking the enemy twice. Take care to note, by the way, that this is not simply a misunderstanding of what "50% Crit chance" means. Rather, it's like this: The first attack has a 50% chance to produce a Crit. If it does, the second attack then has a 50% chance to produce a Crit. However, if the first attack instead produced a regular Hit, the second attack must then produce a Crit in order to fulfill the requirement.

In other words, Hit Crit is assumed to be the only possible outcome after an initial Hit, and so it has the same probability as that initial Hit. Meanwhile, Crit Crit and Crit Hit are both possible outcomes following an initial Crit, and they share equally the probability of that initial Crit. The probabilities are, therefore,
Crit Crit - 1/4
Crit Hit - 1/4
Hit Crit - 1/2
so the probability of two Crits — and thus our answer to the question — is 1/4.

If you have Python installed, you can easily verify this result for the "guaranteed Crit" scenario using the computer simulation below. The variables first and second represent the first and second attacks, respectively; the Boolean values True and False represent Crit and Hit, respectively; the variable double keeps track of how many times we get two Crits; and the variable trial is a counter for the while loop, which iterates 100000 times. With all this in mind, the algorithm should be self-explanatory.

# Guaranteed Critical Hit (100000 trials)
import random
double = 0
trial = 0
while trial < 100000:
    first = random.choice([True,False])      # first = random
    if first:                                # if first = crit:
        second = random.choice([True,False]) #     second = random
    else:                                    # if first = no crit:
        second = True                        #     second = crit
    if first and second:                     # if two crits:
        double += 1                          #     count double
    trial += 1                               # count trial
print("Chance of two crits: "
      + str(100 * double / trial) + "%")


This simulation will indeed return a result of approximately 25%.

However, the fact that I got a computer to spit out this number does not mean it's the correct answer to the question. The algorithm used in this simulation and the logic used in the preceding discussion are based on an interpretation of the problem which, in my view, is severely flawed. There's no evidence that the statement "at least one of the hits is a crit" is any kind of gameplay rule to be enforced during combat. There's no evidence that it was predetermined before the attacks took place. All we know is that the statement turns out to be true for a particular instance of two attacks.

Furthermore, the notion of a guaranteed Crit makes no sense when we've already been told to assume that the Crit chance is 50%. This interpretation of the problem forces us to say that the Crit chance is sometimes 50% and sometimes 100%. Worse yet, while a strict reading of "50% Crit chance" would normally lead us to assume that the result of each attack (like a coin flip) is independent from the result of any other, in this solution we are forced to admit that the result of the second attack depends on the result of the first attack.

Fortunately, the next two interpretations avoid all of these problems by dropping the dubious assumption that a "guaranteed Crit" exists in gameplay.

Partial Information Provided: The "1/3" Interpretation


Another common interpretation of the problem is as follows: The two attacks take place with no restrictions other than a 50% Crit chance for each, calculated independently. The fact that we have "at least one" Crit is simply information which then happens to be true for this pair of attacks in particular.

As stated previously, when attacking twice, we should expect the possible outcomes to be
Crit Crit
Crit Hit
Hit Crit
Hit Hit
all with equal probability. Now imagine that, upon attacking twice, we don't know the actual result of each individual attack. This information has been hidden from us. All we know, after the fact, is that we happened to get at least one Crit in the process. Perhaps the game simply tells us so, or perhaps we were able to figure it out because our total damage for both attacks is known to be above some threshold. In either case, of all the possible outcomes, this only rules out Hit Hit.

In other words, of the four equally probable things that could have possibly happened, we know merely that one of them did not happen. The remaining three possible outcomes still have equal probability, and so those probabilities are
Crit Crit - 1/3
Crit Hit - 1/3
Hit Crit - 1/3
Hit Hit
Our answer to the question, therefore, is that we have a 1/3 probability of getting two Crits. It really is that simple.

As with the previous interpretation, we can use a computer simulation coded in Python to verify the result for this scenario. The variables first and second again represent the first and second attacks, respectively; the Boolean values True and False again represent Crit and Hit, respectively; and the variable double again keeps track of how many times we get two Crits. Note, however, that the variable trial does not simply count how many times we run through the while loop. It actually counts the number of runs in which we get at least one Crit. (These are the trials which are considered valid for the experiment, and the while loop runs until we have 100000 of these valid trials.) Therefore, the final result is the proportion of two-Crit trials to at-least-one-Crit trials, expressed as a percentage. In other words, the result is the percentage of at-least-one-Crit trials in which we get two Crits, and that's exactly what we want to find.

# Partial Information Provided (100000 trials)
import random
double = 0
trial = 0
while trial < 100000:
    first = random.choice([True,False])  # first = random
    second = random.choice([True,False]) # second = random
    if first or second:                  # if at least one crit:
        trial += 1                       #     count valid trial
        if first and second:             #     if two crits:
            double += 1                  #         count double
print("Chance of two crits: "
      + str(100 * double / trial) + "%")


As expected, this will give a result of approximately 33%.

Partial Result Observed: The "1/2" Interpretation


Yet another common interpretation begins much like the previous one: The two attacks take place with no restrictions other than a 50% Crit chance for each, calculated independently. Therefore, in general, we should expect four possible outcomes, each with equal probability:
Crit Crit
Crit Hit
Hit Crit
Hit Hit
This time, however, information about the result of each individual attack is not completely hidden from us. We need only check the result of an attack, and when we do this for one of the attacks, we see that it happened to be a Crit. In other words, we are not merely being told that we got at least one Crit in the process of attacking twice. We are actually discovering this fact by sampling the data, and seeing that one particular attack — either first or second — did indeed produce a Crit. Having ascertained this, we've then ruled out two of our four possible outcomes. We are left with either
Crit Crit - 1/2
Crit Hit - 1/2
Hit Crit
Hit Hit
or
Crit Crit - 1/2
Crit Hit
Hit Crit - 1/2
Hit Hit
depending on which attack we checked, and it doesn't really matter which. Once it has been established that a particular attack resulted in a Crit, the probability of getting two Crits depends entirely on the Crit chance of the other attack. The answer, therefore, should be 1/2.

Once again, we can use Python to write a computer simulation verifying this result. As in the other simulations, the variables first and second represent the first and second attacks, respectively. Each of these two variables will be assigned a Boolean value: True or False, representing Crit or Hit, respectively. The variable double keeps track of how many times we get two Crits. Finally, the variable trial is a counter for the while loop, which iterates 100000 times. For each trial, the program picks the first or second attack at random (because it should not matter which attack we sample). That attack is then set to Crit (to reflect our finding that the sampled attack is a Crit), while the other attack is randomly set to Crit or Hit (to reflect the fact that its result is unknown).

# Partial Result Observed (100000 trials)
import random
double = 0
trial = 0
while trial < 100000:
    gotCrit = random.randint(1,2)            # pick 1 or 2
    if gotCrit == 1:                         # if picked 1:
        first = True                         #     first = crit
        second = random.choice([True,False]) #     second = random
    elif gotCrit == 2:                       # if picked 2:
        second = True                        #     second = crit
        first = random.choice([True,False])  #     first = random
    if first and second:                     # if two crits:
        double += 1                          #     count double
    trial += 1                               # count trial
print("Chance of two crits: "
      + str(100 * double / trial) + "%")


The result given by the simulation will be approximately 50%, as expected.

Comparison of Solutions


Now this is a conundrum. We have three different answers — 1/4, 1/3, and 1/2 — and it's not just because I'm bad at math. The discrepancy doesn't result from any simple arithmetic blunders; in fact, the Python simulations prove that these numbers aren't just coming out of nowhere. Each of these answers follows directly from a different interpretation of the problem, and all of these interpretations seem to make some sense.

The "guaranteed Crit" interpretation, however, seems to makes the least sense. As explained before, the idea that a guaranteed Crit is predetermined (and that this requirement should be enforced during combat) is an additional assumption not stated in the problem. It's also inconsistent with the stated assumption of an independent 50% Crit chance for each swing. This alone, in my opinion, is enough to lay this dubious interpretation to rest and say definitively that 1/4 is not the correct answer. Besides, the problem discussed here is clearly intended to be a rewording of the second half of The Two Children Problem, for which 1/4 was never a candidate answer.

That original problem is actually a set of two questions. As they are stated on Wikipedia:
  • Mr. Jones has two children. The older child is a girl. What is the probability that both children are girls?
  • Mr. Smith has two children. At least one of them is a boy. What is the probability that both children are boys?
The answer to the first question is very obviously 1/2, because we know the older child is a girl. The probability Mr. Jones of having two girls therefore rests entirely on the probability of the younger child being a girl:
Boy Boy
Boy Girl
Girl Boy - 1/2
Girl Girl - 1/2
The answer to the second question, though it turned out to be controversial, was originally supposed to be 1/3, because we only know that at least one child is a boy. The scenario in which Mr. Smith has two boys is one of three equally probable outcomes, because all we can say is that not both of the children are girls:
Boy Boy - 1/3
Boy Girl - 1/3
Girl Boy - 1/3
Girl Girl
The competing answer to the second question is 1/2 yet again. Why two answers? It depends on how we find out that "at least one" child is a boy. The answer is 1/3 if Mr. Smith simply tells us that he has at least one boy (or, equivalently, not two girls). However, the answer is instead 1/2 if we have seen one of the children and observed that he is a boy, because then we can say that the probability of having two boys depends entirely on the gender of the other child.

If you've been paying attention, you know this is exactly what's going wrong with the critical hit problem (which, as we can see, is almost identical to the Mr. Smith question). We're getting two very different answers — 1/3 and 1/2 — depending on how we find out that we got at least one critical hit. Our intuition tells us this shouldn't matter at all, so we're tempted to say that our preferred answer (whatever it may be) is true regardless of how the information is discovered. However, we've already seen that this is not the case. Each of the two answers is totally correct if you read the problem a certain way.

Let's take another look at the "partial information provided" simulation:

# Partial Information Provided (100000 trials)
import random
double = 0
trial = 0
while trial < 100000:
    first = random.choice([True,False])  # first = random
    second = random.choice([True,False]) # second = random
    if first or second:                  # if at least one crit:
        trial += 1                       #     count valid trial
        if first and second:             #     if two crits:
            double += 1                  #         count double
print("Chance of two crits: "
      + str(100 * double / trial) + "%")


The assumption in this interpretation of the problem is that, after a particular instance of two attacks, the game has simply told us we got at least one Crit. In the simulation of this scenario, we are essentially counting double-Crit instances in a pool of 100000 attack pairs, but in building that pool, we're only considering attack pairs for which there was at least one Crit. The result of this simulation proves without a doubt that, of all attack pairs producing at least one Crit, 1/3 of those attack pairs will produce two Crits.

Now let's take another look at the "partial result observed" simulation:

# Partial Result Observed (100000 trials)
import random
double = 0
trial = 0
while trial < 100000:
    gotCrit = random.randint(1,2)            # pick 1 or 2
    if gotCrit == 1:                         # if picked 1:
        first = True                         #     first = crit
        second = random.choice([True,False]) #     second = random
    elif gotCrit == 2:                       # if picked 2:
        second = True                        #     second = crit
        first = random.choice([True,False])  #     first = random
    if first and second:                     # if two crits:
        double += 1                          #     count double
    trial += 1                               # count trial
print("Chance of two crits: "
      + str(100 * double / trial) + "%")


The assumption in this interpretation of the problem is that, after a particular instance of two attacks, we checked the result of one attack and saw that it was a Crit (and this is how we know that we got at least one Crit). In the simulation, we are again counting double-Crit instances in a pool of 100000 attack pairs, but this time the pool consists of attack pairs for which a particular attack — either first or second, at random — was determined to produce a Crit. The result of this simulation proves without a doubt that, of all attack pairs in which a chosen attack is known to produce a Crit, 1/2 of those attack pairs will produce two Crits.

It seems 1/3 and 1/2 are both correct answers. They're just answers to two slightly different questions which sound very much the same.

Bayes' Theorem


For more fun (and just as many answers), we can attempt to solve the problem using Bayes' theorem, which states
P(A|B) = P(B|A) * P(A) / P(B)
where
P(A|B) is the probability of event A, given that event B occurs
P(B|A) is the probability of event B, given that event A occurs
P(A) is the probability of event A
P(B) is the probability of event B
Once again, if we're attacking twice with a 50% Crit chance, we must consider four equally probable outcomes:
Crit Crit - 1/4
Crit Hit - 1/4
Hit Crit - 1/4
Hit Hit - 1/4
So let's say A is the event that we get two Crits. The probability of this occurring alone is
P(A) = 1/4
Now let's just say B is the event that we get at least one Crit (or, equivalently, the event that we do not get zero Crits). The probability of this occurring alone is
P(B) = 3/4
Meanwhile, the probability of getting at least one Crit, given that we get two Crits, is obviously
P(B|A) = 1
Now Bayes' theorem gives the result: The probability that we get two Crits, given that we get at least one Crit, is
P(A|B) = (1) * (1/4) / (3/4) = 1/3
On the other hand, we could instead say B is the event that a chosen attack is observed to be a Crit. The probability of this occurring alone is
P(B) = 1/2
Meanwhile, the probability that one attack is observed to be a Crit, given that we get two Crits, is obviously
P(B|A) = 1
Now Bayes' theorem gives a different result: The probability that we get two Crits, given that a particular attack is observed to be a Crit, is
P(A|B) = (1) * (1/4) / (1/2) = 1/2
Even when we turn to equations, a subtle difference can change the answer.

Conclusion


So which number — 1/3 or 1/2 — is the correct answer to our problem? I think I've proved quite enough times that 1/3 and 1/2 are each absolutely correct given the right assumption about how the stated information was obtained. However, considering the critical hit problem's roots in the Boy or Girl paradox, I think I'm going to have to choose 1/3 as the better answer. Despite the ambiguous wording, the whole point of Martin Gardner's original 1959 version of The Two Children Problem was that the two questions should have two different answers: 1/2 for the first, and 1/3 (not 1/2 again) for the second. The critical hit problem discussed here is based on the second question.

Even without author intent as backup, the decision to choose 1/3 over 1/2 is not at all indefensible. Getting an answer of 1/2 requires us to make an additional (albeit minor) assumption: that a particular attack results in a Crit. The problem, as written, only asks us to consider that we get at least one Crit. If we simply accept this stated fact, without taking it upon ourselves to imagine how that information has been revealed, we get an answer of 1/3 as explained before.

Wednesday, July 11, 2012

The Moving Portal Paradox

Time for a thought experiment.

Many times, while browsing a certain anonymous imageboard, I've come across the following picture. It's been circulating for a while now, and it still starts a violent debate every time it's posted.

(I hope the artist will forgive me for using it here without permission, but the artist is unknown and probably posted this anonymously. You can't seriously expect me to track down the creator of an image which likely originated on the aforementioned imageboard where almost everyone is nameless and every post is deleted within hours. Besides, I'm claiming fair use, for all the obvious reasons.)

If you've ever played Portal, you probably have some idea of what's going on here. (If you haven't played Portal, you messed up, because it's fun and was given away for free on at least two occasions.) The basic question represented by the image is this: If you have a moving portal (orange) and a stationary portal (blue), and the moving portal engulfs a stationary cube, how does the cube behave when it emerges from the stationary portal? In scenario A, the cube essentially remains stationary as it was before the ordeal. In scenario B, the cube flies out of the blue portal, presumably at the same speed with which the orange portal was moving.

The Official Answer

Which scenario is correct? Neither. It obviously can't happen in real life, and it never actually happens in the game. In fact, portals are not typically allowed to exist on moving surfaces, and the only in-game exceptions are scripted events. (This is most likely because moving portals would cause a lot of weird behavior which the game isn't programmed to handle, the above being just one example.) So if you place a portal on a surface in the game, and then that surface moves, the portal vanishes immediately. But what if we simply lifted the seemingly trivial ban on moving portals and conducted a test within the game? Fortunately for us, some guy with a YouTube account created his own test chamber in Portal 2 to find out:


Technical difficulties! It seems that the rule against moving portals isn't the only thing preventing us from doing an experiment. Here it goes again with a faster moving portal:


Clearly, the very game on which this paradox is based just isn't built to handle such a conundrum. However, this is merely a result of the way the game is programmed. It's not an indication of how hypothetical portals might behave, since there's no apparent reason that the portal surface should actually become "solid" as it does in the video above. In short, we've learned nothing. So let's disregard this unfruitful experiment and move on.

An Attempt to Apply the Laws of Physics

The topic has been discussed a few hundred times with no consensus, but I might as well weigh in. I might even be specially qualified to offer some insight, since I do have... um, well... a degree in physics. Okay, okay, so this doesn't make me an expert in the fictional physics of a video game which regularly breaks the actual laws of physics in hilarious ways, nor does it make me an expert in weird scenarios which break the laws of this game, nor does it mean you'll actually think I'm smart (since I've left out, for the sake of privacy, the name of the university which I attended). But at least, unlike most people on the internet, I actually know what momentum is. (Hint: It's not a synonym for inertia.)

So let's take a look at this mess. Initially, the orange portal is moving with respect to the cube. Equivalently, since motion is relative, we can say that the cube is initially moving with respect to the orange portal. However, the cube is initially stationary with respect to the blue portal and, hence, to the room itself. Got it?

Many people look at this scenario and immediately conclude that, if the cube is initially stationary with respect to the room, it should still be stationary with respect to the room afterwards. You know, conservation of energy and conservation of momentum, right? And no apparent forces are acting on the cube, so if it's stationary then it should remain so, right? So option A must be correct... right?

Is this explanation elegantly simple or just crudely simplistic?

This argument in favor of option A is easy to follow, but what bothers me is the assumption that the laws of physics work, and that they work in this particular way.

The Laws of Physics and Why They Fail

First of all, how should conservation of momentum work when we're dealing with moving portals, or any portals at all? Even when considering "normal" portal scenarios, in which our two portals are stationary with respect to each other and with respect to the room, this fundamental law of physics seems to fail spectacularly. GLaDOS explicitly tells us that "momentum, a function of mass and velocity, is conserved between portals." I wish I could believe her but, in a strict sense, the law of conservation of linear momentum is already broken in Portal for a very simple reason.

It's important to keep in mind that momentum is a vector; it has both magnitude and direction. We know that direction matters because of the way colliding objects behave. A simple example: Imagine two objects of equal mass, each moving at the same speed, but in opposite directions along the same line. When they collide, the sum of their momenta (initially zero due to the rules of vector addition) must remain unchanged. In an elastic collision, for example, they will bounce off each other and move again in opposite directions at the same speed (and the sum of their momenta will again be zero). In an inelastic collision, they will both stop (in which case it's even easier to see why, together, they have zero momentum). Anyone who paid attention in high school physics, however, will know that they cannot just shoot off in random directions independent of each other, even if their speeds remain the same. If the directions are not right, total linear momentum has not been conserved.

When an object passes through stationary portals in the video game, the magnitude of this object's momentum always remains the same (i.e., the speed is unchanged) with respect to its surroundings. That's good. Unfortunately, the direction of the object's momentum always changes, unless the portals lie on parallel planes and face opposite directions (a very special case). This change in direction is, in fact, a change in momentum, and there is no apparent collision which causes the momentum of another object to change in a reciprocal manner, so conservation is violated. It should be clear now that we cannot blindly apply this particular law of physics to any portal-related problem... at least, not in the most intuitive way. (At least GLaDOS got one thing right: "In layman's terms: speedy thing goes in, speedy thing comes out.")

So the law of conservation of linear momentum is out. But can we at least assume that some of Newton's laws are satisfied? Going back to our original thought experiment, there doesn't seem to be any external force acting on the cube, and therefore its velocity should remain zero, right? After all, according to Newton's first law, an object at rest should remain at rest in the absence of any force.

But Newton also said that an object in motion should keep moving in a straight line until acted upon by some force. We've already seen that an object passing from one portal to another will often see a change in direction, so unless we can identify the force responsible for this, Newton's first law appears to be broken. We encounter a similar problem if we look at the "F=ma" form of Newton's second law. The equation tells us that, if the net force is zero and the cube's mass is nonzero, the cube's acceleration should be zero. However, it appears that the acceleration of a cube passing through portals is never zero unless we've been restricted to that special case of two portals on parallel planes facing opposite directions.

Acceleration is a change in velocity, and velocity (like momentum) is a vector with both magnitude and direction. If a moving object changes its direction, this counts as acceleration, even if the magnitude of the velocity (i.e., the speed) in a given reference frame remains unchanged. Therefore, an object changing direction as a result of passing through portals must have accelerated. According to Newton's second law, this acceleration would suggest the presence of some force. So should we assume that portals can exert a force on objects passing through them and that this force always accelerates an object such that its direction is changed but its speed remains constant? We could, but it's not a very satisfying answer. Since we don't know anything about this made-up force aside from the fact that one interpretation of our thought experiment suggests that such a force might be convenient, it doesn't really help us solve the problem in a meaningful way. Rather than making more assumptions to justify things that don't quite fit, we should be throwing out the dubious assumption that Newton's first and second laws are applicable to any problem involving portals in the first place.

Finally, what of conservation of energy? Does this law really apply in such a totally nonsensical and impossible scenario? You'd have a hard time arguing that it does because, once again, the law doesn't seem to apply to portals in general (let alone our weird moving portal problem). Any two portals at differing heights will essentially cause a change in the gravitational potential energy of a transported object without a corresponding change in kinetic energy (or any other energy we can see). Furthermore, if you place one portal directly above another, an object falling out of one and into the other will gain greater and greater kinetic energy with each pass, and the only thing that will stop this never-ending increase in kinetic energy is air resistance. Energy comes from nowhere, and this isn't something that happens when energy is being conserved.

Again, you could always assume that the portals are allowed to add or subtract exactly the appropriate amount of energy to account for this, perhaps drawing from a near-infinite and invisible source, but to allow such an assumption would be to throw all systematic and logical approaches to the problem out the window. It's a cop out, and it doesn't provide us with a means by which to proceed with this thought experiment. We might as well assume that portals are made of cheese and that they're powered by the souls of orphans. Instead of resorting to magical explanations, it's a lot easier to make no assumptions at all and simply concede that conservation of energy is a concept better left in the real world.

To make a long story short, the commonly cited laws of physics don't seem to be applicable to portals, regardless of whether the portals are moving or stationary. If they do apply, they don't seem to work in the most obvious way. So how do we even begin to make any sense out of the weird moving-portal example in question? Well, I have my own idea; you don't have to agree with it.

A New Frame of Reference

What I want to point out first is that a change in direction as seen by an outside observer is not actually a change in direction as experienced by the object which moves through a pair of portals. After all that fuss about how changes in direction are so important, it probably looks like I'm contradicting myself a little bit, but hear me out. First consider the regular portal scenario with two stationary portals.

Think about what you see if you look directly into a portal as an object passes through it. Since light passes through portals the same way as everything else does, you can easily see that the object appears to move in a straight line! Anyone who played the game should be familiar with this. Furthermore, if you jump into one of the portals yourself, there's no immediate indication, in this first-person perspective, that a change in direction has occurred, even though a third-person observer would disagree. To the portal traveler, it's just like going through a doorway. A person passing through portals would probably not "feel" a change in direction, or any kind of acceleration, even though acceleration due to a directional change technically has occurred.

So perhaps we can say that the direction of an object's velocity remains constant with respect to the portal system reference frame. To make this claim, we have to take the portal concept seriously and invent a new frame of reference and coordinate system in which both portals occupy the same space at all times. It's goofy, but it seems to work... and by "seems to work" I mean it's the only way our portal system can truly conserve momentum, magnitude and direction included. We can see clearly in the game that if an object enters one portal at a certain angle, it actually emerges from the other portal at the same angle, but only if each angle is measured relative to each respective portal.

In other words, if you go straight into one portal, you come straight out of the other; if you hit one portal at a 73° angle, you come out of the other portal at a 73° angle. Your journey through the portal system might have changed your course from, say, west to north, but if we stop trying to measure all of our angles relative to some universal coordinate system (e.g., the room) and just measure from the surface of the nearest portal, the troublesome change in direction is suddenly less troublesome. Mathematically, it's no longer there. So maybe GLaDOS was right after all; maybe we just need to ignore the outside observer and trust the portal traveler instead.

Now let's go back to the moving portal example. Things make a bit more sense when we use this new frame of reference and measure everything with respect to the nearest portal. If the direction of a moving object with respect to this "portal system reference frame" remains unchanged as the object passes through (and we can see that this is the case), it's not so crazy to say that the speed of the object, with respect to the nearest portal, might remain the same as well. Maybe both the direction and magnitude of an object's velocity should remain constant, but only with respect to the "portal system reference frame" and not with respect to anything else.

In other words, it's like this: Before the object enters portal one, your frame of reference is portal one; after the object exits portal two, your frame of reference is portal two. If you take measurements this way, the "before" and "after" measurements should match up. This model is, in fact, consistent with everything that occurs in the game, so it seems natural to extend it to this though experiment as well. If we accept that two portals at different locations can be used to change the location of an object, and if we accept that two portals facing different directions can be used to change the direction of a moving object, it's not such a huge leap to conclude that two portals at different speeds might be used to change change the speed of an object — all of these changes being relative to the room, of course. With respect to the "portal system reference frame" there would be no changes at all; an object's momentum would be conserved, in both magnitude and direction, in any scenario.

In the moving portal thought experiment, we know that the cube is initially moving at great speed with respect to the orange portal as it enters that same portal, so it should be moving at the same great speed with respect to the blue portal as it emerges. If that's the case, option B is correct. This is the best solution I can find, since considering the entire problem from the reference frame of the room just doesn't work properly regardless of whether one portal is moving or not, as explained at length in the previous section.

A Comparison of Both Solutions

It's difficult, however, to come up with a "right" answer, since both solutions are both physically impossible and yet rather consistent with the very limited examples shown in the game. This is because, outside of some scripted situations, the portals in the game never move. Everywhere in Portal and Portal 2, we observe the following:
  1. An object passing through portals maintains the magnitude (but not direction) of its momentum with respect to the surroundings (consistent with option A).
  2. An object passing through portals maintains the magnitude and direction of its momentum with respect to the "portal system reference frame" as defined in the previous section (consistent with option B).
If we demand that an outside observer witness no acceleration of the cube, we might conclude that option A is correct (i.e., that the cube remains stationary with respect to its surroundings). This solution is pretty straight-forward, and there's not much else to be said. It seems to work. However, if we disregard the outside observer (as we must do when strictly applying conservation of momentum to the regular "stationary portal" scenario) and instead demand that the cube itself not "feel" any change in velocity — or if we simply take measurements relative to our so-called "portal system reference fame" — things are much different, and option B looks more attractive.

Let's look at the process one step at a time. Initially, the orange portal is moving with respect to the cube; equivalently, the cube is moving with respect to the orange portal. Let's first use the reference frame in which the orange portal is stationary. Now we have the cube entering the orange portal at a certain speed and at a certain angle. In other words, it has some velocity. If the cube is to experience no change in velocity, it should maintain its speed and direction... but with respect to what frame of reference? In real physics, we must stay in one reference frame throughout the problem, so we would say that the cube maintains its velocity with respect to the moving "orange portal" frame; equivalently, we would say that it remains stationary with respect to the room. Option A seems correct here.

Admittedly, in order to get option B to work — so that the cube first moves with some velocity relative to orange portal and then moves with that same velocity relative to the blue portal upon emerging — we technically need to switch reference frames at the moment the cube passes through. This is because, in the moving portal scenario, the orange and blue portals are not in the same frame of reference... at least, not according to the traditional idea of what a "frame of reference" is. The "portal system reference frame" solution described in the previous section bends the rules, ignores the outside observer, and pretends these two portals are in the same reference frame and coordinate system anyway. Is that really okay? That's a matter of opinion. I say yes, since the portals should, at all times, connect two points in space as if they were the same point, regardless of the relative speed and direction of the two portals.

Of course, this is all just an attempt to extend the fictional rules for mutually stationary portals in order to come up with some more fictional rules for two portals moving with respect to each other. It's not real physics; an outside observer with knowledge of physics would immediately say we broke the actual rules by switching reference frames and rotating our coordinate system in mid-solution, all while keeping the velocity constant, but such an absurd move seems necessary in any portal scenario... at least, the coordinate system rotation certainly is, as I've already explained.

Other Approaches

A popular rebuttal to any argument in favor of option B uses a rather troublesome analogy. "If you drop a hula hoop on a cube, the cube will not fly up in the air," they say. "It will remain stationary." The reasoning here is that passing through the portals, as they connect two points in space, is kind of like passing through a hula hoop (or some other hole, like a doorway or a window). Unfortunately, the hula hoop analogy as applied to this special scenario is completely fallacious. The two portals are moving at a high velocity with respect to each other, while the "entrance" and "exit" sides of the hula hoop are always stationary with respect to each other. The hula hoop is a neat analogy for stationary portals, but as applied here it fails to account for the very thing that defines this whole thought experiment. Even after carefully considering the hula hoop solution, I think B makes a lot more sense.

More generally, most arguments in favor of option A appeal to logic that just doesn't work here. (This isn't a high school physics class and you can't just parrot some rule and assume it applies to every scenario, real or fictional, without thinking.) If two portals connect two points in space and make them one, then this moving-portal scenario has a single point in space moving at two speeds simultaneously, and the implications are pretty wacky. On one hand, the cube is initially stationary with respect to the blue portal. On the other hand, it's initially moving with respect to the orange portal, and the orange portal occupies the same space as the blue portal, so the cube is initially moving with respect to the blue portal. Which fact do we trust? Since the cube is going through the portal system, we have to measure things through the portals and not across the room.

If you don't trust any of this, or if I've lost you completely, there are some other ways of looking at this problem. Imagine that you're looking straight into the blue portal as the orange portal falls on the cube. Remember that the portal is like a window. What do you see? Obviously, you should see the cube (and the platform on which it rests) rapidly approaching from the other side of this window. When the plate with the orange portal slams into the cube's platform, what you see is the platform coming abruptly to a stop as it reaches the window. Which solution you choose now depends on whether you think this cube was actually coming at you from the other side of the window. If it was, the cube fits through the portal window and should keep going, since it's not glued to the platform and there's no force to slow it down. Therefore, choice B should be correct. If you think the motion you saw was an illusion, you should pick A.

But that motion really can't be an illusion if the cube does ultimately emerge from the blue portal, and this brings me to my next point. The following argument is probably simpler and more elegant than anything above, so if you're not convinced, you will be. Consider the fact that the cube is not being teleported instantaneously from the front of one portal to the front of the other. It enters the orange portal and emerges from the blue portal, and it must do so gradually — that is, one "layer" at a time, but not necessarily slowly. For some amount of time, however brief, the cube will be partially on the orange side and partially on the blue side. When the cube comes out of the blue portal, the top of the cube comes out first, and then the middle, and then the bottom. Super obvious, right?

Well, this means the cube must be moving, with respect to the blue portal, as it emerges. (This is a fact which is not up for debate because we know that it does, in fact, emerge.) More specifically, at this time, the cube is emerging from the blue portal at the same relative speed with which it entered the orange portal. That is, the cube is moving with respect to the blue portal at the very same speed at which the orange portal moves with respect to the cube. In other words, the cube must emerge from the blue portal at exactly the orange portal's falling speed. Consider the implications. If it's moving as it emerges from the blue portal, what could possibly cause it to stop once it has completely emerged? Unless some force acts on it, the cube should continue at the same speed. Therefore, choice B should be correct.

From this perspective, things get weird when you consider what would happen if the orange portal falls just far enough that half of the cube has passed through, and then abruptly stops. Then, relative to its surroundings, half of the cube is still stationary on the orange side (no momentum) while the half of the cube on the blue side must have some momentum because it was just moving out of the blue portal. I suppose that, depending on the strength of the cube, it might either emerge at half the expected speed or simply break in half. But I won't get into that. The scenario in question has been explained; by the time the orange portal slams into the platform and stops moving, the cube should have already passed completely through the portal, and a healthy dose of logical thinking will tell us that it should keep moving... that is, until gravity brings it back down to the floor.