
public class Simulation {
	
	private static int[][] connections = new int[][] {  {10,11}, {11,12}, {12,13}, {13,10} };
	private static int num = 4;
	
	public static void main(String[] args) {
		for (int i = 0; i < num; i++) {
			Node n = new Node();
			Network.getNetwork().addNode(n);
		}
		
		for (int con = 0; con < connections.length; con++) {
			int[] pair = connections[con];
			Node n1 = Network.getNetwork().getNode(pair[0]);
			Node n2 = Network.getNetwork().getNode(pair[1]);
			n1.addNeighbor(n2);
			n2.addNeighbor(n1);
		}
		
		Network.getNetwork().startNodes();
		
		try {
			for (;;) {
				Thread.sleep(2000); //run simulation for five seconds
				if (System.currentTimeMillis() - Network.getNetwork().getLastChange() > 1000) {
					Network.getNetwork().stopAllNodes();
					break;
				} else {
					System.out.println("Tick");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		Network.getNetwork().printAllNodes();
		System.out.println("Consistent: " + Network.getNetwork().consistent());
		Network.getNetwork().printMessages(System.out);
	}
	
	//A node's guid is consistent if that node is in/out of the core and everyone (the neighbors) knows it
	

}
