Archive for the ‘Puzzles’ Category

Is This Real Life?

Tuesday, May 3rd, 2016

I watched an extraordinary film recently called Welt am Draht or World On A Wire.

world-on-a-wire-poster-art

It’s a 3.5 hour two-part film made for German TV in 1973. It’s beautifully shot and acted, and one of the more watchable films I’ve seen in a long time. To say I enjoyed it greatly would be an understatement, and I believe I would have done so even if it didn’t have such a remarkable story.

Spoiler alert! I’m going to spoil the film now, so skip to after the next image if you want to watch it without knowing what it is about. Note however that the remainder of this blog will deal with the same issues covered by this remarkable film.

The film is about an IBM-like company (named IKZ) which has created a simulation of reality (Simulacron) which contains 9000 individual simulated humans that are used for consumer trend analysis (such as to determine what fashions may be in vogue years later). One of the programmers kills himself under mysterious circumstances after claiming to have learned a terrible secret, and his replacement (Stiller) finds himself in increasingly bizarre situations as he attempts to determine exactly what led to his predecessors suicide.

The truth is – and here’s the big spoiler – that the world of IKZ is itself a simulation, and none of the inhabitants knows. The dead programmer found out, and in time Stiller finds out himself, and races against time (and the clever and subtle changes being made to the world by whoever is simulating it) to somehow find a reason to keep living now that he knows his life is nothing but data in some computer ‘above’ his reality.

As I said, this film was made in 1973. Even more remarkable was that it was based on a novel from 1964. It’s fantastic: watch it.

ee

Ask yourself: “Am I real, or just a simulation?”

The idea of our reality not being real is hardly new, and for centuries philosophers have debated the nature of reality and whether anything actually exists at all. But in the last few decades the idea that our reality may be a simulation has slowly been gaining some form of credence. This paper in particular, has helped drive the argument. This is not crazy-talk, as recently as a month ago the American Museum of Natural History had a well-attended talk (moderated by Neil deGrasse Tyson) on the topic (only one of the five debaters rejected the possibility).

I’ll skip to the end before I throw out a few considerations: the answer seems to be ‘maybe’. We may one day even be able to prove it is true. In fact it is unlikely – even impossible – that we could ever prove it isn’t true. So we may have to accept the possibility that we are living in a simulation and consider from what effect  – if any – this has on our lives.

screensaver

Bostrom’s argument supposes only one of these is true:
1) No civilization ever becomes able to simulate the universe
2) No civilization that can ever does simulate the universe
3) We are living in a simulation

One of the logical conclusions of his argument is that if we fit into one of the above criteria, that one must be true. Right now we’re in catgeory 1, with neither the ability nor the means to simulate reality. And that’s supposing that reality is even calculable, which is a big unknown due to the probabilistic nature of quantum mechanics and the fact we currently don’t know much about things like gravity, and dark matter (ie. fundamental parts of reality).

But humans are smart, and we learn how to build more powerful computers every year. One day, presumably, we may have the means to simulate ourselves, at which point we’ll enter category 2. When we’re at the point where we can simulate reality, will we? It seems to me this is more a sociological question than a scientific one, but I can’t think of many times in the history of humanity where we’ve developed the ability to do something (non destructive) and not done it. So it is at least likely that we will build the simulation and then turn it on.

At which point we must face the fact that if we can simulate reality perfectly, there is no logical argument against us being simulations ourselves. So if we ever get beyond category 2 and create out own reality sim, we are simultaneously proving that we ourselves are simulated.

There are other possible proofs. One idea is that a 3D reality simulation must have some discrete co-ordinate system (x/y/z) which would have an effect on EM wave transmissions and background cosmic radiation. There are claims that evidence to support this has already been found.

A wilder consideration is that the second law of thermodynamics when applied to the closed system that is our universe suggests that disorder should always be increasing. And yet we live in a universe full of order – in fact we see more order than disorder (ie. atoms are arranged in planets and not distributed randomly throughout the universe). This itself has led to endless philosophy (this will bend your mind) but one theory may be that our simulation has been tweaked to accommodate us in (macroscopic) violation of the second law. In other words the simulation agrees entirely with the laws of physics only as far as it must to allow our universe to exist in the first place.

ferns

Going further down the rabbit-hole, the logical question is ‘how’? How would it ever be possible to build or power a computer able to do this, much less code the simulation itself? We can’t know the answers, and if we are simulated likely never will, but from the point of view of a simulation we may create certainly one must ask “Why simulate everything when you can just do one person?”

