updates
This commit is contained in:
46
protossbot/src/state/build_stages.rs
Normal file
46
protossbot/src/state/build_stages.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use rsbwapi::UnitType;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BuildStage {
|
||||
pub name: String,
|
||||
pub desired_counts: HashMap<UnitType, i32>,
|
||||
}
|
||||
|
||||
impl BuildStage {
|
||||
pub fn new(name: &str) -> Self {
|
||||
Self {
|
||||
name: name.to_string(),
|
||||
desired_counts: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_unit(mut self, unit_type: UnitType, count: i32) -> Self {
|
||||
self.desired_counts.insert(unit_type, count);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_build_stages() -> Vec<BuildStage> {
|
||||
vec![
|
||||
BuildStage::new("Start")
|
||||
.with_unit(UnitType::Protoss_Probe, 10)
|
||||
.with_unit(UnitType::Protoss_Pylon, 1),
|
||||
|
||||
BuildStage::new("Basic Production")
|
||||
.with_unit(UnitType::Protoss_Probe, 12)
|
||||
.with_unit(UnitType::Protoss_Pylon, 2)
|
||||
.with_unit(UnitType::Protoss_Gateway, 1)
|
||||
.with_unit(UnitType::Protoss_Forge, 1),
|
||||
|
||||
|
||||
// Stage 2: Defense cannons
|
||||
BuildStage::new("Defense Cannons")
|
||||
.with_unit(UnitType::Protoss_Probe, 16)
|
||||
.with_unit(UnitType::Protoss_Pylon, 3)
|
||||
.with_unit(UnitType::Protoss_Nexus, 1)
|
||||
.with_unit(UnitType::Protoss_Gateway, 1)
|
||||
.with_unit(UnitType::Protoss_Forge, 1)
|
||||
.with_unit(UnitType::Protoss_Photon_Cannon, 4),
|
||||
]
|
||||
}
|
||||
46
protossbot/src/state/game_state.rs
Normal file
46
protossbot/src/state/game_state.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use std::collections::HashMap;
|
||||
use rsbwapi::{Order, Position, Unit, UnitType, UpgradeType};
|
||||
|
||||
use crate::state::build_stages::BuildStage;
|
||||
|
||||
pub struct GameState {
|
||||
pub intended_commands: HashMap<usize, IntendedCommand>,
|
||||
pub unit_build_history: Vec<BuildHistoryEntry>,
|
||||
pub build_stages: Vec<BuildStage>,
|
||||
pub current_stage_index: usize,
|
||||
pub desired_game_speed: i32,
|
||||
}
|
||||
|
||||
|
||||
impl Default for GameState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
intended_commands: HashMap::new(),
|
||||
unit_build_history: Vec::new(),
|
||||
build_stages: crate::state::build_stages::get_build_stages(),
|
||||
current_stage_index: 0,
|
||||
desired_game_speed: 20,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct IntendedCommand {
|
||||
pub order: Order,
|
||||
pub target_position: Option<Position>,
|
||||
pub target_unit: Option<Unit>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum BuildStatus {
|
||||
Assigned,
|
||||
Started,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BuildHistoryEntry {
|
||||
pub unit_type: Option<UnitType>,
|
||||
pub upgrade_type: Option<UpgradeType>,
|
||||
pub assigned_unit_id: Option<usize>,
|
||||
// pub status: BuildStatus,
|
||||
}
|
||||
2
protossbot/src/state/mod.rs
Normal file
2
protossbot/src/state/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod build_stages;
|
||||
pub mod game_state;
|
||||
Reference in New Issue
Block a user