Tuesday, August 24, 2021

Casual games part I: Minesweeper

Hello. Today I would like to post something about my favorite video games than can be found on the Internet.

My first favorite game is Minesweeper. I have been playing Minesweeper since High School. This is when I learnt how to play it quite fast. I am not a master, but I still can play quite fast. You can watch me play on my video channel. Click here to watch one of my videos. 

I like the Minesweeper game so much, that I made a bunch of JavaScript versions of this game and published them on the Internet. My first Minesweeper game was in Polish and Spanish and was unavailable in English. But my second game is available in English and can be found here.

So how my game differs from others? Well, the traditional Minesweeper game is of course a logical puzzle, but also depends a lot on luck, especially while playing on higher difficulties. Every expert player encountered a frustrating situation in which s/he has to pick randomly between two locations of a mine because it is impossible to figure out where the mine actually is using logic alone. This is especially frustrating if you made a considerable effort to solve almost the entire game and the lucky shot must occur at the end of the game. Though, I learnt later, some people actually like this feature. How strange.

Anyway, to get rid of this frustration I decided to add a feature to my Minesweeper games. This feature is called “Pure Logic” or “Pure Intellect.” With this feature on, the game always generates boards that are solvable by logic alone. That is, you will never encounter a situation in which you actually have to guess. To implement it in my code I used an optimized version of the Tank algorithm with some improvements. This algorithm ensures that the games are always solvable. The algorithm is also highly intelligent. I remember being asked if my algorithm is not too stupid. That is, whether it eliminates some configurations of mines which actually can be solved by a genius player but my algorithm is too stupid to figure them out. And the answer is no: my algorithm is ultimately intelligent, because at its core it boils down to checking all possible configurations of mines and eliminating those which yield contradictions.

A huge advantage of having deterministically-solvable (i.e. solvable without need of luck) Minesweeper boards is that with this feature boards can become quite huge. If the luck is involved, for huge boards, you will sooner or later run out of it. In other words, solving a huge Minesweeper board that depends on luck is like rolling dice 10 times and getting 6 every time. In theory possible, but in practice not so much.

And so my Minesweeper Pro game allows for really big boards, and offers two new predetermined difficulty levels. One is Superman with a board of 50 by 50 and 500 mines and the other is Alien (or Extraterrestrial) with a board of 100 by 100 and 2000 mines. Watch videos on my channel to see how I beat both these difficulty levels.

But that’s not all. The size of the board in my second Minesweeper is limited by the number of graphical elements a web browser can display. You can imagine it as a huge table. If the table is 100 by 100 it has 10000 cells. And many browsers cannot support tables much bigger than that. 

To solve this problem, I decided to use different technology and instead of using HTML elements I used Canvas. So, there are no more humongous tables but there is a picture instead. And I just paint over this picture. This is the technology I used to create my Third Minesweeper Game. This allowed me to add a new predetermined difficulty setting: God (or Godlike). God boards are 250 by 250 with 10000 mines. And believe it or not, I actually did solve it. My best time (as of 2021-08-24) with God difficulty is 4 hours 44 minutes and 30.05 seconds. I know there are at least two people who also solved this difficulty level with times 6:08:06 and 6:17:14. And more is coming – the game has not been popular too much yet, because it still does not rank well with Google.

Unfortunately, creating much larger boards or boards with higher mine density is hard. My algorithm is tuned so that it tries to create a board for a predetermined number of milliseconds, and if it fails to do it in the allotted time, it just stops and spits out an error. Larger boards and boards with higher mine density are generally harder to create and take more time. The 250 by 250 monster with 10000 mines is close to the limit, beyond which reliable board generation is no longer possible.

Eventually, I also decided to create my Fourth Minesweeper game. This is just a simple game based on an old engine which is suitable for people who like nostalgia and do not mind having to use luck from time to time.

I hope you will find your favorite Minesweeper game among my creations ;)


Monday, January 15, 2018

Why does entropy increase over time?

