Skip to main content

OrderHooks

Trait OrderHooks 

Source
pub trait OrderHooks<R: Sides> {
    type Piece: Eq + Copy;

    // Required methods
    fn prepare(&mut self, rules: &R);
    fn classify(&mut self, rules: &R, command: &R::Command) -> Kind<Self::Piece>;
    fn pick(&mut self, rules: &R) -> Option<R::Command>;
    fn at(&self, rules: &R, piece: Self::Piece) -> Option<Pos>;
    fn distance(
        &mut self,
        rules: &R,
        piece: Self::Piece,
        from: Pos,
    ) -> Option<u32>;
    fn safe(&self, rules: &R, at: Pos) -> bool;
}
Expand description

What a TacticsOrder asks the game, once per order call. The game’s hooks hold the state’s Threats and GoalDistance, built in prepare.

Required Associated Types§

Source

type Piece: Eq + Copy

The game’s id of a piece.

Required Methods§

Source

fn prepare(&mut self, rules: &R)

Called first: build this state’s Threats and GoalDistance.

Source

fn classify(&mut self, rules: &R, command: &R::Command) -> Kind<Self::Piece>

What command is, called once per legal command, in the legal order.

Source

fn pick(&mut self, rules: &R) -> Option<R::Command>

The game’s own pick (an AI’s command), if it has one; it may also be a strike or a step, and is listed once.

Source

fn at(&self, rules: &R, piece: Self::Piece) -> Option<Pos>

Where piece stands now.

Source

fn distance(&mut self, rules: &R, piece: Self::Piece, from: Pos) -> Option<u32>

How far piece would walk from from to the nearest goal; None with no walk.

Source

fn safe(&self, rules: &R, at: Pos) -> bool

Whether no threat reaches at.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§