hanabi.rs/src/main.rs

42 lines
996 B
Rust
Raw Normal View History

2016-03-06 01:54:46 +01:00
extern crate rand;
2016-03-06 10:35:19 +01:00
#[macro_use]
extern crate log;
2016-03-06 01:54:46 +01:00
mod game;
2016-03-06 07:49:40 +01:00
mod strategies;
2016-03-06 11:13:08 +01:00
mod info;
2016-03-06 01:54:46 +01:00
2016-03-07 06:44:17 +01:00
#[allow(unused_imports)]
use log::LogLevel::{Trace, Debug, Info, Warn, Error};
2016-03-06 10:35:19 +01:00
struct SimpleLogger;
impl log::Log for SimpleLogger {
fn enabled(&self, metadata: &log::LogMetadata) -> bool {
2016-03-07 06:44:17 +01:00
metadata.level() <= Debug
2016-03-06 10:35:19 +01:00
}
fn log(&self, record: &log::LogRecord) {
if self.enabled(record.metadata()) {
println!("{} - {}", record.level(), record.args());
}
}
}
2016-03-06 01:54:46 +01:00
fn main() {
2016-03-06 10:35:19 +01:00
log::set_logger(|max_log_level| {
2016-03-07 06:44:17 +01:00
max_log_level.set(log::LogLevelFilter::Trace);
2016-03-06 10:35:19 +01:00
Box::new(SimpleLogger)
2016-03-07 06:44:17 +01:00
}).unwrap();
2016-03-06 10:35:19 +01:00
2016-03-06 07:49:40 +01:00
let opts = game::GameOptions {
2016-03-06 01:54:46 +01:00
num_players: 4,
hand_size: 4,
2016-03-06 07:49:40 +01:00
num_hints: 8,
num_lives: 3,
};
2016-03-07 01:14:47 +01:00
let n = 1;
// strategies::simulate(&opts, &strategies::AlwaysDiscard, n);
// strategies::simulate(&opts, &strategies::AlwaysPlay, n);
strategies::simulate(&opts, &strategies::RandomStrategy, n);
2016-03-06 01:54:46 +01:00
}