Rib IT Ltd
Evolved Frogs · Research preview · Technical white paper

Teaching frogs to hop without telling them how

Abstract

We evolved the 726 weights of a small neural network that drives a two-dimensional physics frog, using a genetic algorithm with a population of 200 and no gradients, demonstrations or hand-written gait. The only teacher is the score, and the frogs gamed each score we gave them. Scoring distance alone bred divers: by generation 29 the champion covered 14.8 m and crashed 2.88 s in, and 99–100% of the population fell in every generation. Scaling distance by the time spent upright stopped the dive within about 10 generations. We originally reported that the survivors then scooted on their stiff front leg. That was wrong. Measured second by second, they lunged 7–9 m in the first 2–3 s and then stood still, which the survival-scaled score rewards. A follow-up that scored only airborne distance (E4) showed the same freeze.

Adding a stall rule, which ends the episode if the frog moves less than 0.5 m forward in 2 s, took away the reward for standing still. In a 300-generation run (E5) a continuous hop emerged. The shipped champion, generation 298, was selected on 10 validation courses (validation 24.12, holdout 23.04). On the flat showcase course it covers 26.1 m in 10 s at about 2.5 m/s, airborne about 35% of the time, and it stayed upright for all 10 s on that course and on all five holdout courses. The winner's curse remains: over the last 50 generations the champion's holdout score ranged from 11.66 to 23.97. Every experiment is a single run with one seed.

1. Results at a glance

Distances are for the frog's torso over one 10-second episode. Scores depend on the scoring rule in force, so scores from different experiments are not comparable; distances and airborne fractions are.

QuestionAnswerEvidence§
Does scoring distance alone produce hopping?No. It produces divers.Generation 29 champion: 14.8 m, fell after 2.88 s. 99–100% of the population fell in every generation.5
Which fix for falling works better?Scaling by survival (A)Both cures stopped the dive within about 10 generations; A gave a smoother signal than a flat 10-point penalty (B).6
Do the survivors hop?No. They lunge, then stand still.E3 generation 200 on the flat course: 4.4, 7.7 and 8.7 m at 1, 2 and 3 s, and still 8.6 m at 9 s. First misreported as scooting.7, 9
How far after 300 generations of E3?About 9 m, nearly all in the first 2–3 sChampion distance 9.1 m at generation 299; median score −0.29 to 6.77.8
Is the latest champion the best one to ship?No, in E3 or E5E3: generation 299 validation 4.36 against generation 277's 8.26. E5: generation 299 validation 21.97 against generation 298's 24.12.8, 11
Does scoring only airborne distance fix it?NoSame lunge and freeze: the selected champion reached 8.9 m by 3 s and did not move after that.10
Does a stall rule fix it?YesE5 generation 298: 26.1 m on the flat course, about 2.5 m/s for the full 10 s, about 35% airborne, upright for all 10 s on the flat course and all 5 holdout courses.11
Is the winner's curse gone?NoE5 holdout over the last 50 generations: min 11.66, mean 20.04, max 23.97.11

2. The setup

2.1 Body

The frog is seven rigid pieces: a torso (with a head and a stiff, fixed front leg), plus two back legs each made of a thigh, a shin and a foot. Six revolute joints (hip, knee and ankle on each back leg) connect them. Each joint has a position-target motor with a strength limit. Nothing is animated: the motors push, and gravity, friction, momentum and collisions decide what happens.

Joint limits, as exported with the run
Joint (each back leg)Range (radians)Maximum torque
Hip−2.2 to 0.530 Nm
Knee−0.3 to 1.930 Nm
Ankle−2.4 to 0.315 Nm

2.2 Senses

The brain receives 21 inputs, each scaled to roughly −1 to 1:

2.3 Brain

A fully connected network of 21 inputs, two hidden layers of 16 neurons with tanh activation, and 6 outputs: 726 weights and biases in total. Each output picks a target angle within its joint's range, and that joint's motor drives towards it. Choosing target poses is far easier to evolve than choosing raw forces. Evolution only ever sees the 726 numbers as a flat list; it never knows they form a network.

2.4 Physics

planck.js 1.4.2, a port of the Box2D engine, with a fixed step of 1/60 s, 8 velocity and 3 position iterations, and gravity of −10 m/s².

2.5 Episode

