diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-02-26 23:26:51 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-02-26 23:27:20 +0300 |
commit | 8e7ac2814c4a92eba79f9c626ad14ac0b7bfef3f (patch) | |
tree | da30e36423d5b1aa4aaaa2666b985e9674680850 /src/clock.rs | |
parent | 54e72754d0fae2b2768b66c39c72e9afaba0cba8 (diff) | |
download | chessnost-8e7ac2814c4a92eba79f9c626ad14ac0b7bfef3f.tar.gz |
feat: add clock and time management to UCI
Diffstat (limited to 'src/clock.rs')
-rw-r--r-- | src/clock.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/clock.rs b/src/clock.rs new file mode 100644 index 0000000..896307a --- /dev/null +++ b/src/clock.rs @@ -0,0 +1,22 @@ +use std::time::Duration; + +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Clock { + pub time: [Duration; 2], // White, Black + pub increment: [Duration; 2], +} + +impl Default for Clock { + fn default() -> Self { + Self::new(Duration::from_secs(60 * 5), Duration::from_secs(3)) + } +} + +impl Clock { + pub fn new(time: Duration, increment: Duration) -> Self { + Self { + time: [time, time], + increment: [increment, increment], + } + } +} |