Make divide-by-zero error, handle error gracefully in grow
This commit is contained in:
@@ -52,11 +52,8 @@ func (def *Definition) Grow(statusChan chan<- Status) (*vm.Program, error) {
|
||||
|
||||
score, err := def.score(prog)
|
||||
if err != nil {
|
||||
if statusChan != nil {
|
||||
close(statusChan)
|
||||
}
|
||||
|
||||
return nil, err
|
||||
// Can never get best score
|
||||
continue
|
||||
}
|
||||
|
||||
if score > status.BestScore {
|
||||
@@ -89,7 +86,10 @@ func (def *Definition) score(prog *vm.Program) (uint64, error) {
|
||||
|
||||
sample.SetInputs(state)
|
||||
|
||||
state.Execute() // ignore error
|
||||
err = state.Execute()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
score += sample.matchingOuts(state)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user