-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (52 loc) · 1.15 KB
/
main.cpp
File metadata and controls
70 lines (52 loc) · 1.15 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
// main.cpp -- ALP PISKIN & ANKIT KOTWAL
#include "Grid.h"
#include <iostream>
#include <unistd.h>
int main(int argc, char* argv[]) {
if (argc > 7) {
std::cout << "Error: Invalid Input\n";
exit(0);
}
srand(1);
unsigned gridSize = 20;
unsigned numDoodles = 5;
unsigned numAnts = 100;
unsigned steps = 1000;
unsigned pause = 1;
if (argc >= 2) {
gridSize = atoi(argv[1]);
}
if (argc >= 3) {
numDoodles = atoi(argv[2]);
}
if (argc >= 4) {
numAnts = atoi(argv[3]);
}
if (argc >= 5) {
steps = atoi(argv[4]);
}
if (argc >= 6) {
int seed = atoi(argv[5]);
srand(seed);
}
if (argc >= 7) {
pause = atoi(argv[6]);
}
Grid *a = new Grid(gridSize,gridSize);
if(!a->loadGrid(numAnts, numDoodles)){
std::cout << "Number of ants and doodles are greater than the board size..." << std::endl;
return 1;
}
std::cout << " -- Initial State: " << std::endl;
a->printGrid();
for (unsigned i = 0; i < steps; i++) {
a->run();
if (i % pause == 0) {
a->printGrid();
std::cout << "----------------------------------\n -- Step:" << i+1 << std::endl;
}
}
std::cout << " -- End State: " << std::endl;
a->printGrid();
return 0;
}