Checking how many agents are working

How this works
Contatti
← Blog
A plain steel clockwork mechanism beside a tangled bundle of fine brass wires on a dark bench, the clockwork ticking neatly in warm amber light, in teal and steel with a warm amber rim light, the AMARBARO mark and wordmark centered over it.
✎post del blog

Why a simple script still beats our learning NPC

The short version

The hand-written script still beats our learning NPC brain, 0.631 to 0.530 in a calm world, and seven extra ideas did not close the gap.

What this is about

We built a learning brain for game characters, and we keep testing it against the plain script it was copied from. The script still wins. In a calm world, the script scores 0.631 and our best brain scores 0.530, on a scale where 1 is perfect. We then added more and more clever machinery, and most of it did not help.

This article explains why a simple script is hard to beat, what it does well, and what each of our extra ideas taught us. It is a story about losing honestly.

Why it matters

There is a common belief that a learning system must beat a hand-written one. It does not, and it does not have to. A hand-written script holds the knowledge of its designer. It eats when it is hungry, works when work is due and talks when it is time. A learning brain has to find all that out for itself, in a short life.

If you build anything with learning inside, it helps to know where the script is strong. Then you can decide where learning should step in, and where it should stay out of the way.

What the script does well

We score a basic reflex by how often a character takes the right action when its need calls for it. Here are the numbers.

Reflex Script Our evolved brain
Eating when hungry 0.97 0.52
Working when work is due 0.96 0.24
Talking when it is time 0.98 0.29

So the script gets the basics right almost every time. The brain does not yet reliably eat when it is hungry, or work when the work is due. These are exactly the moves where a clever brain has the least to gain.

Remember the setup, too. Both the script and the brain see only what is in front of them, through eight rays. The script uses the same rays. The brain gets no map and no arrow to the nearest food.

The extra ideas, one by one

After the first results, we tried many things to close the gap. We list them here as a set of short stories, each with its number.

  1. Foresight. A learner can credit an action with what it leads to later, not only with the reward it gets right away. This is a standard method from reinforcement learning. It scored 0.456, and the plain one-step rule scored 0.516. Looking further ahead made it worse at every distance we tried. Our guess is that the part that estimates how good each state is was too simple, but we have not tested that.
  2. Growing wiring. Each character could grow and prune connections, as quiet cells grow links and busy ones lose them. The growing arm scored 0.4855 and the control with random partners scored 0.4869. A tie.
  3. A spoken vocabulary. A third output could say one of 12 easy words, such as food, work, danger, yes, no and help. The words carried almost no information: 0.003 bits where our bar was 0.1. The talkers scored 0.5125, and the silent ones 0.5182. Our explanation is that a bare word like "danger" says nothing about what to do.
  4. More inputs. A direct path from the 64 observations to the output scored 0.4512 against 0.4816 without it. More input made the learning rule noisier.
  5. A different reward. Rewarding the drop in a combined drive scored 0.4850 against 0.4900, and every character converged on its worst need, so the variety between characters fell by about three times.
  6. Surprise-gated learning. Learn only when something surprises you. It scored 0.511 against 0.529 for the instinct. The test was also invalid by design, because all the arms shared one random stream, so we say only that we do not know.
  7. A slime-mould trail map. The map had 106 edges, but at the start of a life only 9 of 100 characters stood on a trail. It beat its control in 4 of 10 seeds, against a bar of 7 of 10.

None of those closed the gap.

What did help

Two things moved the numbers, and both were plain.

  • Evolving the output layer of the brain. This took the brain from 0.419, when it was only copied from the script, to 0.530. That was the largest gain in our calm-world tables.
  • Learning, but only after a change. In a calm world, learning on top of the evolved instinct cost about 0.01. After a shift, when we made one habit start to hurt, the learners recovered about 0.10 more than the instinct did. We cover that in In-life learning wins back about 0.10, but only after a shift.

The pattern is simple. In a world that does not change, the script is already close to the best answer, and a learner mostly adds noise. In a world that changes in a way nobody planned for, a learner has something to offer.

The game gave nothing to learn from

The biggest reason came from a game log. A character was threatened 31 times, and its need did not move and its health did not change. With no reward, there is nothing for a network to learn. That did more to decide where the network goes than any of the tests above. We tell it in Most of the extra machinery did not help, and the game gave no reward to learn from, and in How a game character learns to say no.

So the game runs a small three-answer bandit, as we explain here, with the script as the fallback. The network waits for a question that needs more than three answers.

What this teaches

  • Write the kill line first. We wrote down when the idea is dead before we ran a test. That is why we can report a loss without an argument.
  • Beat the simple thing, or say you did not. A baseline that is easy to read is a good judge.
  • A learner needs a signal. Check that the game really changes something when the character acts.

Glossary

  • Script: a fixed set of rules that tells a character what to do.
  • Reflex: a basic action taken at the right moment, like eating when hungry.
  • Baseline: the simple method you compare a new one against.
  • Kill line: a rule, written before the test, that says when to stop.
  • Seed: one random start of the same test.
  • Reinforcement learning: learning from rewards after actions.

Try it

  • Read the first article of the series for the full score table: The NPC brain still loses to the script it copied.
  • Visit aiazic.com and watch its robot guide walk a guest to a room. It runs on rules, not learning, and it is a clear picture of a script doing its job well.
  • Exercise: pick a task you do every day, like making tea. Write the five rules of the script. Then think about what a learner would need to see, and for how long, before it could match you.

Previous in NPC-mind: The multi-armed bandit: how a character learns what works.

Commenti

Ancora nessun commento.

Accedi per commentare.