Parameterize ideal function size

This commit is contained in:
Ian Gulliver
2021-11-23 20:45:03 -08:00
parent 8a63bd3b3e
commit a9360aa8da
3 changed files with 20 additions and 26 deletions

View File

@@ -5,13 +5,8 @@ import "math/rand"
import "github.com/firestuff/subcoding/gen"
import "github.com/firestuff/subcoding/vm"
const instructionsPerFunctionMean = 15
const instrucitonsPerFunctionStdDev = 10
const minifyPeriodMean = 10000
func Mutate(_ *Definition, prog *vm.Program) {
target := int(rand.NormFloat64()*instrucitonsPerFunctionStdDev + instructionsPerFunctionMean)
func Mutate(def *Definition, prog *vm.Program) {
target := int(rand.NormFloat64()*float64(def.InstructionsPerFunctionStdDev) + float64(def.InstructionsPerFunctionMean))
if len(prog.Functions[0].Instructions) < target {
addInstruction(prog, prog.Functions[0])