Expand description
An easily reusable game bot for deterministic games.
It is required to implement the trait Game for your game to use this crate.
§Examples
A game where you win by selecting 10.
use std::ops::RangeInclusive;
#[derive(Clone)]
struct ChooseTen;
impl rubot::Game for ChooseTen {
/// there is only one player, you!
type Player = ();
type Action = u8;
/// did you choose a 10?
type Fitness = bool;
type Actions = RangeInclusive<u8>;
fn actions(&self, _: Self::Player) -> (bool, Self::Actions) {
(true, 1..=10)
}
fn execute(&mut self, action: &u8, _: Self::Player) -> Self::Fitness {
*action == 10
}
}
fn main() {
use rubot::Bot;
use std::time::Duration;
let mut bot = Bot::new(());
assert_eq!(
bot.select(&ChooseTen, Duration::from_secs(1)),
Some(10)
);
}Please visit the examples folder or the trait Game documentation
for more realistic examples.
Re-exports§
pub use alpha_beta::Bot;
Modules§
- alpha_
beta - A deterministic game bot using alpha beta pruning.
- tree
- A tree implementation used in examples and tests.
Structs§
- Depth
- A struct implementing
RunConditionreturning cancelling the computation once the depthself.0is reached. - Logger
- A struct implementing
IntoRunConditionwhich can be used to log a call toselect. For more details you can visit the individual methods. - Steps
- Can be converted into
RunConditionwhich returnstruefor the firstself.0steps. This should only be used for debugging and testing as unlikeDuration,ToCompletionorDepth, the total amount of steps needed is not directly indicative of search depth and can change between minor versions. - ToCompletion
- A struct implementing
RunConditionwhich always returnstrue.
Traits§
- Game
- An interface required to interact with
GameBots. - Into
RunCondition - Converts a type into a
RunConditionused byBot::select. It is recommended to mostly useDuration. - RunCondition
- A condition which indicates if
Bot::selectshould keep on running. It is recommended to useDurationfor nearly all use cases.