One episode is 600 steps (10 s). It ends early if the torso or head touches the ground; we call that a fall. In E5 it also ends early if the frog stalls (§3.2). One episode takes about 16 ms of computer time.

3. Method

3.1 Genetic algorithm

Each generation, every brain drives a frog on the same three courses and scores the average. Then:

StepSettingPurpose
Population200 brainsInitial weights drawn at random, standard deviation 0.5.
Elitismbest 5 copied unchangedThe best result so far is never lost.
Tournament selectionbest of 4 picked at randomGood brains breed often; weaker ones sometimes, which keeps variety.
Crossover30% of childrenUniform: each weight comes at random from one of two parents.
Mutation10% of weights nudgedGaussian nudge, standard deviation 0.3 × 0.99generation, never below 0.05: exploring first, fine-tuning later.
Courses3 per generationThe same three for every brain in a generation, so the comparison is fair.

3.2 Scoring rules

The score is the only thing evolution sees, so it is where the real design work happens. We used four scoring rules over the course of the project, and for E5 added a stall rule to rule A:

3.3 Courses

Courses are generated from a seed, so only the seed needs storing and the browser can rebuild the identical ground. We keep four kinds apart, following the same discipline as our image classifier (select on validation, report on test):

SetSeedsUsed for
Trainingnew random seeds each generation, 3 per generationSelection during evolution. Gently bumpy.
Validation2001–2010 (10 courses)Choosing which champion to ship, from the last 50 generations. Nothing else.
Holdout1001–1005 (5 courses)Scoring every generation's champion. Never used for any selection, so the shipped champion's holdout score is an unbiased estimate.
Showcase0 (perfectly flat)The site's recordings and the gait analysis. Fixed before any results were seen.

4. E0: probes before evolution

Before evolving anything, we checked the body and physics with simple controllers.

ControllerResult
Hold the crouch poseStands for 10 s; moves −0.16 m
Hand-coded "crouch, then kick every 0.8 s", joint torque 40/40/20 Nm5.6 m, then flipped (torso at 168°) and fell after 1.3 s
Same, torque 25/25/124.1 m, fell after 1.4 s
Same, torque 15/15/71.9 m, fell after 0.9 s
20 random brainsAll fell within 0.4–1.8 s, travelling 0–5.5 m (mostly diving forward)

5. E1: the reward hack

A 30-generation smoke run with the distance-only score (§3.2).

GenerationBest scoreMedianChampion
04.700.77fell after 1.55 s, 5.6 m
109.003.97fell after 2.95 s, 11.4 m
2912.026.82fell after 2.88 s, 14.8 m

The population fall rate was 99–100% in every generation.

Finding. Evolution optimised the score and ignored the intent. It produced ever-longer dives followed by a crash: the reward hack predicted in E0. Diving is not a failure of the algorithm. It is the correct answer to the question we asked.

6. E2: fixing the score

Two cures, 100 generations each, seed 1, both keeping the energy term: A scales distance by the fraction of the episode survived; B subtracts a flat 10 for falling (§3.2).

GenA bestA medianA holdoutA championA fellB bestB medianB holdoutB championB fell
01.56−0.292.894.8 m, 4.8 s99%1.04−9.231.041.5 m, 10 s99%
105.950.634.936.9 m, 10 s62%4.47−5.754.424.9 m, 10 s80%
506.301.056.067.3 m, 10 s64%6.773.136.747.2 m, 10 s46%
996.795.475.337.1 m, 10 s34%7.442.876.128.0 m, 10 s42%

Fell: share of all the population's episodes that ended in a fall. Holdout: the champion's score on the 5 holdout courses. Champion: average over that generation's 3 training courses. Scores under A and B are not directly comparable: A scales distance, B subtracts a penalty.

Decision. A (scale by survival) is the default for everything that follows. It is simpler to explain and gave a smoother signal.

7. Gait analysis (corrected)

With falling fixed, we measured how the champions move on the flat showcase course: the share of time with no part of the frog touching the ground (airborne), the number of separate flights, and the share of time the stiff front leg is on the ground.

ChampionDistanceAirborneFlightsFront leg on ground
A, gen 106.8 m14%281%
A, gen 997.0 m15%565%
B, gen 998.9 m19%573%

Original finding (superseded): second reward hack. The champions mostly scoot on the fixed front leg with occasional short hops. Nothing in the score says "hop", and scooting is a stable way to cover distance without falling.