Consider that for a moment. Maybe reality is not a simulation. Maybe just you are? Maybe just I am. Maybe none of you exist, and the comments you leave on my blog (or texts you send me) were just generated by a computer to make the world I perceive seem real? Maybe everyone I interact with only exists while I interact with them? It may be that reality isn’t simulated, only my reality is? (You may want to read up on the Bishop George Berkley at this point.)

sg

Which brings me to: If we are simulated, so what? The answer is it doesn’t matter. Assuming the simulators continue to let the simulation play out without interference (or at least tweak the code to hide their interference) then it has no affect on our lives at all. What we don’t – can’t – know won’t hurt us, you could say.

My Dad at this point is thinking another obvious question: who are the simulators? If we are simulations who built the computer and who wrote the code? This is for some an uncomfortable element of the argument, since it blurs the lines between science and faith.

Many years ago in a quantum physics text I read a quote that I will paraphrase here: “Science should be careful of looking too closely else they may find God”. It seems to be this is just as relevant to the simulated reality argument.

(If this topic interests you, you may also want to read about the idea that our universe itself is a computer and another theory explaining the apparent 2nd law violation.)

How Far Can You See In The Woods?

Thursday, March 12th, 2015

This is one I’ve been thinking about for a while: how far can you see in a forest?

pine

I’ve always been intrigued by the effect forests have on our vision. Even in forests where trees are far apart that you can’t touch two at a time, you usually can’t see too far. When Bernard and I went up to the Grand Canyon last year, the forests there are very light on underbrush and the trees have a decent distance between them and you still can’t see much further than a few dozen feet. When I was camping in January and I got up early and saw pademelons everywhere, I couldn’t see them beyond a few meters into the woods.

So I’ve been thinking, is there an equation that governs view distance in a forest? Which naturally led me to try and devise one myself.

newmexico

Once you sit down and think about it, you find it’s a bit of an open-ended problem. So I decided to start by thinking about an easier problem, and then expanding from there. So consider this one:

You stand somewhere on one side of a flat field, and your friend stands somewhere on the other side. The field is full of trees. What is the percent chance you can see your friend?

This is not a brain teaser with an easy answer, and the result will depend on many things:
– Where you stand
– Where your friend stands
– The size of the field
– The number of trees
– The size of the tree trunks

Problems with many unknowns can get difficult to solve quickly, so the first step is to eliminate some. The first two (location of you and your friend) can be expressed as the distance between you and them. The last three (field size, tree count and tree size) can be expressed as a ‘wood density’ (ie. the total cross-sectional area of the trees divided by the area of the field).

I speculate the general solution is some function of the distance between you and them, and the wood density. But how does one calculate the result?

Dense-forest2

As I teach my students, always approach a problem from extremes. The two extremes here are easy:
– If the wood density is zero (there are no trees) the chance you can see your friend is 100%
– If the wood density is 100 (the field is chock-a-block with trees) the chance you can see your friend is 0%

So we expect an answer somewhere between 0 and 100%. This may seem trivial, but there are problems in which the percent range can be much tighter and it’s useful to know we have the full 100%.

But what if there is only one tree? Consider these possibilities:

Screen Shot 2015-03-12 at 9.02.17 AM

On the left you (A) can’t see your friend (B) because a tree is smack in the middle. In the middle you can (the tree doesn’t block your view), but on the right you can’t either because the tree just blocks your view. Any general solution must account for all such possibilities (and an infinite amount more).

So how to calculate a percent chance for one tree? There is no way I can surmise to solve this via a general equation solution, so the required tool is computer simulation, specifically Monte Carlo simulation. In essence: generate a very large amount of ‘maps’ (of you, your friend and one tree) and calculate the percent chance from solving each and adding them.

For instance, if the only possible configurations were those shown above, the chance of seeing your friend would be 33.3% (only one in three maps). Of course there are many, many maps though (as many as you want actually), and it would be impossible to solve them all, so a more rigorous method is needed.

forest

Here’s how I would do it – and I welcome any theorists to give their techniques in the comments. This is (at this point), for one tree only:

1) Randomly generate your position (A) on the edge of the field
2) Randomly generate the position of your friend (B)
3) Determine the vector connecting the two of you (AB)
4) Randomly determine the position of the tree
5) Determine if the vector between A and B is blocked by the tree

This last step is trickier than it sounds, and the easiest way to do it (aside from a clever technique I discuss below*) might be to:
5a) Calculate the vector passing through the center of the tree perpendicular to the vector AB (this just requires some vector algebra)
5b) Calculate the intersection of these two vectors (more vector algebra)
5c) Calculate the distance between the point of intersection and the center of the tree (easy)
5d) If this distance is less than the tree radius, line-of-sight is blocked

