diff --git a/grow/definition.go b/grow/definition.go index 0861415..c35ba94 100644 --- a/grow/definition.go +++ b/grow/definition.go @@ -7,10 +7,14 @@ import "gopkg.in/yaml.v2" import "github.com/firestuff/subcoding/vm" type Definition struct { - GlobalMemorySize uint64 `yaml:"global_memory_size"` - FunctionMemorySize uint64 `yaml:"function_memory_size"` - InstructionLimit uint64 `yaml:"instruction_limit"` - Samples []*Sample `yaml:"samples"` + GlobalMemorySize uint64 `yaml:"global_memory_size"` + FunctionMemorySize uint64 `yaml:"function_memory_size"` + InstructionLimit uint64 `yaml:"instruction_limit"` + + InstructionsPerFunctionMean uint64 `yaml:"instructions_per_function_mean"` + InstructionsPerFunctionStdDev uint64 `yaml:"instructions_per_function_std_dev"` + + Samples []*Sample `yaml:"samples"` } func NewDefinition(r io.Reader) (*Definition, error) { diff --git a/grow/defs/pythag.yaml b/grow/defs/pythag.yaml index 2ba164b..47c00bc 100644 --- a/grow/defs/pythag.yaml +++ b/grow/defs/pythag.yaml @@ -1,30 +1,25 @@ global_memory_size: 2 function_memory_size: 1 instruction_limit: 20 + +instructions_per_function_mean: 5 +instructions_per_function_std_dev: 3 + samples: - in: [3,4] out: [5] -- in: [5,12] - out: [13] - -- in: [8,15] - out: [17] - - in: [7,24] out: [25] -- in: [20,21] - out: [29] - -- in: [12,35] - out: [37] - -- in: [9, 40] - out: [41] - - in: [88, 105] out: [137] +- in: [140, 171] + out: [221] + +- in: [105, 208] + out: [233] + - in: [161, 240] out: [289] diff --git a/grow/mutate.go b/grow/mutate.go index 5cde07e..d5598d0 100644 --- a/grow/mutate.go +++ b/grow/mutate.go @@ -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])