You get a bonus - 1 coin for daily activity. Now you have 1 coin

Genetic algorithm Cat Jump online on Intellect

Used 520 times
Genetic algorithm Cat Jump online

Genetic Algorithm Cat Jump

The cat tries to jump from the starting platform to the red target. The genome controls motors in the leg, body and tail joints; the best attempts enter the selection pool and produce offspring.

Mutation settings

Current cat

Attempt: 1 Frame: 0 Current score: 0.00 Best score: 0.00

Best attempts

AttemptScoreTargetsDistanceHeightJoint parameters

Share:



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Your answer option for this service or noticed an error:

Genetic Algorithm Cat Jump online is an interactive simulator where a virtual cat learns to jump across platforms. The tool is useful for demonstrating evolutionary algorithms, motion-parameter search, selection-based learning and visual exploration of how random mutations can gradually produce better behavior.
Tool features:

  • run a physical cat-jump simulation directly in the browser;

  • preserve the original cat body outlines: head, neck, upper and lower torso, front and back legs, toes and tail;

  • calculate motion with embedded physics: gravity, inertia, friction, platform collisions and joint constraints;

  • control joints through a genome: each active joint receives parameters for periodic motor motion;

  • generate an endless chain of target platforms: when the cat reaches the current target, the next platform is created;

  • show a best-attempts table with score, distance, height and reached targets;

  • configure mutation chance, mutation amount, best-pool size, attempt length and simulation speed;

  • pause, manually move to the next cat and fully reset training.




In this tool, the genetic algorithm improves not the cat's lunges themselves, but the joint movement parameters.
The following parameters are modified for each active joint:
- time_factor - the frequency/tempo of joint movement.
- time_shift - the phase shift, i.e., at what point in the cycle the joint begins to move.
- cos_factor - the force and direction of the motor movement.
- forward_push - how strongly a paw pushes the body forward when a toe touches a platform.
- lift_push - how strongly a paw lifts the torso during push-off.
- target_sense - how much the joint amplifies movement when the cat approaches the current target.
- target_window - the distance to the target where this amplification starts.
This is generated in randomChromosome() and then stored in the genome:
The movement is calculated as follows:
speed = gene.cos_factor * targetBoost * Math.cos(gene.time_factor * frame + gene.time_shift)
impulse = clamp(speed / 700, -0.075, 0.075)
In other words, each gene specifies the periodic motor force for a specific joint, and targetBoost makes movement stronger near the target platform. This is applied in applyMotors():
What "improves" from generation to generation:
- Paw coordination: which joints flex/extend, with what phase and force.
- Torso push-off momentum from the platform.
- Torso lift when the toe hits the ground.
- Upper_torso forward movement.
- Jump height.
- Method of landing on the target platform.
The score is calculated in updateScore():
The formula is roughly as follows:
score = sqrt(maxX^2 + maxY^2) + proximityBonus + targetsReached * 12 - stabilityPenalty - fallPenalty
That is, the algorithm prefers cats that:
- moved further to the right (maxX);
- jumped higher (maxY);
- moved closer to the current target platform even before reaching it;
- reached more target platforms (targetsReached, a large bonus * 12);
- tumble less and do not fall downward.
After an attempt, the genome is saved in genePool, the pool is sorted by score, and the best ones remain. The best-attempt pool is also saved in browser localStorage, so training can continue after reloading the page. Clicking "Reset training" clears both the current pool and the localStorage save.
A new genome is created as follows:
- two parents are selected from the best attempts;
- for each gene, a version from one of the parents is randomly selected;
- individual parameters are mutated by multiplying by a random coefficient;
- values ​​are constrained to ranges.
This is in makeGenome() and copulate().
Result: the algorithm "teaches" the cat not directly to jump, but rather selects the rhythm, phase, and strength of motor impulses in the joints. The best combinations result in more movement, height, and
platform hits, so they are more likely to be inherited.


Short theory of the genetic algorithm:
A genetic algorithm is a search method inspired by natural selection. First, random candidate solutions are created. In this model, one candidate solution is the cat genome: a set of numeric parameters for motorized joints. After an attempt, the simulator evaluates the result: how far and high the cat moved and how many target platforms it reached. The best genomes are stored in the selection pool. A new cat is created by crossover of two parent genomes: some parameters come from one parent and some from the other. Mutation then slightly changes selected parameters. This lets the algorithm explore new jump patterns instead of only repeating previous movements.
How the physics model works:
The cat body consists of separate polygon parts. Joints between them have allowed angle limits. At every simulation step, gravity is applied, inertia is preserved, platform contact is processed and joint constraints are corrected. Toe bodies have stronger ground grip, so a successful paw position can produce a push. This is not a video or prerecorded animation: the jump emerges from the interaction of the genome, physics and platforms.
Settings explained:

  • Mutation chance - the probability that an individual gene parameter changes when a new cat is created. Low values make learning more stable but slower. High values explore more aggressively but can often break already useful motions.

  • Mutation amount - how strongly the selected parameter changes. Small values are good for fine tuning. Large values are useful when the population is stuck repeating similar failed movements.

  • Best pool size - how many top attempts are kept for parent selection. A small pool quickly reinforces strong solutions but can reduce diversity. A larger pool preserves more variation and may discover unexpected strategies.

  • Attempt length - how many frames one attempt lasts before scoring and moving to the next cat. A short attempt speeds up learning but may not allow a complex jump. A long attempt helps when crossing several platforms in a row.

  • Simulation speed - the number of physics steps per second. Higher speed evaluates attempts faster but uses more CPU. "Pause" stops calculation while keeping the current state.

  • Pause / Continue - temporarily stops or resumes evolution without resetting the current cat.

  • Next cat - manually finishes the current attempt, stores its result and starts a new cat.

  • Reset training - clears the best-genome pool and starts again from a random cat.


How to read the results:
The "Score" value includes distance, jump height, proximity to the current platform, a penalty for unstable tumbling, and bonuses for reached target platforms. "Targets" shows how many platforms the cat successfully reached in one attempt. "Distance" is the maximum forward progress, and "Height" is the maximum upward movement relative to the starting position. In the best-attempts table, the "Joint parameters" column shows the full parameter set for every active joint. Only the top part is visible by default to keep the table readable; "Show all" expands the whole genome, and "Copy" copies JSON with joint parameters and the raw genome array for moving the result elsewhere. Once the cat reaches a target reliably, the next platform appears farther ahead, turning the task into an endless platformer.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply