1 /*
2  *  primitive.cc
3  *  Avida
4  *
5  *  Copyright 1999-2011 Michigan State University. All rights reserved.
6  *
7  *
8  *  This file is part of Avida.
9  *
10  *  Avida is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
12  *
13  *  Avida is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public License along with Avida.
17  *  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #include "AvidaTools.h"
22 
23 #include "apto/core/FileSystem.h"
24 #include "avida/Avida.h"
25 #include "avida/util/CmdLine.h"
26 
27 #include "cAvidaConfig.h"
28 #include "cDefaultAnalyzeDriver.h"
29 #include "cDefaultRunDriver.h"
30 #include "cUserFeedback.h"
31 #include "cWorld.h"
32 
33 
main(int argc,char * argv[])34 int main(int argc, char * argv[])
35 {
36 
37   Avida::Initialize();
38 
39   cout << Avida::Version::Banner() << endl;
40 
41   // Initialize the configuration data...
42   cAvidaConfig* cfg = new cAvidaConfig();
43   Avida::Util::ProcessCmdLineArgs(argc, argv, cfg);
44 
45   cUserFeedback feedback;
46   cWorld* world = cWorld::Initialize(cfg, cString(Apto::FileSystem::GetCWD()), &feedback);
47 
48   for (int i = 0; i < feedback.GetNumMessages(); i++) {
49     switch (feedback.GetMessageType(i)) {
50       case cUserFeedback::UF_ERROR:    cerr << "error: "; break;
51       case cUserFeedback::UF_WARNING:  cerr << "warning: "; break;
52       default: break;
53     };
54     cerr << feedback.GetMessage(i) << endl;
55   }
56 
57   if (!world) return -1;
58 
59   const int rand_seed = world->GetConfig().RANDOM_SEED.Get();
60   cout << "Random Seed: " << rand_seed;
61   if (rand_seed != world->GetRandom().GetSeed()) cout << " -> " << world->GetRandom().GetSeed();
62   cout << endl;
63 
64   if (world->GetConfig().VERBOSITY.Get() > VERBOSE_NORMAL)
65     cout << "Data Directory: " << world->GetDataFileManager().GetTargetDir() << endl;
66 
67   cout << endl;
68 
69   if (world->GetConfig().ANALYZE_MODE.Get() > 0) {
70     (new cDefaultAnalyzeDriver(world, (world->GetConfig().ANALYZE_MODE.Get() == 2)))->Run();
71   } else {
72     (new cDefaultRunDriver(world))->Run();
73   }
74 
75   return 0;
76 }
77