diff --git a/src/bin/compare.rs b/src/bin/compare.rs index 7684ed6..a5cc050 100644 --- a/src/bin/compare.rs +++ b/src/bin/compare.rs @@ -9,7 +9,7 @@ fn compare(player_builders: &[Box], games: usize) { let r = (0..games) .into_par_iter() .map_init(SmallRng::from_entropy, |rng, _| { - herzen(player_builders, 0, rng) + herzen::(player_builders, 0, rng) }) .fold( || vec![[0_u64; 13]; player_builders.len()], @@ -48,11 +48,11 @@ fn compare(player_builders: &[Box], games: usize) { fn main() { let player: Vec> = vec![ - Box::new(player::random::Random { seed: 0 }), - Box::new(player::random::Random { seed: 0 }), - Box::new(player::random::Random { seed: 0 }), - Box::new(player::random::Random { seed: 0 }), + Box::new(player::highest::Highest {}), + Box::new(player::highest::Highest {}), + Box::new(player::highest::Highest {}), + Box::new(player::highest::Highest {}), ]; - compare(&player, 10000); + compare(&player, 10000000); } diff --git a/src/game.rs b/src/game.rs index 6587554..e18eb22 100644 --- a/src/game.rs +++ b/src/game.rs @@ -89,7 +89,7 @@ pub fn playeble(card: Card, hand: &[Card], stack_color: Option) -> bool { } } -pub fn herzen( +pub fn herzen( player_builders: &[Box], starting_player: usize, rng: &mut impl Rng, @@ -125,12 +125,16 @@ pub fn herzen( for i in 0..hand_size { let mut stack = Vec::with_capacity(player.len()); - println!("## Round {i}:"); + if OUTPUT { + println!("## Round {i}:"); + } for j in 0..player.len() { let index = (round_starting_player + j) % player.len(); - println!("# Player {index}"); + if OUTPUT { + println!("# Player {index}"); + } let ai = AdditionalInformation {}; @@ -146,7 +150,9 @@ pub fn herzen( hands[index].remove(card_index); - println!("# Player {index} played {played_card:?}"); + if OUTPUT { + println!("# Player {index} played {played_card:?}"); + } stack.push(played_card); } @@ -166,9 +172,11 @@ pub fn herzen( let cost = stack.iter().map(|c| c.cost()).sum::(); - println!( - "## Player {winner} takes the stack {stack:?} with {winning_card:?}, {cost} points" - ); + if OUTPUT { + println!( + "## Player {winner} takes the stack {stack:?} with {winning_card:?}, {cost} points" + ); + } points[winner] += cost; @@ -178,13 +186,17 @@ pub fn herzen( let remainder = &full_deck[hand_size * player.len()..]; let remainder_cost = remainder.iter().map(|c| c.cost()).sum::(); - println!( + if OUTPUT { + println!( "## Player {round_starting_player} takes the remaining cards {remainder:?}, {remainder_cost} points" ); + } points[round_starting_player] += remainder_cost; - println!("## Game ended. Points: {points:?}"); + if OUTPUT { + println!("## Game ended. Points: {points:?}"); + } points } diff --git a/src/main.rs b/src/main.rs index ff87753..b2be14c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,5 +130,5 @@ fn main() { let mut rng = SmallRng::from_entropy(); - game::herzen(&player, 0, &mut rng); + game::herzen::(&player, 0, &mut rng); }