Skip to content

Commit

Permalink
add 960 support
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Feb 12, 2024
1 parent cc068aa commit 4e43985
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src-tauri/src/chess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl EngineProcess {

async fn set_options(&mut self, options: EngineOptions) -> Result<(), Error> {
let fen: Fen = options.fen.parse()?;
let mut pos: Chess = match fen.into_position(CastlingMode::Standard) {
let mut pos: Chess = match fen.into_position(CastlingMode::Chess960) {
Ok(p) => p,
Err(e) => e.ignore_too_much_material()?,
};
Expand Down Expand Up @@ -249,7 +249,7 @@ fn parse_uci_attrs(
) -> Result<BestMoves, Error> {
let mut best_moves = BestMoves::default();

let mut pos: Chess = match fen.clone().into_position(CastlingMode::Standard) {
let mut pos: Chess = match fen.clone().into_position(CastlingMode::Chess960) {
Ok(p) => p,
Err(e) => e.ignore_too_much_material()?,
};
Expand Down Expand Up @@ -590,7 +590,7 @@ pub async fn analyze_game(

let fen = Fen::from_ascii(options.fen.as_bytes())?;

let mut chess: Chess = fen.clone().into_position(CastlingMode::Standard)?;
let mut chess: Chess = fen.clone().into_position(CastlingMode::Chess960)?;
let mut fens: Vec<(Fen, Vec<String>, bool)> = vec![(fen, vec![], false)];

options.moves.iter().enumerate().for_each(|(i, m)| {
Expand Down Expand Up @@ -784,7 +784,7 @@ mod tests {

fn pos(fen: &str) -> Chess {
let fen: Fen = fen.parse().unwrap();
Chess::from_setup(fen.into_setup(), CastlingMode::Standard).unwrap()
Chess::from_setup(fen.into_setup(), CastlingMode::Chess960).unwrap()
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/db/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum PositionQuery {
impl PositionQuery {
pub fn exact_from_fen(fen: &str) -> Result<PositionQuery, Error> {
let position: Chess =
Fen::from_ascii(fen.as_bytes())?.into_position(shakmaty::CastlingMode::Standard)?;
Fen::from_ascii(fen.as_bytes())?.into_position(shakmaty::CastlingMode::Chess960)?;
let pawn_home = get_pawn_home(position.board());
let material = get_material_count(position.board());
Ok(PositionQuery::Exact(ExactData {
Expand Down Expand Up @@ -170,7 +170,7 @@ fn get_move_after_match(
) -> Result<Option<String>, Error> {
let mut chess = if let Some(fen) = fen {
let fen = Fen::from_ascii(fen.as_bytes())?;
Chess::from_setup(fen.into_setup(), shakmaty::CastlingMode::Standard)?
Chess::from_setup(fen.into_setup(), shakmaty::CastlingMode::Chess960)?
} else {
Chess::default()
};
Expand Down Expand Up @@ -413,7 +413,7 @@ mod tests {
fn assert_partial_match(fen1: &str, fen2: &str) {
let query = PositionQuery::partial_from_fen(fen1).unwrap();
let fen = Fen::from_ascii(fen2.as_bytes()).unwrap();
let chess = Chess::from_setup(fen.into_setup(), shakmaty::CastlingMode::Standard).unwrap();
let chess = Chess::from_setup(fen.into_setup(), shakmaty::CastlingMode::Chess960).unwrap();
assert!(query.matches(&chess));
}

Expand Down

0 comments on commit 4e43985

Please sign in to comment.