• entries
    32
  • comments
    143
  • views
    30469

SCIENCE (biatch!) for Big Games! (part 2)

Sign in to follow this  

1318 views

(other entries to this series: 1 2 3 4 5 )

The reboot is coming along nicely. What you see in the picture is the basic space full of stars that is now being generated seemingly correctly. I will be porting and improving the code for galaxy formation, superclusters and cosmic filaments in the next few days.

But where is the science?

Before I even started on this project, I did a massive research project to get the overview of how everything (yes, everything) works. I want it to be at the very least based in real science, even if 100% accuracy is impossible on a human-made computer. The research was for a teaching project, but it has infected my mind and transfered over to this project, so let's see what the science behind existence can tell us, shall we? And to start at the root of it all, let's start with...

QUANTUM MECHANICS

Look, I'll be the first to admit that this is a level of detail that miiiiight just be going too far. What game would need to have subatomic particle (or waves, uhhhh) programmed into it?? In truth, my own project is not in dire need of this, and it will be a good while before I even start poking this slumbering beast. But there are aspects of quantum mechanics (or QM, for the pros) which, in the long run, may in fact be worth the effort.

Let's start at the beginning: 13.8 billion years ago, the universe was born into a completely, truly empty void. It started as a tiny, tiny point, smaller than an atom, full of all energy that would ever exist. It was held together by, no kidding, the Superforce. But that broke apart and energy flooded out. The 'pieces' of the Superforce became new forces, first Gravity, then Strong Interaction (SI), and finally Weak Interaction (WI) and Electro-Magnetism (EM). These forces caused the energy to sort of coagulate into lumps that we call particles. Those particles would go on to become everything we know. This initial event is called the Big Bang.

The fact of the matter is, make a program that simulates these particles closely enough, and it will build your universe for you. Problem: It will take every computer that will ever exist to run the simulation this way, and oh, we don't know exactly how these particles behave, we only got about 90% of the puzzle, if even that. One particle was discovered as late as 2012. So we need shortcuts. But even without this magical simulation, understanding these particles is like a physics engine for, well, actual particle physics. This will allow materials and effects to be simulated from scratch, like simulating oceans of unusual chemicals on a distant planet and knowing how they look (including color) and act. It's late-stage concepts, but they can do a lot.

So, in that spirit, here's the Quick'n'Dirty guide to QM:

Gravity: We don't know how it really works. Mass attracts mass, but beyond that, we're lost. The particle discovered in 2012 was the Higgs boson, which is the closest thing we got. It works like people in a crowd: When you want to move in a different direction than the crowd, you need to amke an effort. Except with Higgs, the crowd will follow your lead, once you push through. This is why heavy things are hard to change the course of; turn your car to sharply, and it will tumble in the direction it was going. In other words, momentum. But why things get pulled towards other things with mass, we're not sure yet.

