First program generation

This commit is contained in:
Ian Gulliver
2021-11-20 19:25:16 -10:00
parent f6a598a559
commit a5a4c49e37
10 changed files with 28 additions and 13 deletions

View File

@@ -1,7 +1,16 @@
global_memory_size: 1
function_memory_size: 1
instruction_limit: 2
samples:
- global_memory_inputs:
0: 0
global_memory_outputs:
0: 1
- global_memory_inputs:
0: 1
global_memory_outputs:
0: 2
- global_memory_inputs:
0: 100
global_memory_outputs:
0: 101

View File

@@ -7,6 +7,7 @@ import "gopkg.in/yaml.v2"
type Definition struct {
GlobalMemorySize uint64 `yaml:"global_memory_size"`
FunctionMemorySize uint64 `yaml:"function_memory_size"`
InstructionLimit uint64 `yaml:"instruction_limit"`
Samples []*Sample `yaml:"samples"`
}

View File

@@ -13,16 +13,7 @@ func (def *Definition) Grow() {
// TODO: Score should be number of output criteria, not number of Samples
for high_score < len(def.Samples) {
prog := gen.RandProgram(def.GlobalMemorySize, def.FunctionMemorySize)
{
src, err := asm.Disassemble(prog)
if err != nil {
log.Fatal(err)
}
log.Print("Prog:\n%s", src)
}
prog := gen.RandProgram(def.GlobalMemorySize, def.FunctionMemorySize, def.InstructionLimit)
score, err := def.Score(prog)
if err != nil {
@@ -37,7 +28,7 @@ func (def *Definition) Grow() {
log.Fatal(err)
}
log.Print("New high score %d / %d:\n%s", high_score, len(def.Samples), src)
log.Printf("New high score %d / %d:\n%s", high_score, len(def.Samples), src)
}
}
}