working knightCalc
This commit is contained in:
parent
94b501fd17
commit
c1eade9440
24
src/move.zig
24
src/move.zig
@ -81,8 +81,28 @@ pub fn knightMove(g: *types.game, arr: *std.ArrayList(types.move)) void {
|
||||
}
|
||||
|
||||
fn knightCalc(index: u8) u64 {
|
||||
_ = index;
|
||||
return @as(u64,1)<<32;
|
||||
var moves: u64 = 0;
|
||||
const offsets = [_]i8{ 17, -17, 15, -15, 10, -10, 6, -6 };
|
||||
var cnt: u8 = undefined;
|
||||
for (offsets) |off| {
|
||||
if (off > 0) {
|
||||
cnt = index + @abs(off);
|
||||
} else if (index > @abs(off)) { //Icky bad that zig makes me do
|
||||
cnt = index - @abs(off);
|
||||
}
|
||||
const fromFile: i32 = index % 8;
|
||||
const toFile: i32 = cnt % 8;
|
||||
const fromRank: i32 = index / 8;
|
||||
const toRank: i32 = cnt / 8;
|
||||
|
||||
const fileDiff = @abs(fromFile - toFile);
|
||||
const rankDiff = @abs(fromRank - toRank);
|
||||
if (!((fileDiff == 1 and rankDiff == 2) or
|
||||
(fileDiff == 2 and rankDiff == 1)) or cnt > 63)
|
||||
continue;
|
||||
moves = moves | @as(u64, 1) << @truncate(cnt);
|
||||
}
|
||||
return moves;
|
||||
}
|
||||
|
||||
fn bitboardToMoves(start: u8, moves: u64, arr: *std.ArrayList(types.move)) void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user