rust/lib-hwengine-future/src/ai/action.rs
author unC0Rr
Fri, 22 Nov 2024 17:29:30 +0100
branchtransitional_engine
changeset 16040 6c5b3c576fc6
permissions -rw-r--r--
Add some progress on rust AI
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16040
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     1
#[derive(Clone)]
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     2
pub enum Direction {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     3
    Left,
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     4
    Right
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     5
}
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     6
#[derive(Clone)]
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     7
pub enum Action {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     8
    Walk(Direction),
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     9
    LongJump,
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    10
    HighJump(usize)
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    11
}
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    12
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    13
pub struct Actions {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    14
    actions: Vec<Action>
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    15
}
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    16
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    17
impl Actions {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    18
    pub fn new() -> Self {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    19
        Self {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    20
            actions: vec![],
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    21
        }
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    22
    }
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    23
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    24
    pub fn push(&mut self, action: Action) {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    25
        self.actions.push(action)
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    26
    }
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    27
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    28
    pub fn pop(&mut self) -> Option<Action> {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    29
        self.actions.pop()
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    30
    }
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    31
}