[−][src]Crate rubot
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 |
Logger | A struct implementing |
Steps | Can be converted into |
ToCompletion | A struct implementing |
Traits
Game | An interface required to interact with |
IntoRunCondition | Converts a type into a |
RunCondition | A condition which indicates if |