@@ -35,17 +35,20 @@ exports[`Editor Container Should render Editor 1`] = `
35
35
// Bots can move to any reachable location on the map.
36
36
// Let's make bots move to all flag locations
37
37
38
- // You can use auto instead of an explicit type
39
38
size_t used_bots = 0;
40
39
41
40
// Range based loops are convenient to use. We use a reference to
42
41
// ensure that our changes are reflected and not made on a copy!
42
+ // You can use auto instead of an explicit type
43
43
for (auto &bot : state .bots ) {
44
- // Let's not use up all our bots just for this operation . So, we will
45
- // only use a maximum of 18 bots here.
46
- if (used_bots >= state .flag_offsets .size () || used_bots >= 18 )
44
+ // Let's not use up all our bots just for these . So, we will only use a
45
+ // maximum of 18 bots here.
46
+ if (used_bots > state .flag_offsets .size () || used_bots >= 18 )
47
47
break ;
48
48
49
+ // Make sure that you do not access a vector beyond it's size or else,
50
+ // you'll get a segmentation fault and cost you the entire game
51
+
49
52
// State has a vector that has the locations of flag locations on the
50
53
// map. A bot asked to move to a location will automatically go
51
54
// there using the shortest path found and start mining for gold.
@@ -58,19 +61,27 @@ exports[`Editor Container Should render Editor 1`] = `
58
61
59
62
// Before that we ensure that we have atleast one extra bot left
60
63
if (state .bots .size () > used_bots) {
61
- // See the usage of constant value PLAYER2_BASE_POSITION
62
- state .bots [used_bots ].blast (PLAYER2_BASE_POSITION );
64
+ // See the usage of constant value PLAYER_BASE_POSITIONS
65
+ state .bots [used_bots ].blast (PLAYER_BASE_POSITIONS [ 1 ] );
63
66
used_bots ++ ;
64
67
}
65
68
66
69
// Other than blasting and moving, bots can also transform into towers
67
- // Let's try to transform one of the bots near the other end of
68
- // the map i.e., (MAP_SIZE - 2, MAP_SIZE - 2) Note that you cannot construct
69
- // or move to coordinates where either x = MAP_SIZE or y = MAP_SIZE
70
+ // Let's try to transform all of the remaining bots near the other end of
71
+ // the map i.e., (MAP_SIZE - 1, MAP_SIZE - 1) Note that you cannot construct
72
+ // / move to coordinates where either x = MAP_SIZE or y = MAP_SIZE
73
+ int x = MAP_SIZE - 2, y = MAP_SIZE - 2;
70
74
71
75
// The bots can also be traversed like a usual array using an index
72
- for (size_t i = used_bots ; i < used_bots + 1; i ++) {
73
- state .bots [i ].transform (DoubleVec2D (MAP_SIZE - 2 , MAP_SIZE - 2 ));
76
+ for (size_t i = used_bots ; i < state .bots .size (); i++) {
77
+ if (y != (MAP_SIZE - 1)) {
78
+
79
+ // You can use the DoubleVec2D class to define positions and
80
+ // distances
81
+ state .bots [i ].transform (DoubleVec2D (x , y ));
82
+ x -- ;
83
+ y ++ ;
84
+ }
74
85
}
75
86
76
87
// State also has the vector of player towers
@@ -91,15 +102,10 @@ exports[`Editor Container Should render Editor 1`] = `
91
102
// all there is to State and we have some helper snippets and methods
92
103
// so you start competing right away!
93
104
94
- for (auto &bot : state .bots ) {
95
- logr << bot .position << endl ;
96
- }
97
-
98
105
return state ;
99
106
}
100
107
101
- } // namespace player_code
102
- "
108
+ }"
103
109
editorWidth = { 400 }
104
110
enableBasicAutoCompletion = { true }
105
111
enableSnippets = { true }
@@ -109,7 +115,7 @@ exports[`Editor Container Should render Editor 1`] = `
109
115
isLoggedIn = { false }
110
116
keyboardHandler = " default"
111
117
save = { [Function ]}
112
- theme = " solarized_light "
118
+ theme = " monokai "
113
119
updateCode = { [Function ]}
114
120
viewOnly = { false }
115
121
/>
0 commit comments