📄 prefs.cpp
字号:
/*
travelsalesman by Kai Schutte (skander@skander.com)
started Feb 8th 2000, file: prefs.cpp
personal research for evolutionary computation (IEEE Spectrum Magazine, Feb '00)
http://www.webpatterns.net/
*/
/*
Copyright (C) 2000 Kai Schutte
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "prefs.h"
#include <string.h>
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
prefs::prefs() {
xaxis = 100; //setting defaults.
yaxis = 100;
num_cities = 100;
filename = "map";
makenew = false;
extout = false;
survival = 10;
population = 1000;
progress = 5;
generations = 10;
}
void prefs::read_args(int argc, char *argv[]) {
for (int t=1; t < argc;t++) { // parsing arguments.
if (!(strncmp(argv[t], "-x", 2)))
xaxis = (double)atoi(&argv[t][2]);
else if (!(strncmp(argv[t], "-y", 2)))
yaxis = (double)atoi(&argv[t][2]);
else if (!(strncmp(argv[t], "-c", 2)))
num_cities = atoi(&argv[t][2]);
else if (!(strncmp(argv[t], "-f", 2)))
filename = &argv[t][2];
else if (!(strncmp(argv[t], "-n", 2)))
makenew = true;
else if (!(strncmp(argv[t], "-e", 2)))
extout = true;
else if (!(strncmp(argv[t], "-s", 2)))
survival = atoi(&argv[t][2]);
else if (!(strncmp(argv[t], "-p", 2)))
population = atoi(&argv[t][2]);
else if (!(strncmp(argv[t], "-r", 2)))
progress = atoi(&argv[t][2]);
else if (!(strncmp(argv[t], "-g", 2)))
generations = atoi(&argv[t][2]);
else {
cerr << "fatal: Wrong Arguments\n";
exit(1);
}
}
}
void prefs::print_args() {
cout << endl << "Settings are:" << endl;
cout << "| Xaxis | Yaxis | num_cities | filename | makenew |" << endl;
cout << "| " << setw(10) << xaxis << " |" <<setw(10) << yaxis << " |"
<< setw(11) << num_cities << " |" << setw(11) << filename << " |"
<< setw(12) << makenew << " |" << endl;
cout << "| extout | survival | population | progress | generations |" << endl;
cout << "| " << setw(10) << extout << " |" <<setw(10) << survival << " |"
<< setw(11) << population << " |" << setw(11) << progress << " |"
<< setw(12) << generations << " |" << endl << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -