What this is about
How do you store a hillside? The obvious way is a picture, a grid of heights. A bigger area needs a bigger picture. A finer detail needs a finer grid.
There is another way: do not store the ground at all. Store a rule that says how high the ground is at any point. You give the rule a place and it gives you a height. This article explains that idea and what we had to check before we trusted it.
Why it matters
A stored picture of the ground costs memory in proportion to its size. A rule costs the same however big the world is. For us, the ground is under a simulated fly, and in some tests under 65,536 of them. The rule saves memory, and it also guarantees that everything that looks at the ground sees the same ground.
This is the opposite of an AI picture, which is a guess. A formula is exact, and everyone who asks the same question gets the same answer.
How it works
Think of how a game like Minecraft works. It does not store its mountains. It stores a seed and works out the height at a spot when someone looks.
We took the idea a step further:
16 numbers -> height and slope at any x, y -> physics (where the feet touch)
-> renderer (what the camera sees)
The height is a gentle slope plus a few layers of bumps, from broad hills down to fine texture. Both the physics engine and the renderer compute the height from the same 16 numbers, so there is one ground.
What it saves:
- The formula fits in 64 bytes. The table of heights it replaced took 256,000 bytes.
- Sixty-five thousand animals scattered over a kilometer cost no more memory for the ground than one.
- Looking up the ground costs less than 0.3 percent of a physics step at 65,536 animals.
Landmarks come from the same trick. Each 40-millimeter square of ground gets at most one cone, 10 millimeters wide and 40 tall, decided by hashing the address of the square with the seed. A hash is a way to turn a number into a scrambled but repeatable one. So the cones are part of the formula, not extra data.
What we had to check
A neat idea is not a working one. This is how we checked.
A referee. We wrote a second copy of the formula in Python and compared it against the GPU version at 100,000 random points. The height agreed to 5e-08 and the slope to 6e-08, which is rounding noise. We also planted a bug, a changed constant in the hash that makes the noise, and the check failed as it should. A check that cannot fail is not a check.
The feet. The physics engine treats the ground under each foot as a flat plane tilted to match the slope. On a straight ramp that is exact, and we tested it against MuJoCo's own tilted plane at the 1e-05 bar. On bumps it is a different method from MuJoCo's own heightfield contact. We measured the difference but did not make it a gate.
One ramp state failed at 2.4e-04. It was not a real fault: that contact sat within rounding of the point where it switches on. We exempt a state only when it fails and sits at such an edge, count each exemption, and fail the gate if more than 10 percent are exempted.
A warning about the usual tool. MuJoCo's own heightfield, sampled for starting states, pushed the fly's thin feet through the ground: the root at 2.05 mm and the feet 0.81 mm below the surface. So we did not trust it for start poses.
Does the fly stand? The fly stands on bumps 0.1 mm high with an 8 mm wavelength, and collapses onto its belly at 0.3 mm. That one sentence took three attempts. The first test compared the body's up direction with vertical, and it failed the fly standing on flat ground, because the thorax is naturally pitched. The second used root height, and a fly lying on its belly on bumps sat inside the band. The third used "motors off" as the limp case, and that fly stood anyway.
What fixed it was a rule: every gate runs a positive control that must pass (flat ground) and a negative control that must provably fail (an upside-down start). Then you pick the measure from the values of both.
Where a formula falls short
- It is only as rich as the rule. Our ground is slope plus layers of bumps. It will not give you a river valley or a cliff.
- It has no authors. A formula cannot place a path or a building on purpose.
- It needs the physics engine to agree with it. That is why we checked the feet.
For the fly project itself, see our repository github.com/amarbarosys/fly-connectome. The full post is The whole ground is a formula.
The textures are another story
A flat color picture can also be seamless and repeating, as in Textures that repeat without seams. That is a stored picture made to tile. The ground in this article is a rule. Both avoid a visible repeat, in different ways.
Words you may meet
- Procedural: made by a rule, not stored.
- Heightfield: a grid of heights.
- Seed: a number that fixes which random pattern the rule makes.
- Hash: a repeatable scramble of a number.
- Slope: how steep the ground is at a point.
- Control: a case where you know the answer, used to test a check.
Try it
- Draw a line of hills on paper using only two rules: a gentle tilt and a few repeated bumps of different sizes. That is the idea.
- Browse the fly project at github.com/amarbarosys/fly-connectome.
- For worlds in a browser, walk through aiazic.com.
What we do not claim
We tested standing on bumps up to 0.3 mm in this simulation. We did not test slopes or surfaces beyond those, and we did not make the bump-contact difference from MuJoCo a gate.

Kommentare
Noch keine Kommentare.
Anmelden um zu kommentieren.