~macaptain/lkdo-chess

ref: 4a145c47f8fbfa347527f38f5105792fa96cc9e7 lkdo-chess/src/main.zig -rw-r--r-- 1.3 KiB
4a145c47Michael Captain Add king attacks with tests 9 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const std = @import("std");
const board = @import("board.zig");
const attack = @import("attack.zig");

const VERSION = "0.0.1";

fn uciLoop() !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 (uci_in == null) {
            return;
        } else if (std.mem.eql(u8, uci_in.?, "uci")) {
            try stdout.print("id name LKDO v{s}\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", .{});
        }
    }
}

/// Helper function for getting the value of a specific bitboard.
fn bitboardBuilder() void {
    var bitboard: u64 = 0;
    var rank: u6 = 0;
    while (rank < 8) : (rank += 1) {
        var file: u6 = 0;
        while (file < 8) : (file += 1) {
            const square = 8 * rank + file;
            bitboard |= @as(u64, 1) << square;
        }
    }
    board.printBitboard(bitboard);
}

pub fn main() !void {
    //uciLoop();
    //bitboardBuilder();
}