Compare commits

..

No commits in common. "94b501fd17f1634b99ea35fce475f14ed5f16aef" and "1d41b76fa8078d6354e87baff691d9d06aff1283" have entirely different histories.

2 changed files with 2 additions and 28 deletions

View File

@ -60,7 +60,7 @@ fn uciPos(str: []const u8, alloc: std.mem.Allocator) *types.game {
} }
fn fenGame(str: []const u8, alloc: std.mem.Allocator) *types.game { fn fenGame(str: []const u8, alloc: std.mem.Allocator) *types.game {
var pos: u8 = 63; var pos: u8 = 0;
var space: u8 = 0; var space: u8 = 0;
var g = alloc.create(types.game) catch unreachable; var g = alloc.create(types.game) catch unreachable;
g.* = std.mem.zeroes(types.game); g.* = std.mem.zeroes(types.game);
@ -84,7 +84,7 @@ fn fenGame(str: []const u8, alloc: std.mem.Allocator) *types.game {
const set: *u64 = mov.charToSet(g, chr); const set: *u64 = mov.charToSet(g, chr);
const bit: u64 = @as(u64, 1) << @truncate(pos); const bit: u64 = @as(u64, 1) << @truncate(pos);
set.* |= bit; set.* |= bit;
pos -= 1; pos += 1;
} }
return g; return g;
} }

View File

@ -59,32 +59,6 @@ pub fn charToSet(g: *types.game, chr: u8) *u64 {
// pub fn pawnMove(arr: std.ArrayList(c.move)) void { // pub fn pawnMove(arr: std.ArrayList(c.move)) void {
// const move = c.move{ .From = 8, .To = 16, .Promo = 0 }; // const move = c.move{ .From = 8, .To = 16, .Promo = 0 };
// } // }
pub fn knightMove(g: *types.game, arr: *std.ArrayList(types.move)) void {
const moveLut: [64]u64 = comptime blk: {
var value: [64]u64 = undefined;
for (0..64) |i| {
value[i] = knightCalc(@truncate(i));
}
break :blk value;
};
const set = if (g.whiteToMove) &g.white.knights else &g.black.knights;
const fset: u64 = if (g.whiteToMove) @as(u64, c.fullSet(@ptrCast(&g.white))) else @as(u64, c.fullSet(@ptrCast(&g.black)));
var val = set.*; //local copy
const n = @popCount(val);
for (0..n) |_| {
const pos = @ctz(val);
const moves = moveLut[pos] & ~fset;
val = val ^ (@as(u64, 1) << @truncate(pos));
bitboardToMoves(pos, moves, arr);
}
}
fn knightCalc(index: u8) u64 {
_ = index;
return @as(u64,1)<<32;
}
fn bitboardToMoves(start: u8, moves: u64, arr: *std.ArrayList(types.move)) void { fn bitboardToMoves(start: u8, moves: u64, arr: *std.ArrayList(types.move)) void {
var lmoves = moves; var lmoves = moves;
while (lmoves != 0) { while (lmoves != 0) {