<commit_before>package termination

import "github.com/aurelien-rainone/evolve/framework"

// GenerationCount terminates evolution after a set number of generations have
// passed.
type GenerationCount struct {
	generationCount int
}

// NewGenerationCount creates a GenerationCoun termination condition.
func NewGenerationCount(generationCount int) GenerationCount {
	if generationCount <= 0 {
		panic("Generation count must be positive")
	}
	return GenerationCount{generationCount: generationCount}
}

// ShouldTerminate reports whether or not evolution should finish at the
// current point.
//
// populationData is the information about the current state of evolution.
// This may be used to determine whether evolution should continue or not.
func (tc GenerationCount) ShouldTerminate(populationData *framework.PopulationData) bool {
	return populationData.GenerationNumber()+1 >= tc.generationCount
}<commit_msg>Refactor GenerationCount (alias to int)<commit_after>package termination

import "github.com/aurelien-rainone/evolve/framework"

// GenerationCount terminates evolution after a set number of generations have
// passed.
type GenerationCount int

// NewGenerationCount creates a GenerationCoun termination condition.
func NewGenerationCount(generationCount int) GenerationCount {
	if generationCount <= 0 {
		panic("Generation count must be positive")
	}
	return GenerationCount(generationCount)
}

// ShouldTerminate reports whether or not evolution should finish at the
// current point.
//
// populationData is the information about the current state of evolution.
// This may be used to determine whether evolution should continue or not.
func (tc GenerationCount) ShouldTerminate(populationData *framework.PopulationData) bool {
	return populationData.GenerationNumber()+1 >= int(tc)
}
{'fraction_non_alphanumeric': 0.06976744186046512, 'fraction_numerical': 0.0022148394241417496, 'mean_word_length': 5.453571428571428, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2207944', 'n_tokens_mistral': 448, 'n_tokens_neox': 424, 'n_words': 169}