Skip to content

Commit

Permalink
update to shakmaty 0.27.1
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Jul 18, 2024
1 parent 01a6f12 commit 9e081d6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 47 deletions.
52 changes: 29 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde_with::{
formats::SpaceSeparator, serde_as, DisplayFromStr, DurationMilliSeconds, DurationSeconds,
NoneAsEmptyString, StringWithSeparator,
};
use shakmaty::{fen::Fen, uci::Uci, variant::Variant};
use shakmaty::{fen::Fen, uci::UciMove, variant::Variant};
use tokio::{
sync::{mpsc, oneshot},
time::sleep,
Expand Down Expand Up @@ -67,7 +67,7 @@ enum ApiMessage {
},
SubmitMove {
batch_id: BatchId,
best_move: Option<Uci>,
best_move: Option<UciMove>,
callback: oneshot::Sender<Acquired>,
},
}
Expand Down Expand Up @@ -315,8 +315,8 @@ pub struct AcquireResponseBody {
#[serde_as(as = "DisplayFromStr")]
#[serde(default)]
pub variant: Variant,
#[serde_as(as = "StringWithSeparator::<SpaceSeparator, Uci>")]
pub moves: Vec<Uci>,
#[serde_as(as = "StringWithSeparator::<SpaceSeparator, UciMove>")]
pub moves: Vec<UciMove>,
#[serde(rename = "skipPositions", default)]
pub skip_positions: Vec<PositionIndex>,
}
Expand Down Expand Up @@ -359,7 +359,7 @@ struct MoveRequestBody {
struct BestMove {
#[serde_as(as = "Option<DisplayFromStr>")]
#[serde(rename = "bestmove")]
best_move: Option<Uci>,
best_move: Option<UciMove>,
}

#[serde_as]
Expand All @@ -370,9 +370,9 @@ pub enum AnalysisPart {
skipped: bool,
},
Best {
#[serde_as(as = "StringWithSeparator::<SpaceSeparator, Uci>")]
#[serde_as(as = "StringWithSeparator::<SpaceSeparator, UciMove>")]
#[serde(skip_serializing_if = "Vec::is_empty")]
pv: Vec<Uci>,
pv: Vec<UciMove>,
score: Score,
depth: u8,
nodes: u64,
Expand All @@ -382,7 +382,7 @@ pub enum AnalysisPart {
},
Matrix {
#[serde_as(as = "Vec<Vec<Option<Vec<DisplayFromStr>>>>")]
pv: Vec<Vec<Option<Vec<Uci>>>>,
pv: Vec<Vec<Option<Vec<UciMove>>>>,
score: Vec<Vec<Option<Score>>>,
depth: u8,
nodes: u64,
Expand Down Expand Up @@ -468,7 +468,7 @@ impl ApiStub {
pub async fn submit_move_and_acquire(
&mut self,
batch_id: BatchId,
best_move: Option<Uci>,
best_move: Option<UciMove>,
) -> Option<Acquired> {
let (req, res) = oneshot::channel();
self.tx
Expand Down Expand Up @@ -745,7 +745,7 @@ impl ApiActor {
status => {
self.logger.warn(&format!(
"Unexpected status submitting move {} for batch {}: {}",
best_move.unwrap_or(Uci::Null),
best_move.unwrap_or(UciMove::Null),
batch_id,
status
));
Expand Down
8 changes: 4 additions & 4 deletions src/ipc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{num::NonZeroU8, time::Duration};

use shakmaty::{fen::Fen, uci::Uci, variant::Variant};
use shakmaty::{fen::Fen, uci::UciMove, variant::Variant};
use tokio::{sync::oneshot, time::Instant};
use url::Url;

Expand Down Expand Up @@ -31,7 +31,7 @@ pub struct Position {
pub skip: bool,

pub root_fen: Fen,
pub moves: Vec<Uci>,
pub moves: Vec<UciMove>,
}

#[derive(Debug, Clone)]
Expand All @@ -41,8 +41,8 @@ pub struct PositionResponse {
pub url: Option<Url>,

pub scores: Matrix<Score>,
pub pvs: Matrix<Vec<Uci>>,
pub best_move: Option<Uci>,
pub pvs: Matrix<Vec<UciMove>>,
pub best_move: Option<UciMove>,
pub depth: u8,
pub nodes: u64,
pub time: Duration,
Expand Down
16 changes: 8 additions & 8 deletions src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{

use shakmaty::{
fen::Fen,
uci::{IllegalUciError, Uci},
uci::{IllegalUciMoveError, UciMove},
variant::{Variant, VariantPosition},
CastlingMode, EnPassantMode, Position as _, PositionError,
};
Expand Down Expand Up @@ -322,7 +322,7 @@ impl QueueState {
#[derive(Debug)]
struct MoveSubmission {
batch_id: BatchId,
best_move: Option<Uci>,
best_move: Option<UciMove>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -714,7 +714,7 @@ impl From<&IncomingBatch> for ProgressAt {
#[derive(Debug)]
enum IncomingError {
Position(PositionError<VariantPosition>),
IllegalUci(IllegalUciError),
IllegalUciMove(IllegalUciMoveError),
AllSkipped(CompletedBatch),
}

Expand All @@ -724,7 +724,7 @@ impl fmt::Display for IncomingError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
IncomingError::Position(err) => err.fmt(f),
IncomingError::IllegalUci(err) => err.fmt(f),
IncomingError::IllegalUciMove(err) => err.fmt(f),
IncomingError::AllSkipped(_) => f.write_str("all positions skipped"),
}
}
Expand All @@ -736,9 +736,9 @@ impl From<PositionError<VariantPosition>> for IncomingError {
}
}

impl From<IllegalUciError> for IncomingError {
fn from(err: IllegalUciError) -> IncomingError {
IncomingError::IllegalUci(err)
impl From<IllegalUciMoveError> for IncomingError {
fn from(err: IllegalUciMoveError) -> IncomingError {
IncomingError::IllegalUciMove(err)
}
}

Expand Down Expand Up @@ -813,7 +813,7 @@ impl CompletedBatch {
.collect()
}

fn into_best_move(self) -> Option<Uci> {
fn into_best_move(self) -> Option<UciMove> {
self.positions.into_iter().next().and_then(|p| match p {
Skip::Skip => None,
Skip::Present(pos) => pos.best_move,
Expand Down
4 changes: 2 additions & 2 deletions src/stockfish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
time::Duration,
};

use shakmaty::uci::Uci;
use shakmaty::uci::UciMove;
use tokio::{
io::{AsyncBufReadExt as _, AsyncWriteExt as _, BufReader, BufWriter, Lines},
process::{ChildStdin, ChildStdout},
Expand Down Expand Up @@ -452,7 +452,7 @@ impl StockfishActor {
multipv,
depth,
(&mut parts)
.map(|part| part.parse::<Uci>())
.map(|part| part.parse::<UciMove>())
.collect::<Result<Vec<_>, _>>()
.map_err(|_| {
io::Error::new(io::ErrorKind::InvalidData, "invalid pv")
Expand Down

0 comments on commit 9e081d6

Please sign in to comment.