This crate contains a small C library to access some functionality of wildbg
.
In contrast to the web
API this library offers fewer features and requires more manual work to set up. Only use it if you have existing C code and no other way to connect that to wildbg
.
You can see the API in the header file: crates/wildbg-c/wildbgh.h
.
Execute the following from the project's root folder.
cargo build --package wildbg-c --lib --release
The shared library file created may be called wildbg.dll
or wildbg.so
, depending on your operating system.
cp target/release/libwildbg.a $YOUR_C_PROJECT_FOLDER
Replace $YOUR_C_PROJECT_FOLDER
with the correct path):
cp crates/wildbg-c/wildbg.h $YOUR_C_PROJECT_FOLDER
cp -r neural-nets $YOUR_C_PROJECT_FOLDER
#include <stdio.h>
#include "wildbg.h"
int main() {
// Initialize engine:
Wildbg *wildbg = wildbg_new();
// Define position and print winning probability:
int starting[] = {0, -2, 0, 0, 0, 0, 5, 0, 3, 0, 0, 0, -5, 5, 0, 0, 0, -3, 0, -5, 0, 0, 0, 0, 2, 0,};
CProbabilities p = probabilities(wildbg, &starting);
printf("The estimated probability to win is %.2f percent.\n", 100 * p.win);
// Specify 1 pointer game type:
BgConfig config = { .x_away = 1, .o_away = 1 };
// Find and print best move:
CMove move = best_move(wildbg, &starting, 3, 1, &config);
printf("The computer would make the following moves:\n")
for (int i = 0; i < move.detail_count; i ++){
printf("\tfrom %d to %d.\n", move.details[i].from, move.details[i].to);
}
// Deconstruct the engine and free the memory:
wildbg_free(wildbg);
}
cd $YOUR_C_PROJECT_FOLDER
gcc main.c libwildbg.a