Constants for distribution
This commit is contained in:
@@ -6,8 +6,11 @@ import "math/rand"
|
|||||||
import "github.com/firestuff/subcoding/gen"
|
import "github.com/firestuff/subcoding/gen"
|
||||||
import "github.com/firestuff/subcoding/vm"
|
import "github.com/firestuff/subcoding/vm"
|
||||||
|
|
||||||
|
const instructionsPerFunctionMean = 15
|
||||||
|
const instrucitonsPerFunctionStdDev = 10
|
||||||
|
|
||||||
func Mutate(prog *vm.Program) {
|
func Mutate(prog *vm.Program) {
|
||||||
target := int(math.Max(2, rand.NormFloat64()*10+15))
|
target := int(math.Max(2, rand.NormFloat64()*instrucitonsPerFunctionStdDev+instructionsPerFunctionMean))
|
||||||
|
|
||||||
if len(prog.Functions[0].Instructions) < target {
|
if len(prog.Functions[0].Instructions) < target {
|
||||||
addInstruction(prog, prog.Functions[0])
|
addInstruction(prog, prog.Functions[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user