In this video I use an example of two mixing gases to explain why entropy increases over time. Entropy is a measure of disorder, and so it is zero when gases are nicely separated and then starts to increase when the gases start to mix. A situation of order – gases nicely sorted into their own chambers – is less probable than a situation of disorder – in which gases are mixed. And so, as the system evolves, a situation in which entropy is higher is more likely than a situation in which entropy is lower. This is why entropy has to increase. Entropy can also decrease, if accidentally the gas gets unmixed. But because order is less likely than disorder, a decrease in entropy is less likely than its increase.

To sum up, entropy is defined as a measure of disorder, which is often high and rarely low. And so, by definition, entropy is likely to increase and unlikely to decrease. There is no deep physics here. Just clever definitions.


Monday, January 8, 2018

Why does atmospheric pressure decrease with altitude?

In this video, I show how a gas - a bunch of particles bouncing in a chamber - forms a density gradient if there is a force pulling them in one direction. The force is to the right but you should have no problems imagining that it points downwards. There is no voice-over – the animation seems sufficiently self-explanatory.


Saturday, December 2, 2017

What happens when a gravitational wave passes by?

In this video I explain what exactly happens to the geometry of space when a gravitational wave passes by. I haven't seen many videos doing that (actually none). Most of them just say that a gravitational wave squeezes and stretches things but do not explain what does it actually mean. Or, they they show a nice animation of spreading waves, usually on a two-dimensional surface, which is very nice but does not have much to do with gravitational waves.

I do not discuss other details, like the sources of gravitational waves, their strength, recent discoveries, etc. because those topics seem to be discussed aplenty.

So, if you wandered, what gravitational waves were about, here you go:


Tuesday, November 14, 2017

General Relativity: curved spacetime and how gravity works

Here is yet another video. This time it is inspired by the question "why things fall?"

I have noticed that most of videos explaining general relativity make a mistake of showing how to visualize curved space and then claiming that this somehow explains how gravity works. Some (better) videos explain that gravitational attraction is mostly due to time slowing down closer to a massive object. But none seem to explain why and how variation in speed of time explains the downward movement. Until today. There you go:




Monday, May 8, 2017

Special relativity: time dilation, relativity of simultaneity, and length contraction

I have recently learnt Special Relativity and in the process of doing so I have noticed that the explanations of it available on YouTube are somehow lacking. Here are the features of my explanation which I have not seen in the videos produced so far:

1. Why squeezing object in one way is good but in another way is bad? Most explanations of time dilation using a mirror in a train tell the viewer that in order to keep the speed of time constant a clock on a moving train must tick slower. But nobody mentions that the speed of light can be also kept constant by squeezing the train. And since we have length contraction why should we ignore the possibility of width contraction? Therefore, I decided to discuss the possibility of width contraction and explain why it must be discarded.

2. Some people confuse the idea of “what actually happens” with “what appears to happen” and think that time dilation is some sort of optical illusion. To make sure that they do not have this impression after watching my video, I present them with a hypothetical experiment illustrating what it means that the time moves slower for a moving observer.

3. Relativity of simultaneity is rarely discussed and when it is discussed, the presentation is done poorly. Most explanations present results but do not present the logic and are often of the type: “for this person they are simultaneous, for the other they are not, deal with it!” This does not give viewer a chance to understand why exactly the concept of simultaneity fails. Instead, I came up with a thought experiment with two moving trains and firecrackers to illustrate the logic. I hope that after watching my video a diligent viewer will be able to answer a question: “WHY simultaneity is relative?

4. Virtually no video discusses length contraction. As with relativity of simultaneity, a person trying to understand “why there is length contraction?” will have hard time finding satisfactory answer in the existing non-scientific video material. I try to fill this gap. My experiment with two trains and firecrackers, once the relativity of simultaneity is established, very nicely demonstrates the logic of why must it be that there is length contraction.

5. I also try to explain why, as the speed of the object approaches the speed of light, the length of the object and the speed of time for it both decrease to zero. This point is often skipped in the currently available videos.

6. Finally, I decided not to use any equations in my explanations (ok, I use one equation “SPEED = DISTANCE / TIME” but it is not essential for the presentation) and I decided not to use specialist phrases like “frame of reference” which may confuse people who do not study physics. My explanations are designed in such a way so that they can be used in a discussion at a cocktail party. Indeed, I have tried these explanations in a social setting before making this video and they seemed successful. As my lab rats I used people who are not versed in physics or mathematics but are generally intelligent.