~macaptain/lkdo-chess

ref: f747faa3854d8b337509530928436ef5d9116b86 lkdo-chess/src/main.zig -rw-r--r-- 771 bytes
f747faa3Michael Captain Initial commit 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const std = @import("std");

const VERSION = "0.0.1";

fn uci_loop() !void {
    const stdin = std.io.getStdIn().reader();
    const stdout = std.io.getStdOut().writer();
    var line_buf: [2000]u8 = undefined;
    while (true) {
        const uci_in = (try stdin.readUntilDelimiterOrEof(line_buf[0..], '\n')).?;
        if (std.mem.eql(u8, uci_in, "uci")) {
            try stdout.print("id name LKDO v{}\n", .{VERSION});
            try stdout.print("id author macaptain\n", .{});
            try stdout.print("uciok\n", .{});
        } else if (std.mem.eql(u8, uci_in, "quit")) {
            return;
        } else if (std.mem.eql(u8, uci_in, "isready")) {
            try stdout.print("readyok\n", .{});
        }
    }
}

pub fn main() !void {
    try uci_loop();
}