Correction · found during E5

The champions do not scoot. Measuring distance second by second showed that they cover nearly all their distance in the first 2–3 s, then stand still for the rest of the episode. The high front-leg contact is standing, not scooting. Airborne share, flights and front-leg contact are totals over the whole episode, so they could not tell a steady gait from a lunge followed by standing still. The distance-by-second table is in §9.2.

The exhibits in this paper are stills from the recordings used by the site. Each still is centred on the frog with the ground fixed, so height above the ground is to scale; gridlines are 1 m apart. Unless a caption says otherwise, stills are taken every 0.4 s for the first 2.4 s, followed by the final recorded frame. A red border on the final still marks a recording that ended early (a fall or a stall); a green border, one that lasted the full 10 s.

Exhibit 1 · E3 · Generation 0 The best of 200 random brains, E3 run, on the flat showcase course. It covered 3.5 m in 10 s without falling, airborne 10% of the time. Nobody would call this hopping.

8. E3: the main run

300 generations with rule A, seed 1. The run took about 7 minutes. Its selected champion, generation 277, was the one the previous preview of this site shipped.

GenerationBestMedianHoldoutChampion distancePopulation fell
01.56−0.292.894.8 m99%
105.950.634.936.9 m62%
506.301.056.067.3 m64%
1006.985.336.947.3 m35%
1508.195.896.128.7 m34%
2008.446.006.988.9 m32%
2508.936.455.159.4 m31%
2809.246.282.489.7 m28%
2998.626.776.089.1 m24%
  • Best (training courses)
  • Champion on holdout courses
  • Median
  • Selected champion
Exhibit 2 · E3 · Score per generation E3, generations 0 to 299, drawn from the exported history. The median rises steadily from −0.29 to 6.77. From about generation 120 the holdout line often drops far below the best: over the last 50 generations it ranged from 1.95 to 8.85 (mean 5.89). The dashed line and dot mark generation 277.

8.1 The winner's curse

8.2 Model selection

The last generation's champion is not necessarily the best one to ship. The exporter scores the champions of the last 50 generations on the 10 validation courses (seeds 2001–2010) and ships the best. The holdout courses (1001–1005) are never used for selection, so the shipped champion's holdout score is still an unbiased estimate. The same procedure is used for E4 and E5.

ChampionValidation (10 courses)Holdout (5 courses)
Latest (gen 299)4.366.08
Selected (gen 277)8.267.62

9. Two behaviours, and lunge and freeze

9.1 Two behaviours, as first measured

Late E3 champions switch between two behaviours depending on small differences in the terrain. Each cell is one 10-second episode: distance, time survived, and share of time airborne.

ChampionFlat (0)10011002100310041005
gen 1007.3 m, 10 s, 14%6.9 m, 10 s, 17%7.3 m, 10 s, 14%7.4 m, 10 s, 16%7.4 m, 10 s, 16%7.5 m, 10 s, 17%
gen 2008.6 m, 10 s, 18%fell: 9.9 m, 3.1 s, 61%8.4 m, 10 s, 19%8.4 m, 10 s, 18%8.8 m, 10 s, 18%8.7 m, 10 s, 18%
gen 277 (selected)fell: 10.0 m, 2.8 s, 62%9.4 m, 10 s, 17%fell: 10.1 m, 2.8 s, 63%9.4 m, 10 s, 17%9.4 m, 10 s, 17%9.5 m, 10 s, 18%
gen 299fell: 10.9 m, 3.3 s, 55%9.3 m, 10 s, 16%fell: 11.0 m, 3.0 s, 64%8.8 m, 10 s, 17%fell: 9.8 m, 2.6 s, 61%8.9 m, 10 s, 16%

Original interpretation (superseded). Evolution has found real hopping but cannot yet keep it stable, and the survival-scaled score rewards the safe scoot about as much as a short, fast hop.

Exhibit 3 · E3 · Generation 277 · The hop The E3 selected champion, shipped by the previous preview, on the flat showcase course: 10.0 m, then it fell at 2.8 s, airborne 62% of the episode. The last still is the final recorded frame before the fall.

9.2 Correction: lunge and freeze

Correction

We found this while investigating why the site's ghost race looked static. The "safe behaviour" is not a gait. It is a lunge of 7–9 m in the first 2–3 s, followed by standing still. Our earlier "scoot" description was wrong.

