<commit_before>package fi.paivola.mapserver;

import fi.paivola.mapserver.core.Event;
import fi.paivola.mapserver.core.ExtensionModel;
import fi.paivola.mapserver.core.GameManager;
import fi.paivola.mapserver.core.GameThread;
import fi.paivola.mapserver.core.Model;
import fi.paivola.mapserver.core.SettingsParser;
import fi.paivola.mapserver.core.TestcaseRunner;
import fi.paivola.mapserver.core.WSServer;
import fi.paivola.mapserver.core.setting.*;
import fi.paivola.mapserver.utils.LatLng;
import fi.paivola.mapserver.core.setting.SettingMaster;
import fi.paivola.mapserver.utils.CSVDumper;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import java.net.UnknownHostException;
import java.util.logging.LogManager;
import org.json.simple.parser.ParseException;

public class App {

    static final boolean profilingRun = false;
    static DiagnosticsWrapper dw; // for the wrapping of stupid debug stuff

    public static void main(String[] args) throws UnknownHostException, IOException, ParseException, InterruptedException, Exception {
        InputStream stream = null;
        if (args.length > 0) {
            File file = new File(args[0]);
            stream = new FileInputStream(file);
            TestcaseRunner tr = new TestcaseRunner(stream);
            return;
        } else {
            stream = App.class.getClassLoader().getResourceAsStream("default_testcase.csv");
        }

        SettingsParser.parse();

        if (profilingRun) { // For profiling

            LogManager.getLogManager().reset();

            for (int i = 0; i < 1000; i++) {
                runTest();
            }

        } else {

            WSServer ws = new WSServer(parseInt(SettingsParser.settings.get("websocket_port").toString()));
            ws.start();

            BufferedReader sysin = new BufferedReader(new InputStreamReader(System.in));
            printHelp();
            mainloop:
            while (true) {
                String in = sysin.readLine();
                switch (in) {
                    case "q":
                    case "quit":
                    case "e":
                    case "exit":
                        ws.stop();
                        break mainloop;
                    case "t":
                    case "test":
                        ws.stop();
                        runTest();
                        break mainloop;
                    case "f":
                        ws.stop();
                        TestcaseRunner tr = new TestcaseRunner(stream);
                        break mainloop;
                    case "h":
                    case "help":
                        printHelp();
                        break;
                    default:
                        System.out.println("Unknown command (" + in + ")");
                        printHelp();
                        break;
                }
            }
        }
    }

    static void printHelp() {
        System.out.println("q|e|quit|exit   - Quits the program\n"
                + "t|test          - Run the test function\n"
                + "f               - Run the TestcaseRunner\n"
                + "h|help          - Display this help");
    }

    /**
     * This function can be used for testing your own models. Please modify
     * this!
     */ 
    static void runTest() {
        dw = DiagnosticsWrapper.getInstance();
        dw.setDebugOutput( true );

        // How many ticks? Each one is a week.
        int simulationDurationTicks = (int) Math.floor(Constants.WEEKS_IN_YEAR * 20);
        // print debug-info on all parameters moving between models
        boolean printFrameData = false;
        GameThread one = new GameThread(simulationDurationTicks, printFrameData);
        GameManager gm = one.game;
        
        dw.addGameThread(one); // for debugging purposes

        // globalit
        gm.createModel("Weather");<commit_msg>Set some debug-output-variables to previous values.<commit_after>package fi.paivola.mapserver;

import fi.paivola.mapserver.core.Event;
import fi.paivola.mapserver.core.ExtensionModel;
import fi.paivola.mapserver.core.GameManager;
import fi.paivola.mapserver.core.GameThread;
import fi.paivola.mapserver.core.Model;
import fi.paivola.mapserver.core.SettingsParser;
import fi.paivola.mapserver.core.TestcaseRunner;
import fi.paivola.mapserver.core.WSServer;
import fi.paivola.mapserver.core.setting.*;
import fi.paivola.mapserver.utils.LatLng;
import fi.paivola.mapserver.core.setting.SettingMaster;
import fi.paivola.mapserver.utils.CSVDumper;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import java.net.UnknownHostException;
import java.util.logging.LogManager;
import org.json.simple.parser.ParseException;

public class App {

    static final boolean profilingRun = false;
    static DiagnosticsWrapper dw; // for the wrapping of stupid debug stuff

    public static void main(String[] args) throws UnknownHostException, IOException, ParseException, InterruptedException, Exception {
        InputStream stream = null;
        if (args.length > 0) {
            File file = new File(args[0]);
            stream = new FileInputStream(file);
            TestcaseRunner tr = new TestcaseRunner(stream);
            return;
        } else {
            stream = App.class.getClassLoader().getResourceAsStream("default_testcase.csv");
        }

        SettingsParser.parse();

        if (profilingRun) { // For profiling

            LogManager.getLogManager().reset();

            for (int i = 0; i < 1000; i++) {
                runTest();
            }

        } else {

            WSServer ws = new WSServer(parseInt(SettingsParser.settings.get("websocket_port").toString()));
            ws.start();

            BufferedReader sysin = new BufferedReader(new InputStreamReader(System.in));
            printHelp();
            mainloop:
            while (true) {
                String in = sysin.readLine();
                switch (in) {
                    case "q":
                    case "quit":
                    case "e":
                    case "exit":
                        ws.stop();
                        break mainloop;
                    case "t":
                    case "test":
                        ws.stop();
                        runTest();
                        break mainloop;
                    case "f":
                        ws.stop();
                        TestcaseRunner tr = new TestcaseRunner(stream);
                        break mainloop;
                    case "h":
                    case "help":
                        printHelp();
                        break;
                    default:
                        System.out.println("Unknown command (" + in + ")");
                        printHelp();
                        break;
                }
            }
        }
    }

    static void printHelp() {
        System.out.println("q|e|quit|exit   - Quits the program\n"
                + "t|test          - Run the test function\n"
                + "f               - Run the TestcaseRunner\n"
                + "h|help          - Display this help");
    }

    /**
     * This function can be used for testing your own models. Please modify
     * this!
     */ 
    static void runTest() {
        dw = DiagnosticsWrapper.getInstance();
        dw.setDebugOutput( false );

        // How many ticks? Each one is a week.
        int simulationDurationTicks = (int) Math.floor(Constants.WEEKS_IN_YEAR * 20);
        // print debug-info on all parameters moving between models
        boolean printFrameData = true;
        GameThread one = new GameThread(simulationDurationTicks, printFrameData);
        GameManager gm = one.game;
        
        dw.addGameThread(one); // for debugging purposes

        // globalit
        gm.createModel("Weather");
{'fraction_non_alphanumeric': 0.09689638318670576, 'fraction_numerical': 0.0021994134897360706, 'mean_word_length': 1.7075752563678466, 'pattern_counts': {'":': 18, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3423411', 'n_tokens_mistral': 2208, 'n_tokens_neox': 2069, 'n_words': 502}