var buf: [512]u8 = undefined;
const stdin = std.io.getStdIn().reader();
const stdout = std.io.getStdOut().writer();
while (true) {
const input = try stdin.readUntilDelimiterOrEof(&buf, '\n') orelse break;
if (std.mem.eql(u8, input, "quit")) break;
if (std.mem.eql(u8, input, "isready")) _ = try stdout.write("readyok\n");
if (input.len >= 8) {
if (std.mem.eql(u8, input[0..8], "position")) {
try gs.parsePosition(input);
gs.show();
}
}
if (input.len >= 3) {
if (std.mem.eql(u8, input[0..3], "uci")) {
if (std.mem.eql(u8, input, "ucinewgame"))
try gs.parsePosition("position startpos")
else
_ = try stdout.write("id name pistike\nuciok\n");
}
}
if (input.len >= 2) {
if (std.mem.eql(u8, input[0..2], "go")) {
var res = try gs.parseGo(input);
_ = try stdout.write(res);
}
}
}