diff options
Diffstat (limited to 'src/knowledge.rs')
-rw-r--r-- | src/knowledge.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/knowledge.rs b/src/knowledge.rs new file mode 100644 index 0000000..3b0c61a --- /dev/null +++ b/src/knowledge.rs @@ -0,0 +1,54 @@ +use actions::*; +use ships::*; +use std::collections::HashMap; + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct Knowledge { + pub last_action: Option<Action>, + pub opponent_map: OpponentMapKnowledge +} + +impl Knowledge { + pub fn new() -> Knowledge { + Knowledge { + last_action: None, + opponent_map: OpponentMapKnowledge::new() + } + } + + pub fn with_action(&self, action: Action) -> Knowledge { + Knowledge { + last_action: Some(action), + opponent_map: self.opponent_map.clone() + } + } +} + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct OpponentMapKnowledge { + pub ships: HashMap<Ship, OpponentShipKnowledge>, + pub cells: Vec<Vec<KnowledgeCell>> +} + +impl OpponentMapKnowledge { + pub fn new() -> OpponentMapKnowledge { + OpponentMapKnowledge { + ships: HashMap::new(), + cells: Vec::new() + } + } +} + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct OpponentShipKnowledge { + pub destroyed: bool +} + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct KnowledgeCell { + pub shot_attempted: bool, + pub possible_ship_uses: HashMap<Ship, u16>, + pub known_ship: Option<Ship> +} + + |