Make pythag really slow

This commit is contained in:
Ian Gulliver
2021-11-24 20:46:48 -08:00
parent 0bccd0c94b
commit 4eb2ff6188
3 changed files with 109 additions and 22 deletions

View File

@@ -98,7 +98,7 @@ func (def *Definition) Grow(statusChan chan<- Status) (*vm.Program, error) {
statusChan <- status
}
if status.BestScores[0].Current == status.BestScores[0].Total {
if def.scoreIsPerfect(status.BestScores) {
return prog, nil
}
}
@@ -225,6 +225,16 @@ func (def *Definition) scoreIsBetter(old, new []*Score) bool {
return false
}
func (def *Definition) scoreIsPerfect(scores []*Score) bool {
for _, score := range scores {
if score.Current < score.Total {
return false
}
}
return true
}
func (def *Definition) minifyProgram(prog *vm.Program) error {
for f := 0; f < len(prog.Functions); f++ {
err := def.minifyFunction(prog, f)