public static void main(String[] args) throws Exception {
      boolean server = (args.length == 1 && args[0].compareTo("--server") == 0);
      String id = UUID.randomUUID().toString();

      Window window = new Window((server) ? "server" : "client");
      window.setVisible(true);

      Game game = new Game((server) ? SquareState.P1 : SquareState.P2);
      game.addGameListener(window);
      game.onStateUpdate();

      final NetworkController nc = (server) ? new NetworkServer(game, id) : new NetworkClient(game, id);
      nc.start();
      nc.joinGame();

      window.addBoardListener(nc);
      window.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent winEvt) {
            nc.quit();
         }
      });
   }