MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / reset_rounds_left

Method reset_rounds_left

battlecode-engine/src/research.rs:152–165  ·  view source on GitHub ↗

Sets the number of rounds left to the cost of the first thing in the queue. Sets the cost to None if the queue is empty.

(&mut self)

Source from the content-addressed store, hash-verified

150 /// Sets the number of rounds left to the cost of the first thing in the
151 /// queue. Sets the cost to None if the queue is empty.
152 fn reset_rounds_left(&mut self) {
153 if self.queue.len() == 0 {
154 self.rounds_left = None;
155 return;
156 }
157
158 let branch = &self.queue[0];
159 let level = self.get_level(branch) + 1;
160 if let Ok(cost) = cost_of(branch, level) {
161 self.rounds_left = Some(cost);
162 } else {
163 unreachable!();
164 }
165 }
166
167 /// Resets the research queue to be empty. Returns true if the queue was
168 /// not empty before, and false otherwise.

Callers 2

add_to_queueMethod · 0.80
end_roundMethod · 0.80

Calls 2

cost_ofFunction · 0.85
get_levelMethod · 0.80

Tested by

no test coverage detected