refactor: move to main.rs file and add prelude
This commit is contained in:
parent
5ef46b3e7a
commit
af18600d15
@ -4,8 +4,6 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
|
||||||
default-run = "engine"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
//! Generates moves from the FEN in the argv.
|
|
||||||
|
|
||||||
use chess_inator::fen::FromFen;
|
|
||||||
use chess_inator::movegen::MoveGen;
|
|
||||||
use chess_inator::Board;
|
|
||||||
use std::env;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let fen = env::args().nth(1).unwrap();
|
|
||||||
let mut board = Board::from_fen(&fen).unwrap();
|
|
||||||
let mvs = board.gen_moves();
|
|
||||||
for mv in mvs.into_iter() {
|
|
||||||
println!("{mv:?}")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
//! Runs perft at depth for a given FEN.
|
|
||||||
|
|
||||||
use chess_inator::fen::FromFen;
|
|
||||||
use chess_inator::movegen::perft;
|
|
||||||
use chess_inator::Board;
|
|
||||||
use std::env;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let depth = env::args().nth(1).unwrap().parse::<usize>().unwrap();
|
|
||||||
let fen = env::args().nth(2).unwrap();
|
|
||||||
let mut board = Board::from_fen(&fen).unwrap();
|
|
||||||
let res = perft(depth, &mut board);
|
|
||||||
println!("{res}")
|
|
||||||
}
|
|
12
src/lib.rs
12
src/lib.rs
@ -24,13 +24,15 @@ pub mod movegen;
|
|||||||
pub mod random;
|
pub mod random;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
|
|
||||||
|
pub mod prelude;
|
||||||
|
|
||||||
use crate::fen::{FromFen, ToFen, START_POSITION};
|
use crate::fen::{FromFen, ToFen, START_POSITION};
|
||||||
use crate::hash::Zobrist;
|
use crate::hash::Zobrist;
|
||||||
use eval::eval_score::EvalScores;
|
use eval::eval_score::EvalScores;
|
||||||
|
|
||||||
const BOARD_WIDTH: usize = 8;
|
pub const BOARD_WIDTH: usize = 8;
|
||||||
const BOARD_HEIGHT: usize = 8;
|
pub const BOARD_HEIGHT: usize = 8;
|
||||||
const N_SQUARES: usize = BOARD_WIDTH * BOARD_HEIGHT;
|
pub const N_SQUARES: usize = BOARD_WIDTH * BOARD_HEIGHT;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
@ -38,7 +40,7 @@ pub enum Color {
|
|||||||
White = 0,
|
White = 0,
|
||||||
Black = 1,
|
Black = 1,
|
||||||
}
|
}
|
||||||
const N_COLORS: usize = 2;
|
pub const N_COLORS: usize = 2;
|
||||||
|
|
||||||
impl Color {
|
impl Color {
|
||||||
/// Return opposite color (does not assign).
|
/// Return opposite color (does not assign).
|
||||||
@ -74,7 +76,7 @@ enum Piece {
|
|||||||
Queen,
|
Queen,
|
||||||
Pawn,
|
Pawn,
|
||||||
}
|
}
|
||||||
const N_PIECES: usize = 6;
|
pub const N_PIECES: usize = 6;
|
||||||
|
|
||||||
pub struct PieceErr;
|
pub struct PieceErr;
|
||||||
|
|
||||||
|
@ -12,11 +12,7 @@ Copyright © 2024 dogeystamp <dogeystamp@disroot.org>
|
|||||||
|
|
||||||
//! Main UCI engine binary.
|
//! Main UCI engine binary.
|
||||||
|
|
||||||
use chess_inator::eval::eval_metrics;
|
use chess_inator::prelude::*;
|
||||||
use chess_inator::fen::FromFen;
|
|
||||||
use chess_inator::movegen::{FromUCIAlgebraic, Move, ToUCIAlgebraic};
|
|
||||||
use chess_inator::search::{best_line, InterfaceMsg, SearchEval, TranspositionTable};
|
|
||||||
use chess_inator::{Board, Color};
|
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
20
src/prelude.rs
Normal file
20
src/prelude.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
This file is part of chess_inator.
|
||||||
|
|
||||||
|
chess_inator is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
chess_inator is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with chess_inator. If not, see https://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
Copyright © 2024 dogeystamp <dogeystamp@disroot.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! Prelude that you can import entirely to use the library conveniently.
|
||||||
|
|
||||||
|
pub use crate::eval::{eval_metrics, EvalMetrics};
|
||||||
|
pub use crate::fen::{FromFen, ToFen};
|
||||||
|
pub use crate::movegen::{FromUCIAlgebraic, Move, MoveGen, ToUCIAlgebraic};
|
||||||
|
pub use crate::search::{best_line, best_move, InterfaceMsg, SearchEval, TranspositionTable};
|
||||||
|
pub use crate::{Board, Color, BOARD_HEIGHT, BOARD_WIDTH, N_COLORS, N_PIECES, N_SQUARES};
|
Loading…
Reference in New Issue
Block a user