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
RunCondition
returning cancelling the computation once the depthself.0
is reached. - Logger
- A struct implementing
IntoRunCondition
which can be used to log a call toselect
. For more details you can visit the individual methods. - Steps
- Can be converted into
RunCondition
which returnstrue
for the firstself.0
steps. This should only be used for debugging and testing as unlikeDuration
,ToCompletion
orDepth
, the total amount of steps needed is not directly indicative of search depth and can change between minor versions. - ToCompletion
- A struct implementing
RunCondition
which always returnstrue
.
Traits§
- Game
- An interface required to interact with
GameBot
s. - Into
RunCondition - Converts a type into a
RunCondition
used byBot::select
. It is recommended to mostly useDuration
. - RunCondition
- A condition which indicates if
Bot::select
should keep on running. It is recommended to useDuration
for nearly all use cases.