-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicConfigure.cpp
More file actions
executable file
·188 lines (170 loc) · 4.39 KB
/
BasicConfigure.cpp
File metadata and controls
executable file
·188 lines (170 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include "BasicConfigure.h"
BasicConfiguration::BasicConfiguration()
{
mHostIp = "192.168.0.66";
mHostPort = 3100;
mMyTeamName = "AmoiensisNQ";
//mMyTeamName = "Test";
mMyPlayerNo = 1;
mMyAgentConf = "agentConf.conf";
mMyFormation = "formation.conf";
mWorldModel = "worldModel.conf";
mDelayTime = 0.0015f;
}
BasicConfiguration::~BasicConfiguration()
{
}
bool BasicConfiguration::ConfigureArguments(int argc, char* argv[])
{
char * str;
for( int i = 1 ; i < argc ; i = i + 2 )
{
// help is only option that does not have to have an argument
if( i + 1 >= argc && strncmp( argv[i], "-help", 3 ) != 0 )
{
//cout << "Need argument for option: " << argv[i] << endl;
exit(0);
}
else if( strncmp( argv[i], "-help", 3 ) == 0 )
{
PrintOptions();
exit(0);
}
// read a command option
if( argv[i][0] == '-' && strlen( argv[i] ) > 1)
{
switch( argv[i][1] )
{
case 'h': // host server
if((i + 1) > argc)
{
//cout << "Need argument for option: " << argv[i] << endl;
return false;
}
else
{
mHostIp = argv[i+1];
}
break;
case 'p': // port
if((i + 1) > argc)
{
cout << "Need argument for option: " << argv[i] << endl;
return false;
}
else
{
sscanf(argv[i+1], "%d", &mHostPort);
}
break;
case 'n': // number
if( (i + 1) > argc )
{
cout << "Need argument for option: " << argv[i] << endl;
return false;
}
else
{
sscanf(argv[i+1], "%d", &mMyPlayerNo);
}
break;
case 't': // teamname
if( (i + 1) > argc )
{
cout << "Need argument for option: " << argv[i] << endl;
return false;
}
else
{
mMyTeamName = &argv[i+1][0];
}
break;
case 'f': // formation fomrations file
if((i + 1) > argc)
{
cout << "Need argument for option: " << argv[i] << endl;
return false;
}
else
{
mMyFormation = argv[i+1];
}
break;
case 'a': // agent fomrations file
if((i + 1) > argc)
{
cout << "Need argument for option: " << argv[i] << endl;
return false;
}
else
{
mMyAgentConf = argv[i+1];
}
break;
case 'w':
if((i + 1) > argc)
{
cout << "Need argument for option: " << argv[i] << endl;
return false;
}
else
{
mWorldModel = argv[i+1];
}
break;
case 'd':
if((i + 1) > argc)
{
cout<< "Need argument for option: " << argv[i] << endl;
return false;
}
else
{
sscanf(argv[i+1], "%f", &mDelayTime);
}
break;
default:
cout<<" Unknown Argument " << argv[i] << endl;
}
}
}
/* if( mMyPlayerNo == 3 )
{
mMyPlayerNo = 9;
}
else if( mMyPlayerNo == 4 )
{
mMyPlayerNo = 10;
}*/
cout<< "BasicConfiguration " << mMyPlayerNo << endl;
PrintInput();
return true;
}
void BasicConfiguration::PrintOptions()
{
cout<< endl;
cout<< " usage: AmoiensisNQ [-param_name param_value] " << endl;
cout<< " " << endl;
cout<< " -h (host) : Specify the server host to connect " << endl;
cout<< " -p (port) : Specify the server port to connect " << endl;
cout<< " -n (number) : Specify the agents number in game " << endl;
cout<< " -t (team) : Specify the team name of agent " << endl;
cout<< " -d (delaytime) : Specify the delay time configuration " << endl;
cout<< " -a (agentconf) : Specify the agent configuration " << endl;
cout<< " -f (formation) : Specify the formation configuration " << endl;
cout<< " -w (worldmodel) : Specify the worldmodel configuration" << endl << endl;
}
//For test
void BasicConfiguration::PrintInput()
{
cout<< endl;
cout<< " Options Input " << endl;
cout<< " -hostip : " << mHostIp << endl;
cout<< " -port : " << mHostPort << endl;
cout<< " -number : " << mMyPlayerNo << endl;
cout<< " -teamname : " << mMyTeamName << endl;
cout<< " -delaytime : " << mDelayTime << endl;
cout<< " -agentconf : " << mMyAgentConf << endl;
cout<< " -formation : " << mMyFormation << endl;
cout<< " -worldmodel : " << mWorldModel << endl << endl;
}