001    /*
002     * SimuCS - Simulator to use with Classifier Systems 
003     * MSc project - Oxford University 
004     * by Benoit Isaac - Summer 2005
005     */
006    
007    package simuLCS;
008    import java.awt.Dimension;
009    
010    import simuLCS.graphics.*;
011    
012    /**
013     * Main class - If a command line argument is given, the program doesn't start the GUI.
014     * @author Benoit
015     * 
016     */
017    public class Application {
018    
019            public static void main(String[] args) {
020    
021                    Utils utils = new Utils();
022    
023                    System.out.println("Constructing simulation...");
024                    Simulation simu = new Simulation(utils);
025                    System.out.println("Constructing simulation...DONE");
026                    System.out.println("Constructing agents...");
027                    simu.create(1);
028                    System.out.println("Constructing agents...DONE");
029                    Config.setPRINT_MODE(0);
030    
031                    if (args.length == 0) {
032                            // no arguments, we have the display by default
033                            System.out.println("Constructing window...");
034                            G_MainWindow window = G_MainWindow.getInstance(simu, utils);
035                            System.out.println("Constructing window...DONE");
036                            window.setSize(new Dimension(1024, 710));
037                            System.out.println("Showing window...");
038                            window.show();
039                            window.launch();
040                            System.out.println("Showing window...DONE");
041                            window.linkSimulation(simu);
042    
043                            simu.linkToGraphics(window);
044                            simu.launchUpdateThread(3000);
045    
046                            simu.createAnimation();
047                            simu.run();
048    
049                    } else {
050                            simu.createAnimation();
051                            simu.run();
052    
053                            String filename;
054                            filename = args[0];
055                            if (filename.equals(""))
056                                    filename = "NoName";
057    
058                            simu.setFileBaseForPlotting(filename);
059                            simu.setFileBaseForSeveralPlotting(filename);
060                            simu.setNbOfRuns(3);
061                            simu.setMaximumTimeSteps(50000);
062                            System.out.println(
063                                    simu.getNbOfRuns()
064                                            + " experiments will be run, until "
065                                            + simu.getMaxTimeSteps()
066                                            + " time steps. Please wait until they are finished.");
067    
068                            simu.start();
069                    }
070    
071            }
072    }