replace the observer pattern with a simple update function
[aco.git] / protoas / AntMain.java
blobb65e7759d9203b85c9a4ae7f6f3c6058abe55294
1 package protoas;
3 import java.io.IOException;
5 class AntMain {
7 public static void main(String[] args) {
8 try {
10 Graph graph;
11 Environment env;
12 int iterations = 0, guisize = 0;
14 try {
15 iterations = Integer.parseInt(args[0]);
16 } catch (Exception e) {
17 System.exit(1);
20 if (args.length == 2) {
21 try {
22 guisize = Integer.parseInt(args[1]);
23 } catch (Exception e) { }
25 if (guisize == 0) {
26 graph = new Graph(args[1]);
27 } else {
28 graph = Graph.sampleGraph();
30 env = new Environment(iterations, graph);
32 env.run();
33 } else if (args.length == 3) {
35 guisize = Integer.parseInt(args[1]);
36 graph = new Graph(args[2]);
37 env = new Environment(iterations, guisize, graph);
39 env.run();
40 } else {
41 System.exit(1);
44 System.out.print("Computation finished..");
45 /* wait for a keypress before exit */
46 System.in.read();
48 } catch (IOException e) {
49 System.out.println(e.toString() + "(" + e.getClass() + "): " + e);
52 System.exit(0);