MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / new

Method new

battlecode-engine/src/team_array.rs:24–37  ·  view source on GitHub ↗

Constructs a new team array info.

()

Source from the content-addressed store, hash-verified

22impl TeamArrayInfo {
23 /// Constructs a new team array info.
24 pub fn new() -> TeamArrayInfo {
25 // The length of the history is COMMUNICATION_DELAY + 1 for each array
26 // from 1 to COMMUNICATION_DELAY rounds ago, and the current round.
27 let mut history: FnvHashMap<Planet, VecDeque<TeamArray>> = FnvHashMap::default();
28 let mut deque: VecDeque<TeamArray> = VecDeque::with_capacity(COMMUNICATION_DELAY + 1);
29 for _ in 0..COMMUNICATION_DELAY + 1 {
30 deque.push_back(vec![0; COMMUNICATION_ARRAY_LENGTH]);
31 }
32 history.insert(Planet::Earth, deque.clone());
33 history.insert(Planet::Mars, deque);
34 TeamArrayInfo {
35 history: history,
36 }
37 }
38
39 fn get_arrays(&self, planet: Planet) -> &VecDeque<TeamArray> {
40 if let Some(array) = self.history.get(&planet) {

Callers

nothing calls this directly

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected