pub struct Table { /* private fields */ }Expand description
A round in progress, with common-knowledge void tracking
Table::round intentionally exposes the full position — user
interfaces and loggers need it — but strategies only ever receive the
Views handed to them by Table::step.
Implementations§
Source§impl Table
impl Table
Sourcepub fn new(round: Round) -> Self
pub fn new(round: Round) -> Self
Wrap a round, recovering void inference from its history
Unlike gin rummy, every observation in Hearts is public, so a table can pick up a round in any phase.
The game score defaults to level (all seats at zero), so a
standalone round reports game_scores of
[0; 4]. Set it with Table::scores when driving a round within
a game.
Sourcepub const fn scores(self, scores: [u16; 4]) -> Self
pub const fn scores(self, scores: [u16; 4]) -> Self
Set the running game totals, indexed by Seat
Each seat’s View then reports the seat-relative
game_scores, letting score-aware strategies
hunt the leader or duck for the endgame.
Sourcepub fn deal(
rules: Rules,
direction: PassDirection,
rng: &mut (impl Rng + ?Sized),
) -> Self
pub fn deal( rules: Rules, direction: PassDirection, rng: &mut (impl Rng + ?Sized), ) -> Self
Shuffle and deal a fresh round onto a new table
Sourcepub fn turn(&self) -> Option<Seat>
pub fn turn(&self) -> Option<Seat>
The seat the driver acts for next, or None when the round is over
During the passing phase — where seats act concurrently in real play
— the driver serializes deterministically: the first unpassed seat
in Seat::ALL order.
Sourcepub fn points_settled(&self) -> bool
pub fn points_settled(&self) -> bool
Whether every penalty card already sits in a completed trick, freezing the round’s point tally
True only mid-play: once it holds, the remaining tricks are all
scoreless and cannot change any seat’s result, so an interactive caller
may offer to end the round and jump straight to the outcome. Reads the
won tricks, not Round::played, so it stays false while the last
penalty card is still in the live, unresolved trick.
Sourcepub fn step(
&mut self,
strategy: &mut dyn Strategy,
) -> Result<Option<RoundResult>, EngineError>
pub fn step( &mut self, strategy: &mut dyn Strategy, ) -> Result<Option<RoundResult>, EngineError>
Ask strategy — which must belong to the seat to act (see
Table::turn) — for one decision and apply it
Returns the result once the round finishes, None while it
continues.
§Errors
EngineError::IllegalAction when the round rejects the strategy’s
choice — including a pass of non-distinct cards. The table is left
unchanged, so an interactive caller may retry the same decision.
Sourcepub fn play(
&mut self,
strategies: [&mut dyn Strategy; 4],
) -> Result<RoundResult, EngineError>
pub fn play( &mut self, strategies: [&mut dyn Strategy; 4], ) -> Result<RoundResult, EngineError>
Drive the round to completion, one strategy per seat
§Errors
EngineError::IllegalAction when a strategy’s choice is rejected.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
impl UnwindSafe for Table
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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