<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.rlcommunity.critterbot.gui;

import java.util.List;

import org.rlcommunity.critterbot.javadrops.clients.DiscoInterfaceServer;
import org.rlcommunity.critterbot.javadrops.drops.CritterControlDrop;
import org.rlcommunity.critterbot.javadrops.drops.CritterRewardDrop;
import org.rlcommunity.critterbot.javadrops.drops.CritterStateDrop;
import org.rlcommunity.critterbot.javadrops.drops.DropInterface;
import org.rlcommunity.critterbot.javadrops.drops.SimulatorDrop;
/**
 *
 * @author critterbot
 */
public class CritterVizMain {
    public static final int critterVisPort = 3444;
    
    public CritterStateDrop currentState;
    
    private CritterViz gui;
    
    public CritterVizMain() {
        
        currentState = new CritterStateDrop();
        // Create a TCP server to talk with Disco
        DiscoInterfaceServer discoServer = new DiscoInterfaceServer(critterVisPort);
        // Start its thread
        discoServer.start();

        // Create the central drop interface
        DropInterface dropInterface = new DropInterface();

        // Add the disco server to the central drop interface
        dropInterface.addClient(discoServer);

        // Create a new agent
        //CritterVizMain me = new CritterVizMain();
        runGUI(currentState,dropInterface);
        //me.runGUI(me.currentState,dropInterface);
        
        while (true) {
            // Receive drops from the simulator
            List<SimulatorDrop> drops = dropInterface.receiveDrops();

            // Pass them on to the agent (this may be an empty list)
            for (SimulatorDrop d : drops) {
                observeDrop(d);
            }
          
            // Sleep for a little while to give the processor a break
            try {
                Thread.sleep(10);
            } catch (InterruptedException ex) {
            }
        }
    }
    
    private void runGUI(final CritterStateDrop state, final DropInterface di) {<commit_msg>Changed CritterVizMain to be a client rather than a server.<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.rlcommunity.critterbot.gui;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;

import org.rlcommunity.critterbot.javadrops.clients.DiscoInterfaceClient;
import org.rlcommunity.critterbot.javadrops.drops.CritterControlDrop;
import org.rlcommunity.critterbot.javadrops.drops.CritterRewardDrop;
import org.rlcommunity.critterbot.javadrops.drops.CritterStateDrop;
import org.rlcommunity.critterbot.javadrops.drops.DropInterface;
import org.rlcommunity.critterbot.javadrops.drops.SimulatorDrop;
/**
 *
 * @author critterbot
 */
public class CritterVizMain {
    public static final int critterVizPort = 3444;
    public static final String critterVizHost = "localhost";
    public static final int dropQueueSize = 32;
    
    public CritterStateDrop currentState;
    
    private CritterViz gui;
    
    public CritterVizMain() {
        
        currentState = new CritterStateDrop();
        // Create a TCP server to talk with Disco
        InetAddress netAddr = null;
        try {
        	netAddr = InetAddress.getByName(critterVizHost);
        }
        catch (UnknownHostException e) {
        	System.err.println("Unknown hostname.");
        	System.exit(1);
        }
        DiscoInterfaceClient discoClient = new DiscoInterfaceClient(
        		netAddr, critterVizPort, dropQueueSize);
        // Start its thread
        discoClient.start();

        // Create the central drop interface
        DropInterface dropInterface = new DropInterface();

        // Add the disco server to the central drop interface
        dropInterface.addClient(discoClient);

        // Create a new agent
        //CritterVizMain me = new CritterVizMain();
        runGUI(currentState,dropInterface);
        //me.runGUI(me.currentState,dropInterface);
        
        while (true) {
            // Receive drops from the simulator
            List<SimulatorDrop> drops = dropInterface.receiveDrops();

            // Pass them on to the agent (this may be an empty list)
            for (SimulatorDrop d : drops) {
                observeDrop(d);
            }
          
            // Sleep for a little while to give the processor a break
            try {
                Thread.sleep(10);
            } catch (InterruptedException ex) {
            }
        }
    }
    
    private void runGUI(final CritterStateDrop state, final DropInterface di) {
{'fraction_non_alphanumeric': 0.07769907705516205, 'fraction_numerical': 0.003219575016097875, 'mean_word_length': 2.4932533733133435, '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': '2978855', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1277, 'n_words': 338}