Skip to content

Commit

Permalink
chore: make games dependant on feature
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockCat committed Mar 22, 2024
1 parent 1461db2 commit bdae1c7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
29 changes: 22 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ categories = ["algorithms", "games"]
repository = "https://github.com/KarelPeeters/board-game-rs"

[features]
games = [
"dep:chess",
"dep:arimaa_engine_step",
"dep:once_cell",
"dep:lazy_static",
"dep:static_assertions",
"dep:nohash-hasher",
]
default = []

[dependencies]
Expand All @@ -25,13 +33,12 @@ num_cpus = "1.15.0"

# TODO the chess crate is heavy (and takes a long time to build, see below "temp fix"), maybe replace it with
# cozy-chess or shakmaty
chess = "3.2.0"
# TODO make arimaa optional with a feature
arimaa_engine_step = { version = "1.0.1" } # , path = "../arimaa-engine-step"
once_cell = "1.18.0"
lazy_static = "1.4.0"
static_assertions = "1.1.0"
nohash-hasher = "0.2.0"
chess = { version = "3.2.0", optional = true }
arimaa_engine_step = { version = "1.0.1", optional = true } # , path = "../arimaa-engine-step"
once_cell = { version = "1.18.0", optional = true }
lazy_static = { version = "1.4.0", optional = true }
static_assertions = { version = "1.1.0", optional = true }
nohash-hasher = { version = "0.2.0", optional = true }

# temporary fix until https://github.com/jordanbray/chess/pull/67 is merged
[profile.dev.build-override]
Expand All @@ -47,3 +54,11 @@ debug = true
[profile.release-with-debug]
inherits = "release"
debug = true

[[bin]]
name = "bench"
required-features = ["games"]

[[bin]]
name = "go_split_perft"
required-features = ["games"]
7 changes: 3 additions & 4 deletions src/bin/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

use std::time::Instant;

use itertools::Itertools;
use rand::rngs::SmallRng;
use rand::SeedableRng;

use board_game::ai::mcts::mcts_build_tree;
use board_game::games::ataxx::AtaxxBoard;
use board_game::games::chess::ChessBoard;
use board_game::games::sttt::STTTBoard;
use itertools::Itertools;
use rand::rngs::SmallRng;
use rand::SeedableRng;

fn main() {
bench("mcts_sttt", || {
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
//! ```
// export used game crates

#[cfg(feature = "games")]
pub use arimaa_engine_step;

#[cfg(feature = "games")]
pub use chess;

pub mod board;
Expand All @@ -95,9 +99,14 @@ pub mod pov;
pub mod wdl;

pub mod ai;

#[cfg(feature = "games")]
pub mod games;

#[cfg(feature = "games")]
pub mod heuristic;

pub mod util;

#[cfg(feature = "games")]
pub mod interface;
4 changes: 4 additions & 0 deletions tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

#[cfg(feature="games")]
pub mod ai;

#[cfg(feature="games")]
pub mod board;
pub mod util;

0 comments on commit bdae1c7

Please sign in to comment.