<commit_before>/*******************************************************************************
 * Copyright (c) 2016 <NAME> - github.com/shpralex
 * This program and the accompanying materials
 * are made available under the terms of the The MIT License (MIT)
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *******************************************************************************/
package com.sproutlife.model;

import java.awt.Point;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

import com.sproutlife.model.echosystem.Echosystem;
import com.sproutlife.model.echosystem.Mutation;
import com.sproutlife.model.echosystem.Organism;

public class Stats {
    GameModel gameModel;
    
    public double avgAge;
    public double avgLifespan;
    public int avgMaxLifespan;
    
    double avgSize = 0;
    double avgMaxSize = 0;
    double avgTerritory = 0;
    int[] maxTerriroty = new int[100];
    int sumMaxTerritory = 0;
    
    double avgTotalMutations = 0;
    double avgRecentMutations = 0;
    
    public int c1, c2, c3, c4;
    
    public int born, die1, die2, stayed;
    public int gridSize;
    
    public int mutationCount;
    public int mutationMiss;
    
    public Mutation freqMutation;
    public int freqMuteFreq =0;
    
    public int infectedCount =0;
    
    public int[] childEnergy = new int[100];
    public int[] sproutNumber = new int[100];
    
    
    public Stats(GameModel gameModel) {
        this.gameModel = gameModel;
    }
    
    private Echosystem getEchosystem() {
        return gameModel.getEchosystem();
    }
    
    private int getTime() {
        return gameModel.getTime();
    }
    
    public String getDisplayText() {
        String text ="";
        text += "Game Time: "+getTime();
        text += "\n";
        text += "\n";
        text += "Population (Organism #): "+getEchosystem().getOrganisms().size();
        text += "\n";
        text += "\n";
        text += "Average Age: "+String.format("%.1f", avgAge);
        text += "\n";
        text += "Average Lifespan: "+String.format("%.1f", avgLifespan);
        text += "\n";
        text += "Average Max Lifespan: "+String.format("%.1f", avgMaxLifespan/10.0+1);
        text += "\n";
        text += "\n";
        text += "Average Cell #: "+String.format("%.1f", avgSize);
        text += "\n";
        text += "Average Territory: "+String.format("%.1f", avgTerritory);
        text += "\n";       
        text += "Average Max Cell#: "+String.format("%.0f", avgMaxSize);
        text += "\n";
        text += "Average Max Territory: "+(sumMaxTerritory/ getEchosystem().getOrganisms().size());
        text += "\n";
        text += "\n";
        text += "Average Mutation #: "+String.format("%.1f", avgTotalMutations);
        
        return text;
        
    }
    
    public void update() {
        updateAvgSize();
        updateAvgLifespan();
        updateAvgMutations();
    }
    
    public void printInfected() {
        System.out.print(getTime() + " Org count "+getEchosystem().getOrganisms().size());
        System.out.print(" Avg Life  " + avgMaxLifespan);
        System.out.println(" Infected born "+infectedCount);<commit_msg>Divide by 0 fix<commit_after>/*******************************************************************************
 * Copyright (c) 2016 <NAME> - github.com/shpralex
 * This program and the accompanying materials
 * are made available under the terms of the The MIT License (MIT)
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *******************************************************************************/
package com.sproutlife.model;

import java.awt.Point;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

import com.sproutlife.model.echosystem.Echosystem;
import com.sproutlife.model.echosystem.Mutation;
import com.sproutlife.model.echosystem.Organism;

public class Stats {
    GameModel gameModel;
    
    public double avgAge;
    public double avgLifespan;
    public int avgMaxLifespan;
    
    double avgSize = 0;
    double avgMaxSize = 0;
    double avgTerritory = 0;
    int[] maxTerriroty = new int[100];
    int sumMaxTerritory = 0;
    
    double avgTotalMutations = 0;
    double avgRecentMutations = 0;
    
    public int c1, c2, c3, c4;
    
    public int born, die1, die2, stayed;
    public int gridSize;
    
    public int mutationCount;
    public int mutationMiss;
    
    public Mutation freqMutation;
    public int freqMuteFreq =0;
    
    public int infectedCount =0;
    
    public int[] childEnergy = new int[100];
    public int[] sproutNumber = new int[100];
    
    
    public Stats(GameModel gameModel) {
        this.gameModel = gameModel;
    }
    
    private Echosystem getEchosystem() {
        return gameModel.getEchosystem();
    }
    
    private int getTime() {
        return gameModel.getTime();
    }
    
    public String getDisplayText() {
        String text ="";
        text += "Game Time: "+getTime();
        text += "\n";
        text += "\n";
        text += "Population (Organism #): "+getEchosystem().getOrganisms().size();
        text += "\n";
        text += "\n";
        text += "Average Age: "+String.format("%.1f", avgAge);
        text += "\n";
        text += "Average Lifespan: "+String.format("%.1f", avgLifespan);
        text += "\n";
        text += "Average Max Lifespan: "+String.format("%.1f", avgMaxLifespan/10.0+1);
        text += "\n";
        text += "\n";
        text += "Average Cell #: "+String.format("%.1f", avgSize);
        text += "\n";
        text += "Average Territory: "+String.format("%.1f", avgTerritory);
        text += "\n";       
        text += "Average Max Cell#: "+String.format("%.0f", avgMaxSize);
        text += "\n";
        text += "Average Max Territory: "+(sumMaxTerritory/ Math.max(1, getEchosystem().getOrganisms().size()));
        text += "\n";
        text += "\n";
        text += "Average Mutation #: "+String.format("%.1f", avgTotalMutations);
        
        return text;
        
    }
    
    public void update() {
        updateAvgSize();
        updateAvgLifespan();
        updateAvgMutations();
    }
    
    public void printInfected() {
        System.out.print(getTime() + " Org count "+getEchosystem().getOrganisms().size());
        System.out.print(" Avg Life  " + avgMaxLifespan);
        System.out.println(" Infected born "+infectedCount);
{'fraction_non_alphanumeric': 0.1750719369983341, 'fraction_numerical': 0.011812812358019082, 'mean_word_length': 2.6365638766519823, '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': '3500845', 'n_tokens_mistral': 2064, 'n_tokens_neox': 1949, 'n_words': 519}