aboutsummaryrefslogtreecommitdiff
path: root/src/clock.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-02-26 23:26:51 +0300
committereug-vs <eugene@eug-vs.xyz>2023-02-26 23:27:20 +0300
commit8e7ac2814c4a92eba79f9c626ad14ac0b7bfef3f (patch)
treeda30e36423d5b1aa4aaaa2666b985e9674680850 /src/clock.rs
parent54e72754d0fae2b2768b66c39c72e9afaba0cba8 (diff)
downloadchessnost-8e7ac2814c4a92eba79f9c626ad14ac0b7bfef3f.tar.gz
feat: add clock and time management to UCI
Diffstat (limited to 'src/clock.rs')
-rw-r--r--src/clock.rs22
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],
+ }
+ }
+}