playMoves now in zig
This commit is contained in:
parent
ca1e62397c
commit
eccd8efdba
@ -1,5 +1,5 @@
|
|||||||
#ifndef EVAL_H
|
#ifndef EVAL_H
|
||||||
#define EVAL_H
|
#define EVAL_H
|
||||||
move *findBest(move* move, size_t size, game* g);
|
move *findBest(move* move, long long size, game* g);
|
||||||
void makeMove(game *g, move* m);
|
void makeMove(game *g, move* m);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
18
src/main.zig
18
src/main.zig
@ -3,6 +3,7 @@ const c = @cImport({
|
|||||||
@cInclude("main.h");
|
@cInclude("main.h");
|
||||||
@cInclude("types.h");
|
@cInclude("types.h");
|
||||||
@cInclude("help.h");
|
@cInclude("help.h");
|
||||||
|
@cInclude("eval.h");
|
||||||
});
|
});
|
||||||
|
|
||||||
const uciTag = enum {
|
const uciTag = enum {
|
||||||
@ -101,12 +102,17 @@ fn fenGame(str: []const u8, alloc: std.mem.Allocator) [*c]c.game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn playMoves(game: [*c]c.game, str: []const u8) [*c]c.game {
|
fn playMoves(game: [*c]c.game, str: []const u8) [*c]c.game {
|
||||||
var buffer: [2560]u8 = undefined; //this is bad
|
if (str.len < 4) return game;
|
||||||
const len = @min(str.len, buffer.len - 1);
|
var splitItr = std.mem.splitSequence(u8, str, " ");
|
||||||
@memcpy(buffer[0..len], str[0..len]);
|
while (splitItr.next()) |moveString| {
|
||||||
buffer[len] = 0;
|
var move: c.move = .{ .To = 0, .From = 0, .Promo = 0 };
|
||||||
|
if (moveString.len < 4) continue;
|
||||||
return c.playMoves(game, &buffer);
|
move.From = (moveString[0] - 'a') + (moveString[1] - '1');
|
||||||
|
move.To = (moveString[2] - 'a') + (moveString[3] - '1');
|
||||||
|
move.Promo = if (moveString.len == 5) moveString[4] else 0;
|
||||||
|
c.makeMove(game, &move);
|
||||||
|
}
|
||||||
|
return game;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uciGo(game: *c.game) []const u8 {
|
fn uciGo(game: *c.game) []const u8 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user