<commit_before>package sequential

import (
	"math/rand"
)

func (model *Model) init_board_strain() {
	// init on the metal
	model.Board_strain = make([][]int, model.Parameters.Board_Size)
	for row_i := range model.Board_strain {
		model.Board_strain[row_i] = make([]int, model.Parameters.Board_Size)
	}

	// init in the model
	for row_i := range model.Board_strain {
		for col_i := range model.Board_strain[row_i] {
			if rand.Float64() < model.Parameters.R_Init_Odds {
				model.Board_strain[row_i][col_i] += 1
			}
			if rand.Float64() < model.Parameters.S_Init_Odds {
				model.Board_strain[row_i][col_i] += 2
			}

		}
	}
}

func (model *Model) init_board_signal_num() {
	// init on the metal
	model.Board_signal_num = make([][][]int, 2)
	for strain_i := range model.Board_signal_num {
		model.Board_signal_num[strain_i] = make([][]int, model.Parameters.Board_Size)
		for row_i := range model.Board_signal_num[strain_i] {
			model.Board_signal_num[strain_i][row_i] = make([]int, model.Parameters.Board_Size)
		}
	}

	// init in the model
	center_coord := Coordinate{}
	for center_coord.r = 0; center_coord.r < model.Parameters.Board_Size; center_coord.r++ {
		for center_coord.c = 0; center_coord.c < model.Parameters.Board_Size; center_coord.c++ {
			rad_i := Coordinate{}
			for rad_i.r = center_coord.r - model.Parameters.S_Radius; rad_i.r <= center_coord.r+model.Parameters.S_Radius; rad_i.r++ {
				for rad_i.c = center_coord.c - model.Parameters.S_Radius; rad_i.c <= center_coord.c+model.Parameters.S_Radius; rad_i.c++ {
					// here we count the number of signals for each cell

					// get strain at rad_i
					strain_at_rad := model.get_cell_strain(rad_i.get_toroid_coordinates(model.Parameters.Board_Size))

					// the allele of signal of the strain at rad_i
					signal_strain_at_rad := s4strain[strain_at_rad]

					// add one signal at center_coord of the signal allele from rad_i
					model.Add_To_Cell_Signal_Num(center_coord, signal_strain_at_rad, 1)
				}
			}
		}
	}
}

func (model *Model) init_board_prod() {
	// init on the metal
	model.Board_prod = make([][]bool, model.Parameters.Board_Size)
	for i0 := range model.Board_prod {
		model.Board_prod[i0] = make([]bool, model.Parameters.Board_Size)
	}

	// init in the model
	center_coord := Coordinate{}
	for center_coord.r = range model.Board_prod {
		for center_coord.c = range model.Board_prod[center_coord.r] {
			strain_at_center_coord := model.get_cell_strain(center_coord)
			receptor_allele_at_center_coord := r4strain[strain_at_center_coord]
			if model.get_cell_signal_num(center_coord, receptor_allele_at_center_coord) >= model.Parameters.Signal_Threshold {
				model.set_cell_prod(center_coord, 1 > 0)
			}
		}
	}
}

func (model *Model) init_board_pg_num() {
	model.Board_pg_num = make([][]int, model.Parameters.Board_Size)
	for row_i := range model.Board_pg_num {
		model.Board_pg_num[row_i] = make([]int, model.Parameters.Board_Size)
	}

	center_coord := Coordinate{}
	for center_coord.r = range model.Board_pg_num {
		for center_coord.c = range model.Board_pg_num[center_coord.r] {
			rad_i := Coordinate{}
			for rad_i.r = center_coord.r - model.Parameters.PG_Radius; rad_i.r < center_coord.r+model.Parameters.PG_Radius+1; rad_i.r++ {
				for rad_i.c = center_coord.c - model.Parameters.PG_Radius; rad_i.c < center_coord.c+model.Parameters.PG_Radius+1; rad_i.c++ {
					rad_i_t := rad_i.get_toroid_coordinates(model.Parameters.Board_Size)
					if model.get_cell_prod(rad_i_t) {
						model.Add_To_Cell_PG_Num(center_coord, 1)
					}
				}
			}
		}
	}
}

func (model *Model) init_boards() {
	model.init_board_strain()
	model.init_board_signal_num()
	model.init_board_prod()
	model.init_board_pg_num()
}

