[−][src]Struct connect6::agent::AsyncAgent
Agent for playing multiple games asynchronously.
AsyncAgent
play multiple games on tokio thread-pool.
It pass the policy generator and return the vector of game result.
Examples
let policy_gen = || RandomPolicy::new(); let async_agent = AsyncAgent::debug(policy_gen); let result = async_agent.run(4); println!("ratio: {}", result.iter().map(|x| x.winner as i32).sum::<i32>());
Methods
impl<P: 'static + Policy + Send, F: Fn() -> P> AsyncAgent<P, F>
[src]
pub fn new(policy_gen: F) -> AsyncAgent<P, F>
[src]
Construct a new AsyncAgent.
Get policy generator as callable object which return impl Policy
.
Examples
let gen = || RandomPolicy::new(); let async_agent = AsyncAgent::new(gen);
pub fn debug(policy_gen: F) -> AsyncAgent<P, F>
[src]
Construct a debug mode AsyncAgent, it will display the dbg info.
Examples
let gen = || RandomPolicy::new(); let async_agent = AsyncAgent::debug(gen);
pub fn run(&self, num: i32) -> Vec<PlayResult>
[src]
Self-play the given number of games asynchronously on thread pool.
Examples
let gen = || RandomPolicy::new(); let async_agent = AsyncAgent::new(gen); let result = async_agent.run(4); println!("result: {}", result.iter().map(|x| x.winner as i32).sum::<i32>());
Panics
If some games return the Err from Agent::play.
Auto Trait Implementations
impl<P, F> Send for AsyncAgent<P, F> where
F: Send,
F: Send,
impl<P, F> Sync for AsyncAgent<P, F> where
F: Sync,
F: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,