1
2 /* "Species" - a CoreWars evolver. Copyright (C) 2003 'Varfar'
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 1, or (at your option) any later
7 * version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #include "species.hpp"
20
21 #ifndef _WIN32
22 #include <sys/time.h>
23 #include <sys/resource.h>
24 #endif
25
26 #include <iostream>
27
28 using namespace std;
29
30 /***** main program entry point ********************/
31
main(int,char)32 int main(int /*argc*/,char /***args*/) {
33 CKingdom kingdom;
34
35 #ifndef _WIN32
36 setpriority(PRIO_PROCESS,0,20); // very low background task priority
37 #endif
38
39 try {
40 cout << "Species " << VERSION << ": a corewars evolver program (c) Will Varfar, 2003" << endl;
41
42 /* // distribution check
43 ini.seek("kingdom");
44 CDistribution operands("operands",0,8000);
45 operands.read_ini(ini);
46 for(int i=0; i<100; i++)
47 cout << operands.rnd() << ',';
48 cout << endl;
49 return 0;*/
50
51 kingdom.load();
52 for(;;) { // forever
53 kingdom.fight();
54 }
55 } catch(CSpeciesError *se) {
56 cerr << se->desc() << endl;
57 delete se;
58 return 1;
59 } catch(KeyValuePair::KVP_ERROR err) {
60 cerr << "INI_PARSER_ERROR " << KeyValuePair::ERROR_MSG(err) << endl;
61 return 4;
62 } catch(...) {
63 cerr << "an unspecified error occurred" << endl;
64 return 2;
65 }
66 return 0;
67 }
68