Skip to content

Commit

Permalink
optimal line
Browse files Browse the repository at this point in the history
  • Loading branch information
mikea committed Oct 29, 2024
1 parent 1c3c08a commit 0063776
Show file tree
Hide file tree
Showing 10 changed files with 670 additions and 154 deletions.
6 changes: 3 additions & 3 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ watch +WATCH_TARGET='run':
run:
cargo build -r
# bermuda hand
time target/release/bridgitte analyze-deal --player N --strain S --stats "854.Q873.Q984.65 KQ32.T6.T72.AJ93 9.AJ542.J653.T87 AJT76.K9.AK.KQ42"
time target/release/bridgitte analyze-deal --declarer e --strain d --stats "854.Q873.Q984.65 KQ32.T6.T72.AJ93 9.AJ542.J653.T87 AJT76.K9.AK.KQ42"

clippy:
cargo clippy -- -D clippy::pedantic -A clippy::missing-panics-doc -A clippy::module_name_repetitions
Expand All @@ -25,11 +25,11 @@ bench: test

callgrind: build-valgrind
rm -f callgrind.out.* cachegrind.out.*
valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes target/release/bridgitte analyze-deal --player N --strain S "854.Q873.Q984.65 KQ32.T6.T72.AJ93 9.AJ542.J653.T87 AJT76.K9.AK.KQ42"
valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes target/release/bridgitte analyze-deal --declarer N --strain S "854.Q873.Q984.65 KQ32.T6.T72.AJ93 9.AJ542.J653.T87 AJT76.K9.AK.KQ42"

cachegrind: build-valgrind
rm -f callgrind.out.* cachegrind.out.*
valgrind --tool=cachegrind target/release/bridgitte analyze-deal --player N --strain S "854.Q873.Q984.65 KQ32.T6.T72.AJ93 9.AJ542.J653.T87 AJT76.K9.AK.KQ42"
valgrind --tool=cachegrind target/release/bridgitte analyze-deal --declarer N --strain S "854.Q873.Q984.65 KQ32.T6.T72.AJ93 9.AJ542.J653.T87 AJT76.K9.AK.KQ42"

build-valgrind:
# use build-std to get nice symbols
Expand Down
12 changes: 9 additions & 3 deletions src/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
use rayon::prelude::*;

use crate::{
search::{search, Config},
search::{search, Config, InitialPosition},
ByPlayer, Deal, Player, Suit,
};

Expand All @@ -15,7 +15,6 @@ pub struct Strain {
pub trumps: Option<Suit>,
}


impl Strain {
const ALL: [Strain; 5] = [
Strain {
Expand Down Expand Up @@ -108,5 +107,12 @@ pub fn analyze_player(deal: &Deal, player: Player, config: &Config) -> ByStrain<

#[must_use]
pub fn analyze(deal: &Deal, player: Player, strain: &Strain, config: &Config) -> u8 {
search(deal, strain.trumps, player, config)
search(
&InitialPosition {
deal: deal.clone(),
trumps: strain.trumps,
declarer: player,
},
config,
)
}
Loading

0 comments on commit 0063776

Please sign in to comment.