Can change bot type in rules screen
This commit is contained in:
@ -36,7 +36,7 @@ impl GameRules {
|
||||
.join(","),
|
||||
boats_can_touch: MULTI_PLAYER_BOATS_CAN_TOUCH,
|
||||
player_continue_on_hit: MULTI_PLAYER_PLAYER_CAN_CONTINUE_AFTER_HIT,
|
||||
bot_type: BotType::Random,
|
||||
bot_type: BotType::Smart,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,42 @@ pub enum BotType {
|
||||
Smart,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
impl BotType {
|
||||
pub fn description(&self) -> &'static BotDescription {
|
||||
BOTS_TYPES.iter().find(|d| d.r#type == *self).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, Clone)]
|
||||
pub struct BotDescription {
|
||||
pub r#type: BotType,
|
||||
pub name: &'static str,
|
||||
pub description: &'static str,
|
||||
}
|
||||
|
||||
const BOTS_TYPES: [BotDescription; 4] = [
|
||||
BotDescription {
|
||||
r#type: BotType::Linear,
|
||||
name: "Linear",
|
||||
description: "Linear strike. Shoot A1, A2, A3, ..., B1, B2, ...",
|
||||
},
|
||||
BotDescription {
|
||||
r#type: BotType::Random,
|
||||
name: "Random",
|
||||
description: "Random search. Random strike.",
|
||||
},
|
||||
BotDescription {
|
||||
r#type: BotType::Intermediate,
|
||||
name: "Intermediate",
|
||||
description: "Random search. Intelligent strike.",
|
||||
},
|
||||
BotDescription {
|
||||
r#type: BotType::Smart,
|
||||
name: "Smart",
|
||||
description: "Smart search. Smart strike.",
|
||||
},
|
||||
];
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
pub struct PlayConfiguration {
|
||||
pub min_boat_len: usize,
|
||||
@ -26,7 +55,7 @@ pub struct PlayConfiguration {
|
||||
pub max_map_height: usize,
|
||||
pub min_boats_number: usize,
|
||||
pub max_boats_number: usize,
|
||||
pub bot_types: Vec<BotDescription>,
|
||||
pub bot_types: &'static [BotDescription],
|
||||
pub ordinate_alphabet: &'static str,
|
||||
}
|
||||
|
||||
@ -41,28 +70,7 @@ impl Default for PlayConfiguration {
|
||||
max_map_height: MAX_MAP_HEIGHT,
|
||||
min_boats_number: MIN_BOATS_NUMBER,
|
||||
max_boats_number: MAX_BOATS_NUMBER,
|
||||
bot_types: vec![
|
||||
BotDescription {
|
||||
r#type: BotType::Linear,
|
||||
name: "Linear",
|
||||
description: "Linear strike. Shoot A1, A2, A3, ..., B1, B2, ...",
|
||||
},
|
||||
BotDescription {
|
||||
r#type: BotType::Random,
|
||||
name: "Ranom",
|
||||
description: "Random search. Random strike.",
|
||||
},
|
||||
BotDescription {
|
||||
r#type: BotType::Intermediate,
|
||||
name: "Intermediate",
|
||||
description: "Random search. Intelligent strike.",
|
||||
},
|
||||
BotDescription {
|
||||
r#type: BotType::Smart,
|
||||
name: "Smart",
|
||||
description: "Smart search. Smart strike.",
|
||||
},
|
||||
],
|
||||
bot_types: &BOTS_TYPES,
|
||||
ordinate_alphabet: ALPHABET,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user