// TODO this comment sucks. initialize all the data samples
func (model *Model) init_data_samples() {
	model.init_data_samples_snapshots()
	model.init_data_samples_frequencies()
	model.init_data_samples_neighborhood_frequencies()
}

// Initialize the board snapshots samples
func (model *Model) init_data_samples_snapshots() {
	if model.Settings.Snapshots_sample_num != 0 {
		if model.Parameters.Generations%model.Settings.Snapshots_sample_num == 0 {
			// the case in which the last snapshot is the same as the last generation
			model.Data_samples.Snapshots = make([]Snapshot, 1, model.Settings.Snapshots_sample_num)
		} else {
			// the case in which the last snapshot isn't the same as the last generation
			model.Data_samples.Snapshots = make([]Snapshot, 1, model.Settings.Snapshots_sample_num+1)
		}
		for sample_i := range model.Data_samples.Snapshots {
			data := make([][]int, model.Parameters.Board_Size)
			for row := range data {
				data[row] = make([]int, model.Parameters.Board_Size)
			}
			model.Data_samples.Snapshots[sample_i].Data = data
		}
	}
}

// Initialize the strain frequencies samples
func (model *Model) init_data_samples_frequencies() {
	if model.Settings.Frequencies_sample_num != 0 {
		if model.Parameters.Generations%model.Settings.Frequencies_sample_num == 0 {
			// the case in which the last sample is the same as the last generation
			model.Data_samples.Frequencies = make([]Frequency, 1, model.Settings.Frequencies_sample_num)
		} else {
			// the case in which the last sample isn't the same as the last generation
			model.Data_samples.Frequencies = make([]Frequency, 1, model.Settings.Frequencies_sample_num+1)
		}
		for sample_i := range model.Data_samples.Frequencies {
			model.Data_samples.Frequencies[sample_i].Data = make([]int, 8)
		}
	}
}

// Initialize the neighbors frequencies samples
func (model *Model) init_data_samples_neighborhood_frequencies() {
	if model.Settings.Neighborhood_frequencies_sample_num != 0 {
		if model.Parameters.Generations%model.Settings.Neighborhood_frequencies_sample_num == 0 {
			// the case in which the last sample is the same as the last generation
			model.Data_samples.Neighbors_frequencies = make([]Neighbors_frequency, model.Settings.Neighborhood_frequencies_sample_num)
		} else {
			// the case in which the last sample isn't the same as the last generation
			model.Data_samples.Neighbors_frequencies = make([]Neighbors_frequency, model.Settings.Neighborhood_frequencies_sample_num+1)
		}
		for sample_i := range model.Data_samples.Neighbors_frequencies {
			data := make([][]int, 8)
			// for each strain we'll count how many strains are around it.
			for strain_i := range data {
				data[strain_i] = make([]int, 8)
			}
			model.Data_samples.Neighbors_frequencies[sample_i].Data = data
		}
	}
	model.Data_samples.Neighbors_frequencies = model.Data_samples.Neighbors_frequencies[0:1]
}<commit_msg>Golangifying names and solving the 0 sample numbers bug.<commit_after>package sequential

import ()

// We need only one init function for both models
func (model *Model) InitBoardSignalNum() {
	// init on the metal
	model.BoardSignalNum = make([][][]int, 2)
	for strain_i := range model.BoardSignalNum {
		model.BoardSignalNum[strain_i] = make([][]int, model.Parameters.BoardSize)
		for row_i := range model.BoardSignalNum[strain_i] {
			model.BoardSignalNum[strain_i][row_i] = make([]int, model.Parameters.BoardSize)
		}
	}

	// init in the model
	center_coord := Coordinate{}
	for center_coord.r = 0; center_coord.r < model.Parameters.BoardSize; center_coord.r++ {
		for center_coord.c = 0; center_coord.c < model.Parameters.BoardSize; center_coord.c++ {
			rad_coord := Coordinate{}
			for rad_coord.r = center_coord.r - model.Parameters.SRadius; rad_coord.r <= center_coord.r+model.Parameters.SRadius; rad_coord.r++ {
				for rad_coord.c = center_coord.c - model.Parameters.SRadius; rad_coord.c <= center_coord.c+model.Parameters.SRadius; rad_coord.c++ {
					// here we count the number of signals for each cell

					// get strain at rad_coord
					strain_at_rad := model.CellStrain(rad_coord.ToroidCoordinates(model.Parameters.BoardSize))

					// the allele of signal of the strain at rad_coord
					signal_strain_at_rad := s4strain[strain_at_rad]

					// add one signal at center_coord of the signal allele from rad_coord
					model.AddToCellSignalNum(center_coord, signal_strain_at_rad, 1)
				}
			}
		}
	}
}

