public static void main(String[] args) throws IOException {

		CommClient client;
		
		if (args.length > 0) {
			client = new CommClient(args[0]);
		}
		else {
			client = new CommClient("13");
		}
		String robotInput;
		
		GUIBoard board = new GUIBoard();
		board.setVisible(true);
		board.repaint();
		
		while ((robotInput = client.getNextLine()) != null) {
			
			System.out.println("received: " + robotInput);
			
			if (robotInput.startsWith("Robot moved to ")) {
				double x = 2 * Double.parseDouble(robotInput.substring(robotInput.indexOf("(") + 1, robotInput.indexOf(",")));
				double y = 2 * Double.parseDouble(robotInput.substring(robotInput.indexOf(",") + 1, robotInput.indexOf(")")));
				double direction = Double.parseDouble(robotInput.substring(robotInput.indexOf("[") + 1, robotInput.indexOf("]")));
				board.updateRobot(new Point2D.Double(x,y), direction);
				System.out.println("robot position updated");
			}
			
			if(robotInput.startsWith("Hit wall at ")){
				double x = 2 * Double.parseDouble(robotInput.substring(robotInput.indexOf("(") + 1, robotInput.indexOf(",")));
				double y = 2 * Double.parseDouble(robotInput.substring(robotInput.indexOf(",") + 1, robotInput.indexOf(")")));
				board.drawObject(new GuiBlock(x, y));
				System.out.println("added block");
			}
			
			if (robotInput.startsWith("Green pompom at ")) {
				double x = 2 * Double.parseDouble(robotInput.substring(robotInput.indexOf("(") + 1, robotInput.indexOf(",")));
				double y = 2 * Double.parseDouble(robotInput.substring(robotInput.indexOf(",") + 1, robotInput.indexOf(")")));
				//rDemo.updateRobot(new Point2D.Double(x,y));
				board.drawObject(new GuiPingPong(x,y, Color.GREEN));
				System.out.println("added green pompom");
			}
			if (robotInput.startsWith("Pink pompom at ")) {
				double x = 2 * Double.parseDouble(robotInput.substring(robotInput.indexOf("(") + 1, robotInput.indexOf(",")));
				double y = 2 * Double.parseDouble(robotInput.substring(robotInput.indexOf(",") + 1, robotInput.indexOf(")")));
				//rDemo.updateRobot(new Point2D.Double(x,y));
				board.drawObject(new GuiPingPong(x,y, Color.PINK));
				System.out.println("added pink pompom");
			}
			if (robotInput.startsWith("Got pompom")){
				board.resetObjects();
			}
			
		}
		
		System.out.println("Robot probably disconnected");
		
		System.exit(0);
		
	}