Strong Interaction: Two kinds of particles make up what we call 'matter': Leptons (meaning 'small') and quarks (uhm, a word from the James Joyce poem Finnegan's Wake, for some reason. No kidding). They are very alike, but a small difference makes all the, uhm, difference: Leptons have an electrical charge that we define as "while e's", either 1, 0, or -1 e. Quarks have a fractional charge; 2/3, 1/3, -1/3 or -2/3. Only whole charges can exist, so quarks bond together in more or less stable groups called hadrons (meaning 'big', and yes, that's why that huge thing in Europe is called the Large Hadron Collider, it smashes hadrons together). Groups of 2 hadrons are called mesons ('medium'), groups of 3 are called baryons ('heavy'). The only really stable group we know is 2/3, 2/3 and -1/3. They form the baryon hadron we call a proton ('the first'). Hadrons are held together by tiny particles called gluons ('glue particles', no kidding). In veeery short, gluons pop up and disappear all over the place, all the time. They have an energy called, for no real reason, color. And like aprticles can be 1 or -1, or 2/3 or -2/3, gluons can have the 'color' red, blue or green, or the anti-colors anti-red, anti-blue or anti-green (again, no kidding; science is weird). A gluon always appears with its anti-version, and they destroy each other immediately, unless they swap partners with another color; red and anti-red can swap with green/anti-green, leaving a red/anti-green pair and a green/anti-red pair. When they swap like that, they pull on each other, and quarks have color as well, so gluons can swap with them and pull on them. Get the right gluons and quarks together in one spot, and they will pull on each other enough to stick together. Protons, if you were wondering, have a red, green and blue quark all the time, swapping colors with gluons and each other to maintain that balance. And that, kids, is how babies are made. Because babies are made from atoms, which are made of these particles.

Weak Interaction: A bit easier than SI is WI. Although leptons and quarks are very similar, they act very differently when WI enters the picture. See, particles can be needlessly heavy, lugging around mass/energy they don't need. WI lets them shed that mass/energy (on a QM level, mass and energy are basically the same; heavy stuff has more energy, so to speak). Leptons do it by shooting out a lepton with a charge of 0, a so-called neutrino ('little neutral one', awww); your lepton too fat? Fire off a neutrino, drop the weight, deed done. Quarks have it weirder, though. They fire off a W boson (W for 'weak', and bosons are all particles that help one of these four forces work, like gluons, W bosons, Higgs bosons, and later, photons). W bosons steal the charge from the quark. But a W can only hold a full 1 or -1 charge, so if a 2/3 quark fires of a W+ (W with charge of 1), the quark drops to a charge of -1/3. It becomes a different quark. That matters, a lot!

Electro-Magnetism: Oh boy. This is a big one. It does a looot of stuff, but let's try and keep this as simple as possible. EM works by leptons and quarks (and hence also hadrons, made of quarks) constantly emitting and absorbing bosons called photons. Yes, 'light particles'. When you see light, it's photons hitting something in your eye (a protein, but that's for a later debate). This works by an atom (which is a bunch of protons in the middle with -1 leptons (electrons) zipping around them) constantly trying to pull its electrons closer. The electrons need to drop energy to do that, and they emit photons to get rid of that energy. They can gain energy by absorbing the same energy photons. But they can only emit photons of specific energies, which is why things have color; different energy photons, different color. Things glow when hot because they are emitting photons of high energy, to shed the heat. It's also why glass works like it does: The atoms in glass can't absorb photons we see. But they absorb high-energy photons, like ultraviolet light, which is why you won't get a tan beneath glass (if you could only see ultraviolet colors, glass would look pitch black). But they do other things, too. For one, they create that whole 'electrical charge' thing. No photons, no charge. They also create magnetism (you may have noticed the name), since photons leave ripples behind them as they move, and if you fire a lepton or hadron in some direction, those ripples straighten out like shockwaves behind a supersonic jet. Depending on the charge of the lepton or hadron, those ripples actually have a clockwise or counterclockwise pull (imagine them as circles around the lepton or hadron when you see it coming right at you), and if two sets of ripples line up right (leptons or hadrons going the same way), the ripples will pull together like drops of water merging, and pull leptons and hadrons that follow together, too. Run two naked wires next to each other, and you can see them attract each other. Run the wires (and the leptons that are zooming through, which we call electricity) in a coil and those ripples form a donut shape that is strongest in the middle, and hence pulls stuff in there. Congrats, you got a magnet. So it's electro because electricity is just electrons streaming through something (like a wire. Or you, if you screwed up), and magnetism because the ripples can form magnetic materials. And photons because it's light (photo means light; a photo-graph means a light-drawing). Science!!

So we got that down. What difference does it make, then? Well...

NUCLEAR PHYSICS

Compared to QM, nuclear physics is kind of simple. The atom is made from protons (baryon hadrons of 2/3, 2/3 and -1/3 quarks, equalling 1), usually some neutrons ('neutral ones', made from 2/3, -1/3 and -1/3 quarks, equalling 0), both in the core (a.k.a. the nucleus), and around the nucleus, electrons (leptons with charge -1) fly. Or at tleast they began flying around nuclei (plural of nucleus) about 380,000 years after the Big Bang, when things cooled enough that protons could use their positive charge to catch the negatively charged electrons. See, positive attracts negative in these matters. Positive repels positive, and negative repels negative, but two opposites will attract (neutral does squat). And when things finally cooled enough that protons could catch electrons, all the first atoms formed. That allowed electrons to shed energy and smooch in closer to the protons, creating the first real light. This was a millenia long insane flood of light, so powerful we can still see faint images with the right equipment (including an old radio. A small part of the static you hear in one of those, or see on an old TV screen, is from that faint light). Scientists call it CMBR, Cosmic Microwave Background Radiation. Or 'the baby picture of the universe', because it shows roughly how things looked 13.4 billion years ago.

The first atoms were almost entirely the type with just 1 or 2 protons in the nucleus, because bigger were hard or impossible to form. The positive protons push each other apart, and can only be held together by packing some neutrons in between them (the gluons swap between protons/neutrons and hold them together, but they lack the strength to hold two protons together without neutrons to cling to). That's a pretty big deal, because the first atoms just floated around as thin gases. Gravity slowly bundled them together into clouds, and in the middle of such a cloud, gravity compacted everything harder and harder. In a big enough cloud, the core became so dense that atoms got smooshed together. Two atoms with a single proton each would become a two-proton atom, but that doesn't work, so the energy of pressure and repelling protons supercharged a 2/3 quark in one of them, making it shed a W+ and become a -1/3 quark. That means a proton (a hadron with 2/3, 2/3 and -1/3 quarks) became a neutron (a hadron with 2/3, -1/3 and -1/3 quarks). The proton and neutron did not repel each other, and formed a new nucleus. And more neutrons were made that way, allowing protons to fit in better, and thus, in big clouds of gas, atoms fused into bigger and bigger atoms. This is therefore called fusion. It produces a lot of energy, which causes nearby atoms to also fuse, causing a chain reaction of tremendous energy, which caused the clouds to ignite into the first stars.

Atoms can thus fuse all the way up to 26 protons in a nucleus, which is iron atoms. Heavier atoms are made when a star has only atoms too heavy to fuse more left. Then it dies, and the heat inside it disappears. When something hot goes cold, it shrinks, and when the core of a star shrinks fast, everything collapses violently. In big enough stars, it is so violent that the star explodes. We call that a supernova ('nova' means new, because it looks like a new star in the sky, and 'super' is because it can outshine every other star). In supernovae (plural), the explosion can smash atoms together harder than graivty could, and in a few minutes a billion-years old star can create atoms as big as 92 protons (uranium). Every atom heavier than iron comes from a supernova somewhere.

All this is why some scientists say that "we are all made from stardust". Atoms heavier than one or two protons (hydrogen and helium, respectively) were made in stars, and we are made of those atoms, as is nearly everything around you. And most of the hydrogen and helium atoms still around have existed for all those 13.4 billion years.

But even atoms fall apart, especially big ones. Stars can only make up to 26 proton atoms (iron) because in bigger ones, Strong Interaction (which holds them together with gluons) stars losing the fight with EM (which gives protons the positive charge that makes them repel each other). SI is stronger, but EM has a greater reach, so on the edges of an atom bigger than 26 protons, EM starts pushing too hard, and pieces break off. The typical piece contains two protons and two neutrons, and is called an alpha particle ('alpha' being just 'a' in Greek). Atoms sending out alpha particles are said to produce alpha radiation. But this is when there are too many protons packed in too tight. What if there are too many neutrons? Well, neutrons are not as stable as protons. A free neutron only lasts about 10 minutes before one of its -1/3 quarks sheds a W- boson and becomes a 2/3 quark (-1/3 quarks are just a bit heavier than 2/3 quarks, so it's just trying to shed some weight. We all know that feeling, right?). Protons prevent this from happening, but if there are too many neutrons, one is going to transform. As it does, the W- flies out of the atom, becoming an electron (also -1 charge, remember?). This is a beta particle ('beta' for 'b'), or beta radiation. So a neutron can become a proton and an electron, and protons can get ejected. Big atoms can therefore change their number of protons back and forth wildly. Some do it fast, a million times per second. Others, like uranium (the 92 proton atoms) take about 4.5 billion years for half of them to do it (because it's a matter of chance when an atom 'decays' into another kind of atom by changing its number of protons, you count the time in how long it takes half of them to do it, called the atom's half-life). There is also gamma radiation, which is just insanely high-energy light emitted to shed a lot of energy from an atom. And like fusion, atom decay and its radiation heats stuff around it up. So when atoms decay, they release heat, which is why we use nuclear reactors; we trick big atoms into releasing their energy quicker and drive huge turbines to harness electricity. Incidentally, those turbines create energy by constantly rubbing magnets together to jiggle the electrons inside wires, a reverse of how you made that electro-magnet earlier. So yeah, nuclear power plants are nothing but atoms and QM making electrons wizz through metal wires!

AS FOR THE GAME......

This is enough SCIENCE (biatch) for today. We'll continue on the next entry, but first, how does all this fit into making a game??

We all know physics engines by now. They handle things colliding and falling and flying around and such. Advanced ones even include friction, the amount of movement lost when things scrape along each other. Really advanced ones, usually for lab simulations only, also track heat, which is generated when things smash together or rub on eavh other (clap your hands and then rub them, you'll feel it a little), or can track how things break apart when smashing together, or how explosions tear things apart, etc. And engineers simulate how heat travels through machines and buildings all the time.

QM and nuclear physics are not essential to any game (to my knowledge). But if we are going to do heavy-duty procedural generation (and we are), every kind of procedural simulation is built on rules. And those rules are built on other rules, and so forth. At some point, it can become an advantage to simply define matter according to its smallest components. If a 'chemistry engine' lets us generate chemicals from basic scientific rules (coming up in a later blogpost), what color will those chemicals have? How will they react to heat from light? Will they be radioactive? What if a player creates so much energy from something that it affects matter on the atomic or subatomic level?

None of this is vital to any game I know of. But think about games that have nuclear power plants or fusion engines or particle beams and so on. You can just make up how those things work and put them into the game (which, spoilers, is how it's going to be for quite a while in my project, too). But step by step, you can go into details about how these devices work, so that players can adjust them wildly, change how they are used, or even invent new ones. But to do that, you need some basics about how they work, deep down.

So no, QM and nuclear physics are not a huge priority. However, they give us a foundation for understanding other sciences (coming soon), and when the game gets advanced enough, they provide new ways to give a player creative freedom, for creating or destroying mindbendingly advanced devices. It sometimes helps to be prepared...

Sign in to follow this  


2 Comments


Recommended Comments

I made a galaxy before, but nothing like this!

I'm only in the early stages, but I just got basic galaxies working; check here!

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now