MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / mutate

Method mutate

Brain.js:79–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77 }
78
79 mutate() {
80 let mutationRate = 0.1;
81 let chanceOfNewInstruction = 0.02;
82 for (let i = this.parentReachedBestLevelAtActionNo; i < this.instructions.length; i++) {
83 if (random() < chanceOfNewInstruction) {
84 this.instructions[i] = this.getRandomAction()
85 } else if (random() < mutationRate) {
86 this.instructions[i].mutate();
87 }
88 }
89 }
90
91 mutateActionNumber(actionNumber){
92 // let mutationRate = 0.1;

Callers 2

mutateActionNumberMethod · 0.45
NaturalSelectionMethod · 0.45

Calls 1

getRandomActionMethod · 0.95

Tested by

no test coverage detected