Distance at each whole second on the flat course (seed 0) and holdout course 1001:

ChampionCourseDistance at 1 s, 2 s, …, 9 s (m)Outcome
E3 gen 10flat4.1, 6.9, 6.8, 6.8, 6.8, 6.8, 6.8, 6.8, 6.8upright at 10 s
E3 gen 50flat2.7, 4.8, 4.8, 5.4, 6.0, 6.2, 6.1, 6.4, 6.9upright at 10 s
E3 gen 100flat4.4, 6.9, 7.3, 7.3, 7.3, 7.3, 7.3, 7.3, 7.3upright at 10 s
E3 gen 200flat4.4, 7.7, 8.7, 8.6, 8.6, 8.6, 8.6, 8.6, 8.6upright at 10 s
E3 gen 27710014.3, 8.6, 9.4, 9.4, 9.4, 9.4, 9.4, 9.4, 9.4upright at 10 s
E3 gen 277flat4.3, 8.5fell at 2.8 s
Exhibit 4 · E3 · Generation 200 · Lunge and freeze An E3 champion on the flat showcase course, with stills at 0, 1, 2, 3, 5, 7 and 9 s and the final frame. Logged distance at each second: 4.4, 7.7, 8.7, 8.6, 8.6, 8.6, 8.6, 8.6, 8.6 m. It is moving for the first 2–3 s and then stands still for the rest of the episode. Upright at 10 s, 8.6 m.

9.3 A note on the showcase

The course was never changed. The flat showcase course (seed 0) was fixed before any of these results were seen. We did not change it to one where a champion looks better. On it, the E3 selected champion hops for 2.8 s and falls, and the previous preview said so on its front page. The E5 champion (§11) is shown on the same course.

10. E4: airborne-only scoring Complete · corrected

E4 was designed while we still believed the champions scooted. It counts only forward distance covered while no part of the frog touches the ground, still scaled by survival: 150 generations, seed 1. The aim was to stop rewarding scooting.

GenerationBestMedianHoldoutChampion distanceChampion airbornePopulation fell
01.60−0.331.601.6 m9%99%
103.910.263.904.9 m10%67%
255.192.445.026.5 m18%46%
505.702.965.637.1 m18%51%
756.143.724.297.9 m20%41%
1006.564.394.689.1 m20%36%
1256.414.372.408.6 m17%30%
1496.244.914.368.3 m18%24%

Scores count airborne distance only, so they are not comparable with E2 or E3 scores. Distances and airborne fractions are comparable.

10.1 Selection

Using the same procedure as E3, generation 120 was chosen, with validation 6.00 and holdout 5.88. The latest champion (generation 149) had validation 4.26 and holdout 4.36.

ChampionFlat (0)10011002100310041005
gen 507.1 m, 10 s, 16%7.1 m, 10 s, 17%7.2 m, 10 s, 17%6.9 m, 10 s, 15%7.1 m, 10 s, 17%7.2 m, 10 s, 17%
gen 100fell: 9.6 m, 3.3 s, 56%9.4 m, 10 s, 23%fell: 9.6 m, 3.3 s, 55%8.6 m, 10 s, 18%8.3 m, 10 s, 22%fell: 6.0 m, 5.1 s, 55%
gen 120 (selected)8.9 m, 10 s, 20%8.9 m, 10 s, 19%8.9 m, 10 s, 20%6.9 m, 10 s, 16%7.2 m, 10 s, 30%8.5 m, 10 s, 24%
gen 1499.2 m, 10 s, 21%fell: 8.8 m, 2.5 s, 80%8.1 m, 10 s, 28%8.6 m, 10 s, 20%fell: 8.7 m, 2.5 s, 79%9.4 m, 10 s, 20%

10.2 Findings

Original interpretation (superseded by E5). The limiting factor is not what the score rewards but whether the fast hop can be controlled at all.

Correction

Distance by second shows the same lunge and freeze as E3. Generation 50 reached 7.1 m by 3 s and generation 120 reached 8.9 m by 3 s, and neither moved after that. Airborne-only scoring still banks the lunge, and survival scaling still rewards standing still. E5 shows that the score was the limit: once standing still was penalised, a continuous hop emerged.

E4 was never shipped, and no E4 recordings were exported, so there are no E4 exhibits.

11. E5: the stall rule Shipped

Rule: the E2-A score (distance × fraction of episode survived, minus the energy term) plus a stall rule. The episode ends if the torso has not moved at least 0.5 m forward in the last 2 s. A stalled episode is scaled by survival exactly like a fall, so standing still after a lunge now costs the survival multiplier. 300 generations, seed 1.

Why: E3 and E4 champions lunged and then froze (§9.2). The stall rule makes continuous forward progress the only way to keep the multiplier.

GenBestMedianHoldoutChampion distanceChampion uprightChampion airbornePopulation fellPopulation stalled
00.88−0.290.865.0 m2.5 s39%98%2%
102.080.341.929.9 m3.0 s73%84%16%
254.240.574.0213.7 m4.0 s66%90%10%
5011.890.905.0718.2 m6.5 s52%88%12%
10015.584.6211.4718.0 m10 s37%66%10%
15021.5113.7316.3223.4 m10 s35%41%3%
20022.6018.0111.3924.6 m10 s40%31%1%
25023.2920.0422.4825.5 m10 s35%22%1%
29924.0320.0223.7426.2 m10 s36%27%5%

Champion columns are averages over that generation's 3 training courses. Population fell / stalled: share of all the population's episodes that ended that way.

  • Best (training courses)
  • Champion on holdout courses
  • Median
  • Shipped champion
Exhibit 5 · E5 · Score per generation E5, generations 0 to 299, drawn from the exported history. The median rises from −0.29 to 20.02. The holdout line still dips well below the best in places: the winner's curse is still present. The dashed line and dot mark generation 298. The vertical scale differs from Exhibit 2, and E5 scores are not comparable with E3 scores.

11.1 Selection

Holdout over the last 50 generations: min 11.66, mean 20.04, max 23.97. Selection on the validation courses (seeds 2001–2010, last 50 generations) chose generation 298.

ChampionValidation (10 courses)Holdout (5 courses)
Latest (gen 299)21.9723.74
Selected (gen 298)24.1223.04

The latest champion scored slightly higher on holdout. Holdout is never used for selection, so that does not change the choice; the selected champion's holdout (23.04) is close to its validation (24.12).

11.2 The selected champion, second by second

Measured with the stall rule switched off, to show what the frog does when nothing stops it:

CourseOutcomeDistanceAirborneDistance at 1 s … 9 s (m)
flatupright at 10 s26.1 m35%3.5, 6.5, 8.8, 11.4, 13.7, 16.2, 18.9, 21.5, 23.8
1001upright at 10 s23.8 m37%3.5, 6.6, 9.1, 11.8, 13.2, 14.9, 17.2, 18.6, 21.0
1002upright at 10 s25.7 m35%3.5, 6.5, 8.9, 11.5, 14.5, 17.1, 18.7, 21.0, 23.2
1003upright at 10 s25.5 m37%3.5, 6.2, 8.5, 10.6, 13.2, 15.0, 17.5, 20.1, 22.7
1004upright at 10 s25.6 m31%3.5, 6.5, 8.7, 11.1, 13.3, 15.9, 18.3, 20.8, 23.2
1005upright at 10 s25.4 m39%3.5, 6.5, 8.6, 11.2, 13.9, 16.1, 18.0, 20.7, 23.4
Exhibit 6 · E5 · Generation 298 · Continuous hop The shipped champion on the flat showcase course, stall rule on, as recorded for the site. Stills at the same times as Exhibit 4 (0, 1, 2, 3, 5, 7 and 9 s, then the final frame): distance keeps rising second after second instead of stopping. 26.1 m in 10 s, airborne 35% of the time, upright and still moving at the end.

11.3 Recorded champions on the flat showcase course

With the stall rule on, as shipped on the site's ghost race:

GenerationOutcome
0stalled, 4.18 m at 3.0 s
5stalled, 4.48 m at 3.5 s
10fell, 9.85 m at 3.0 s
25stalled, 15.44 m at 6.8 s
50stalled, 16.21 m at 7.8 s
100fell, 11.91 m at 5.7 s
200upright at 10 s, 25.49 m
298 (selected)upright at 10 s, 26.12 m
299upright at 10 s, 26.38 m

11.4 Findings

Decision. E5 generation 298 replaces E3 generation 277 as the published champion.

12. Limitations and future work

12.1 Threats to validity

12.2 Candidate next steps (not yet tested)

13. Reproducibility