aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index 36f5580..30002a8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,6 +4,7 @@
#include <string>
#include <unordered_map>
#include <cstdlib>
+#include <array>
#include <cctype>
#include <cassert>
#include <sys/time.h>
@@ -215,14 +216,32 @@ int main(int argc,char **argv){
World world;
vector<Team> teams;
- for(int i=1;i<argc;i++){
+
+ bool opt_pos = false;
+ vector<array<int,2>> positions; // TODO: use pair?
+
+ int k = 1; // Increase past options;
+
+ if(string(argv[k]) == "-p") {
+ opt_pos = true;
+ k++;
+ }
+
+ for(int i=k;i<argc;i++){ // Start after options
ifstream f(argv[i]);
assert(f);
teams.push_back(assemble(preprocess(f)));
+ if(opt_pos) {
+ positions.push_back({strtol(argv[i+1],NULL,10), strtol(argv[i+2],NULL,10)}); // TODO: check if i>argc
+ i += 2;
+ }
}
- for(const Team &t : teams){
- Robot &r=world.create(&t,2,t.banks.size(),false);
+ for(int i=0; i<teams.size(); i++) {
+ const Team &t = teams[i];
+ Robot &r = opt_pos ? world.create(&t,2,t.banks.size(),false, positions[i][0], positions[i][1])
+ : world.create(&t,2,t.banks.size(),false);
+
for(int i=0;i<(int)t.banks.size();i++){
r.load(i,t.banks[i]);
r.active=1;