package comp.hackbridge.viral;

import java.util.ArrayList;
import java.util.HashMap;


public class LocationState {
    private final int MAX_NODES = 1000; // TODO
    private final int array_capacity = 100;
    private final ArrayList<ArrayList<Double>> state; //2D state array
    private HashMap<Long, Node> nodes;  // Map from node ID to Node
    private HashMap<Long, Integer> state_position;  // Map from node ID to array pos

    private int num_nodes = 0;

    public LocationState() {
        state = new ArrayList<ArrayList<Double>>();
        nodes = new HashMap<Long, Node>();
        state_position = new HashMap<Long, Integer>();
        for (int i = 0; i < array_capacity; ++i) {
            state.add(new ArrayList<Double>());
        }
    }

    /**
     * Called upon addition of a new node.
     */
    public StartMessage OnConnect() {
        return null;
    }

    /**
     * Called upon connection of an existing node.
     * @param id
     * @return
     */
    public StartMessage OnConnect(long id) {

        if (num_nodes > array_capacity) {

        }
        System.out.println("Connected");
        return null;
    }

    /**
     * Called upon disconnection of an existing node.
     */
    public boolean OnDisconnect(long id) {
        System.out.println("Disonnected");
        return false;
    }

    /**
     * @param nodeID
     */
    public void OnLocationChange(long nodeID) {
        System.out.println("Location Changed");
    }

}

@@ -448,21 +448,277 @@
 nt n
-um_nodes = 0;
+ode_ctr = 0;  // Counts nodes to add to position%0A%0A    private long num_nodes = 0;%0A%0A    // TODO: move to separate class perhaps.%0A    // TODO: tune parameters.%0A    private final double INITIAL_INFECTED_PERC = 0.05;%0A    private final double INITIAL_AWARENESS_PERC = 0.05;%0A
 %0A%0A  
@@ -1029,109 +1029,1030 @@
   * 
-Called upon addition of a new node.%0A     */%0A    public StartMessage OnConnect() %7B%0A        return null
+Default: (0.0, 1.0)%0A     * @return%0A     */%0A    private double GetRandomNumber(double max) %7B%0A        return Math.random() * max;%0A    %7D%0A%0A    private double GetRandomNumber() %7B%0A        return Math.random();%0A    %7D%0A%0A    /**%0A     * Called upon addition of a new node.%0A     */%0A    public StartMessage OnConnect() %7B%0A        double rand_aware = GetRandomNumber(1.0);%0A        double rand_physical = GetRandomNumber(1.0);%0A%0A        Node new_node = new Node(%0A                GetRandomNumber() %3C INITIAL_INFECTED_PERC ?%0A                        PhysicalState.INFECTED : PhysicalState.SUSCEPTIBLE,%0A                GetRandomNumber() %3C INITIAL_AWARENESS_PERC ?%0A                        AwarenessState.AWARE : AwarenessState.UNAWARE);%0A        nodes.put(new_node.getID(), new_node);%0A        state_position.put(new_node.getID(), node_ctr);%0A        node_ctr++;%0A%0A%0A%0A        // TODO: random factor for susceptible, infected%0A        return new StartMessage(new_node.getID(),%0A                new_node.getPhysicalState(), new_node.getAwarenessState())
 ;%0A  

Update LocationState OnConnect