What this is about
In our street game, every rule of the city is a value in a settings file. How fast hunger falls, what bread costs, how likely a witness is to report a crime, how big the map is: all of them are values you can change. This article explains why we did it that way and what it buys us.
It is the plain version of an idea that runs through the whole project. You need no programming to follow it.
Why it matters
When a game's rules live inside its code, changing a rule means changing the program, building it again and testing it all over. That is slow, and it makes people careful in the wrong way. They stop trying things.
When the rules live in a menu, trying a change takes seconds. You edit a value, reload and look. A tester can make the world harsher or kinder without asking a developer. A server owner can run a different game from the same program.
For us it also makes testing honest. If a number is in one place, you can say exactly which number a test used. If numbers hide in the code, you never know which ones mattered.
The idea in three layers
settings file -> game code reads it -> the city you see
(numbers) (no numbers inside) (speed, prices, size)
- A settings file holds the numbers. Drain rates, prices, crime odds, police response, turf rules and difficulty are all there.
- The code reads the file. It never contains the number itself.
- Presets bundle values. One config file holds named presets, for example
groundedandharsh. An admin command reloads it while the server runs.
Anyone can run the headless server with their own settings file.
The size of the city is a setting too
Here is the clearest example. Our city began as one short hand-made street. It started the server in 0.47 seconds and used 127 MB of memory. Then we built a generator, called citygen. It is seeded, which means the same number always makes the same city. The seed travels to every player's computer before the city builds, so everyone sees the same map.
Later seeds used a richer layout: a river, 7 to 12 neighborhood frames, bridges on the main roads and quays along the water.
Building a city costs time on every start, so we bake maps. A baked map is a city built ahead of time and saved. That also lets the game load the world in chunks and blend far buildings with fog.
Baking changed memory a lot. For the 2 km map, server memory went like this:
| Step | Server memory |
|---|---|
| Bake at 1 km, load everything | 276 MB |
| Load in chunks, far layer for clients | 176 MB |
| Server areas, spawn by chunk | 128 MB |
| Grow to 2 km | 136 MB |
The big drop came from loading the map in chunks instead of all at once. The 2 km map ended up using less memory than the 1 km map had at the start.
Then players said it felt too big and too empty. So we made the size a menu choice. The game now has four baked maps: small at 560 m, medium at 800 m, large at 1 km and huge at 2 km. Medium is the default on the menu. The chosen value crosses the network as the seed. One loose end: the older "huge" map is still the default for headless and command-line starts.
Consequences are settings too
The same idea helped us teach characters to refuse a threat. The price of each answer is a setting, all zero by default. The preset called hybrid sets refusing an armed player at 6 health and complying at 200 cents or 2 need. With the numbers in a menu, we could change what complying cost and watch a character switch to refusing. That test would have been hard if the cost was buried in code. We tell that in How a game character learns to say no.
How we keep the rule from rotting
A rule like "no bare numbers" breaks the first time somebody is in a hurry. So a script enforces it. We call it the literal gate. It scans the game files for numbers written straight into code and fails the whole check if it finds one.
This also guards against a quiet failure. A hardcoded number looks harmless until you want to change it and cannot find it. A gate that fails the build turns a future headache into a present, small one.
We pair that with another habit. Each step in the project's plan closes only after five full checks in a row pass on the same version. The test suite runs in about 24 seconds. Quick checks and a settings menu fit together: the quicker the check, the more often people try a change.
What the menu cannot do
Honesty requires a few limits.
- A setting does not make a good number. The menu lets you change a value. It does not tell you which value is right.
- Settings can hide a loose end. The older "huge" map is still the default for some starts, and it took us a while to see that.
- Not everything is measured yet. A 400 m teleport stalled the game for about 480 ms before our texture work and about 690 ms after. Our report says it was not fixed. Adding test bots made physics update spikes jump from 25 ms to 78 ms when entering new chunks, and the cause is a guess.
Glossary
- Setting: a value in a file that can be changed without touching the code.
- Preset: a named bundle of settings.
- Seed: a number that fixes a random process, so the same seed always builds the same city.
- Baked map: a city built ahead of time and saved to disk.
- Chunk: a small piece of the map, loaded only when needed.
- Headless server: a game server that runs with no screen.
- Gate: a script that fails the build when a rule is broken.
Try it
- The full story of the city is in A city that fits on a menu, and the first article of the series shows the settings rule in A street game where every number is a setting. Dogs, cars and the open work list are in Dogs, clothes, cars and what is next.
- To see a 3D place in a browser tab, open aiazic.com. It is a separate project from the street game, and it needs JavaScript and WebGL. Walk around and notice how much of what you see could be a setting: the light, the room sizes, the speed you move at.
- Exercise: pick any app you use. Write down three numbers you wish you could change. If the app has no menu for them, the numbers are hardcoded.
Previous in Street Simulator Progress: How a game character learns to say no.

Commenti
Ancora nessun commento.
Accedi per commentare.