// TODO this comment sucks. initialize all the data samples
func (model *Model) initDataSamples() {
	model.initDataSamplesSnapshots()
	model.initDataSamplesFrequencies()
	model.initDataSamplesNeighborhoodFrequencies()
}

// Initialize the board snapshots samples
func (model *Model) initDataSamplesSnapshots() {
	if model.Settings.SnapshotsSampleNum != 0 {
		if model.Parameters.Generations%model.Settings.SnapshotsSampleNum == 0 {
			// the case in which the last snapshot is the same as the last generation
			model.DataSamples.Snapshots = make([]Snapshot, model.Settings.SnapshotsSampleNum)
		} else {
			// the case in which the last snapshot isn't the same as the last generation
			model.DataSamples.Snapshots = make([]Snapshot, model.Settings.SnapshotsSampleNum+1)
		}
		for sample_i := range model.DataSamples.Snapshots {
			model.DataSamples.Snapshots[sample_i].Data = make([][]int, model.Parameters.BoardSize)
			for row := range model.DataSamples.Snapshots[sample_i].Data {
				model.DataSamples.Snapshots[sample_i].Data[row] = make([]int, model.Parameters.BoardSize)
			}
			//fmt.Println(sample_i, model.DataSamples.Snapshots[sample_i])
		}
		model.DataSamples.Snapshots = model.DataSamples.Snapshots[0:1]
	}
}

// Initialize the strain frequencies samples
func (model *Model) initDataSamplesFrequencies() {
	if model.Settings.FrequenciesSampleNum != 0 {
		if model.Parameters.Generations%model.Settings.FrequenciesSampleNum == 0 {
			// the case in which the last sample is the same as the last generation
			model.DataSamples.Frequencies = make([]Frequency, model.Settings.FrequenciesSampleNum)
		} else {
			// the case in which the last sample isn't the same as the last generation
			model.DataSamples.Frequencies = make([]Frequency, model.Settings.FrequenciesSampleNum+1)
		}
		for sample_i := range model.DataSamples.Frequencies {
			model.DataSamples.Frequencies[sample_i].Data = make([]int, 8)
		}
		model.DataSamples.Frequencies = model.DataSamples.Frequencies[0:1]
	}
}

// Initialize the neighbors frequencies samples
func (model *Model) initDataSamplesNeighborhoodFrequencies() {
	if model.Settings.NeighborhoodFrequenciesSampleNum != 0 {
		if model.Parameters.Generations%model.Settings.NeighborhoodFrequenciesSampleNum == 0 {
			// the case in which the last sample is the same as the last generation
			model.DataSamples.NeighborsFrequencies = make([]NeighborsFrequency, model.Settings.NeighborhoodFrequenciesSampleNum)
		} else {
			// the case in which the last sample isn't the same as the last generation
			model.DataSamples.NeighborsFrequencies = make([]NeighborsFrequency, model.Settings.NeighborhoodFrequenciesSampleNum+1)
		}
		for sample_i := range model.DataSamples.NeighborsFrequencies {
			data := make([][]int, 8)
			// for each strain we'll count how many strains are around it.
			for strain_i := range data {
				data[strain_i] = make([]int, 8)
			}
			model.DataSamples.NeighborsFrequencies[sample_i].Data = data
		}
		model.DataSamples.NeighborsFrequencies = model.DataSamples.NeighborsFrequencies[0:1]
	}
}
{'fraction_non_alphanumeric': 0.10865281261196703, 'fraction_numerical': 0.005463991400931565, 'mean_word_length': 4.491883915395967, 'pattern_counts': {'":': 0, '<': 15, '<?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': '2631426', 'n_tokens_mistral': 4126, 'n_tokens_neox': 3674, 'n_words': 805}