Constructs a new team array info.
()
| 22 | impl 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) { |