Fork channel

Create a new channel as a copy of main.

Rename channel

Rename main to:

Delete channel

Delete main? This cannot be undone.

snake.zig
const io = @import("io.zig");
const Map = @import("map.zig");
const Cursor = @import("cursor.zig").Self;

body: Map,
head: Cursor,
tail: Cursor,

const Self = @This();

pub fn init(start: Cursor) Self {
    return .{
        .head = start,
        .tail = start,
        .body = .{},
    };
}

pub fn pushdir(self: *Self, dir: u2) void {
    self.body.store(self.head, dir);
    self.head.dir = dir ^ 2;
}

pub fn popdir(self: *Self) void {
    self.body.load(&self.tail);
    self.body.zero(self.tail);
}

pub fn collide(self: Self) bool {
    return self.head.mask() & self.body.empty() == 0;
}

pub fn empty(self: Self) u64 {
    return self.body.empty() & ~self.head.mask();
}

//todo
pub fn print() void {
    unreachable;
}