BinaryExplorer

Struct BinaryExplorer 

Source
pub struct BinaryExplorer<G: ActionOptimiser, A: NodeStoreTrait> { /* private fields */ }

Implementations§

Source§

impl<G: ActionOptimiser, A: NodeStoreTrait> BinaryExplorer<G, A>

Source

pub fn new_checked( contract: Contract, initial_node: TrickNode, north_south_target: u8, ) -> Result<Self, BridgeCoreError>

Source

pub fn current_side(&self) -> Side

Source

pub fn explore_actions(&mut self) -> Result<bool, DoubleDummyError>

use brydz_dd::{
    node::{
        TrickNode
    },
};
use brydz_core::{
    player::side::{SideMap, Side::*},
    cards::trump::Trump,
    bidding::Bid,
    contract::{Contract, ContractParametersGen, ContractMechanics},
    karty::{
        suits::Suit::*,
        cards::*,
        set::CardSetStd,
        card_set
    }
};
use brydz_dd::actions::DistinctCardGrouper;
use brydz_dd::explore::{BinaryExplorer, ExploreOutput, Explorer};
use brydz_dd::hash::DummyNodeStore;

let contract = Contract::new(
ContractParametersGen::new(West, Bid::init(Trump::Colored(Diamonds), 1).unwrap()));
let hands = SideMap::new(
    card_set![ACE_SPADES, QUEEN_SPADES, JACK_CLUBS, KING_CLUBS],
    card_set!(ACE_HEARTS, KING_DIAMONDS, KING_HEARTS, JACK_DIAMONDS),
    card_set![ACE_DIAMONDS, ACE_CLUBS, QUEEN_HEARTS, QUEEN_CLUBS],
    card_set![KING_SPADES, QUEEN_DIAMONDS, JACK_SPADES, JACK_HEARTS ]);
let node = TrickNode::new_checked(hands, contract.current_side()).unwrap();
let mut explorer = BinaryExplorer::<DistinctCardGrouper, DummyNodeStore>::new_checked(contract.clone(), node.clone(), 1).unwrap();

assert_eq!(explorer.explore_actions(), Ok(true));
let mut explorer2 = BinaryExplorer::<DistinctCardGrouper, DummyNodeStore>::new_checked(contract.clone(), node.clone(), 2).unwrap();
assert_eq!(explorer2.explore_actions(), Ok(false));
Source

pub fn hint(&mut self) -> Result<TrackStep, DoubleDummyError>

Source

pub fn update( &mut self, state_update: ExplorerStateUpdate, ) -> Result<(), BridgeCoreErrorGen<Card>>

Source

pub fn state(&self) -> &ExplorerGameState<G>

Trait Implementations§

Source§

impl<G: Clone + ActionOptimiser, A: Clone + NodeStoreTrait> Clone for BinaryExplorer<G, A>

Source§

fn clone(&self) -> BinaryExplorer<G, A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<G: Debug + ActionOptimiser, A: Debug + NodeStoreTrait> Debug for BinaryExplorer<G, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<G, A> Freeze for BinaryExplorer<G, A>
where A: Freeze, G: Freeze,

§

impl<G, A> RefUnwindSafe for BinaryExplorer<G, A>

§

impl<G, A> Send for BinaryExplorer<G, A>
where A: Send, G: Send,

§

impl<G, A> Sync for BinaryExplorer<G, A>
where A: Sync, G: Sync,

§

impl<G, A> Unpin for BinaryExplorer<G, A>
where A: Unpin, G: Unpin,

§

impl<G, A> UnwindSafe for BinaryExplorer<G, A>
where A: UnwindSafe, G: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<'a, T, Pt> TokenParsed<TokensBorrowed<'a, T>> for Pt
where T: PrimitiveMarker<Pt>,

Source§

fn parse_from_tokens( input: TokensBorrowed<'a, T>, ) -> Result<(TokensBorrowed<'a, T>, Pt), Err<Error<TokensBorrowed<'a, T>>>>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V