The simulation would repeat the above steps many (n) times, incrementing a counter (p) by 1 every time you could see your friend. The final result would simply be (p/n)*100%

I imagine with only one tree the percent chance would be very high. But what about many trees?

Screen Shot 2015-03-12 at 9.20.19 AM

That’s only 3 possible examples (from a pool of infinity) of five trees (well, six on the left!). You can see how much more complex the problem seems to become.

Interesting though, the simulation wouldn’t change much. The only difference would be to step 4 above, which would become:
4) Randomly populate the field with trees, saving their positions in an array

And then step 5 would be repeated for every tree. You wouldn’t have to test every single tree against line-of-sight for each AB vector, you could just stop when one blocked the view.

With this modified algorithm, I’d save (into my output file) the following:
1) Position of you (A)
2) Position of friend (B)
3) Size of field
4) # of trees
5) % chance of seeing friend (output of simulation)

Tests would have to be run to find out how many times the simulation needed to be ran. One thing I learned writing my simulation for my PhD was how few runs were actually necessary. My code would have happily ran all day long simulating billions of photos (each of which required hundreds of calculations) but in the end I stopped at only 1000. I found that the variability of the results for photon counts above 1000 was essentially 0, so there was no need to run more. It would be interesting to do the above coding and plot the results vs ‘maps’ ran and see where the plot gets flat. I bet it’s lower than we’d expect.

Once the basic simulation was in place, modifications I would add include:
– Variable tree size. The wood density would decide the total cross-sectional area of trees, and you could rather easily vary the radius per tree and keep track of total area so as not to exceed the desired density
– Foliage. Trees (bushes) could have a ‘transmission ratio’, possibly linked to a secondary radius (to discriminate between trunk and leaves). So line of sight could be half-blocked for instance if you were viewing your friend through leaves (as opposed to blocked by a trunk)
– Variable field size. The field is nothing more than a construct to give some constraint to the problem. It would be trivial to instead solve the following: You and your friend stand in a forest full of trees. What is the percent chance you can see your friend?

I strongly suspect the results would show a strong proportionality between the magnitude of AB, the wood density and the chance of seeing your friend, and it’s likely an equation could be fitted to allow for a general solution.  It’s tempting to suppose the trivial result would simply equal wood density (ie 50% trees = 50% chance), but my gut tells me it isn’t that simple.

denseforest

One interesting consideration is the dimension of the field, and how it may affect results. I have mostly ignored it here, but it may be worth considering. Consider the following examples:

Screen Shot 2015-03-12 at 9.41.13 AM

Each permutation has 6 trees, but the first two have very narrow fields, both of which will lead to very low chances to see your friend (for random A, B positions). It’s true that the ‘wood density’ varies strongly between the first two the one on the right, and I wonder if that will be enough to correlate the results. In other words, can the exact field dimensions actually be ignored?

wood2

So lets return to the general problem, and what has caused me to think about all this: How far can you see in the woods?

It’s a much more interesting problem to imagine, but I think I may save it for another post  🙂

About that clever technique: It occurs to me a completely different way of solving this would be to do it graphically and exploit hardware graphics techniques. For instance, make the trees sprites and draw a vector between A and B and see if there is a collision with a tree. Do this enough times and save the results. The resolution (and I don’t mean computer screen resolution) would be necessarilly less, but maybe this technique – which saves a lot of coding and vector algrebra calculations – could work?

Master Of Puzzles

Thursday, May 8th, 2014

It’s time I revealed another of my secret skills: Puzzle Master!

But I’m not one of those half-men that only solves puzzles. No my friends, I have now become adept at creating puzzles.  My brain-twisters will be a challenge for all non-genii, and should provide endless hours of entertainment to those that cannot count themselves among the hallowed brethren of the puzzle savants.

Curious to test and see where you rank in the world of puzzlers? Try this one first (you can print the full-sized version):

secret

Good luck working out what that is without finishing it!

But of course I know there are some real smart alecks reading this blog, and I’m sure one or two of you may even be able to finish the above without more than 3 or 4 mistakes. Lest your heads swell, I’ve decided to present you with another of my creations to show you just how lofty the halls of the Gods Of Puzzling are…

And so! One of my greatest creations: a ‘god tier‘ difficulty (and quite positively Laytonesque) Picross for you to solve:

mystery picross

Print it and solve it! Send me a photo of the completed puzzle for a mystery prize! (If you don’t know how to solve Picross puzzles, read this)

Good luck 🙂