Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bitArtisan1 authored Jul 25, 2023
1 parent 3ebf708 commit 61cb265
Show file tree
Hide file tree
Showing 40 changed files with 7,871 additions and 0 deletions.
Binary file added Wize/final-book.bin
Binary file not shown.
Binary file added Wize/imgs/Interface (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wize/imgs/Neuron activation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wize/imgs/Per square value estimation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wize/imgs/print.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wize/imgs/score.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wize/imgs/weights_9931db908a9b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Wize/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Compiler and flags
CXX := g++
CXXFLAGS := -Ofast -pthread -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_SSE -msse

# Source files directory
SRC_DIR := src

# Source files
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
NNUE_SRCS := $(SRC_DIR)/nnue/nnue.cpp $(SRC_DIR)/nnue/misc.cpp
TINYCTHREAD_SRC := $(SRC_DIR)/tinycthread.c

# Output binary name
NAME := Wize

all: $(NAME)

$(NAME): $(SRCS) $(NNUE_SRCS) $(TINYCTHREAD_SRC)
$(CXX) $(CXXFLAGS) $(SRCS) $(NNUE_SRCS) $(TINYCTHREAD_SRC) -o $(NAME)

clean:
rm -f $(NAME)
Binary file added Wize/nn-9931db908a9b.nnue
Binary file not shown.
66 changes: 66 additions & 0 deletions Wize/src/Wize.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <iostream>
#include "defs.h"
#include <cstring>

int main(int argc, char *argv[])
{

std::cout << R"(
╭───────────────────────────────────────────────╮
│ (\=, │
│ // .\ │
│ (( \_ \ │
│ )) `\_) │
│ ██╗ ██╗██╗███████╗███████╗ (/ \ │
│ ██║ ██║██║╚══███╔╝██╔════╝ | _.-'| │
│ ██║ █╗ ██║██║ ███╔╝ █████╗ )___( │
│ ██║███╗██║██║ ███╔╝ ██╔══╝ (=====) │
│ ╚███╔███╔╝██║███████╗███████╗ }====={ │
│ ╚══╝╚══╝ ╚═╝╚══════╝╚══════╝ (_______) │
│ by: yanpuri │
╰───────────────────────────────────────────────╯
)" << std::endl;
AllInit();
// Start board
S_BOARD pos[1];
S_SEARCHINFO info[1];

info->quit = FALSE;
info->threadNum = 4; // Default 1 thread


HashTable->pTable = NULL;
InitHashTable(HashTable, 1024);
std::string input;
setbuf(stdin, NULL);
setbuf(stdout, NULL);
std::cout << "> Wize started successfully. Enter '\033[38;5;129muci\033[0m' to get started...\n";
char line[256];
while (TRUE) {
memset(&line[0], 0, sizeof(line));

fflush(stdout);
if (!fgets(line, 256, stdin))
continue;
if (line[0] == '\n')
continue;
if (!strncmp(line, "uci",3)) {
Uci_Loop(pos, info);
if(info->quit == TRUE) break;
continue;
} else if(!strncmp(line, "quit",4)) {
break;
}
else {
std::cout << "Unknown command: " << line << std::endl;
continue;
}
}
// Clean allocated memory
free(HashTable->pTable);
CleanPolyBook();
return 0;
};



6 changes: 6 additions & 0 deletions Wize/src/Wize.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#pragma once

#include <iostream>

// TODO: Reference additional headers your program requires here.
85 changes: 85 additions & 0 deletions Wize/src/attack.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include "defs.h"
#include "stdio.h"

const int KnDir[8] = { -8, -19, -21, -12, 8, 19, 21, 12 }; // Definitions for the movement of knights
const int RkDir[4] = { -1, -10, 1, 10 }; // Definitions for the movement of rooks
const int BiDir[4] = { -9, -11, 11, 9 }; // Definitions for the movement of bishops
const int KiDir[8] = { -1, -10, 1 ,10, -9, -11, 11, 9 }; // Definitions for the movement of kings

// Is a square under attack
int SqAttacked(const int sq, const int side, const S_BOARD* pos) {

// Variable definitions
int pce, index, t_sq, dir;

// Checking if the given parameters are valid
ASSERT(SqOnBoard(sq));
ASSERT(SideValid(side));
ASSERT(CheckBoard(pos));

// Pawns
if (side == WHITE) {
if (pos->pieces[sq - 11] == wP || pos->pieces[sq - 9] == wP) {
return TRUE;
}
}
else {
if (pos->pieces[sq + 11] == bP || pos->pieces[sq + 9] == bP) {
return TRUE;
}
}

// Knights
for (index = 0; index < 8; ++index) {
pce = pos->pieces[sq + KnDir[index]];
if (pce != OFFBOARD && IsKN(pce) && PieceCol[pce] == side) {
return TRUE;
}
}

// Rooks and Queens
for (index = 0; index < 4; ++index) {
dir = RkDir[index];
t_sq = sq + dir;
pce = pos->pieces[t_sq];
while (pce != OFFBOARD) {
if (pce != EMPTY) {
if (IsRQ(pce) && PieceCol[pce] == side) {
return TRUE;
}
break;
}
t_sq += dir;
pce = pos->pieces[t_sq];
}
}

// Bishops and Queens
for (index = 0; index < 4; ++index) {
dir = BiDir[index];
t_sq = sq + dir;
pce = pos->pieces[t_sq];
while (pce != OFFBOARD) {
if (pce != EMPTY) {
if (IsBQ(pce) && PieceCol[pce] == side) {
return TRUE;
}
break;
}
t_sq += dir;
pce = pos->pieces[t_sq];
}
}

// Kings
for (index = 0; index < 8; ++index) {
pce = pos->pieces[sq + KiDir[index]];
if (pce != OFFBOARD && IsKI(pce) && PieceCol[pce] == side) {
return TRUE;
}
}

return FALSE;
}


55 changes: 55 additions & 0 deletions Wize/src/bitboards.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "stdio.h"
#include "defs.h"

// Array of integers
const int BitTable[64] = {
63, 30, 3, 32, 25, 41, 22, 33, 15, 50, 42, 13, 11, 53, 19, 34, 61, 29, 2,
51, 21, 43, 45, 10, 18, 47, 1, 54, 9, 57, 0, 35, 62, 31, 40, 4, 49, 5, 52,
26, 60, 6, 23, 44, 46, 27, 56, 16, 7, 39, 48, 24, 59, 14, 12, 55, 38, 28,
58, 20, 37, 17, 36, 8
};

// Takes least significant bit and returns the index of that bit, then sets the bit to 0
int PopBit(U64* bb) {
U64 b = *bb ^ (*bb - 1);
unsigned int fold = (unsigned) ((b & 0xffffffff) ^ (b >> 32));
*bb &= (*bb - 1);
return BitTable[(fold * 0x783a9b23) >> 26];
};

// Takes bitboard, returns number of bits that are 1
int CountBits(U64 b) {
int r;
for (r = 0; b; r++, b &= b - 1);
return r;
};
// Print and visualize a bitboard on the screen
void PrintBitBoard(U64 bb) {

U64 shiftMe = 1ULL; // For shifting

// Indices for loops
int rank = 0;
int file = 0;
// Variables to store squares
int sq = 0;
int sq64 = 0;

printf("\n");
for (rank = RANK_8; rank >= RANK_1; --rank) {
for (file = FILE_A; file <= FILE_H; ++file) {
sq = FR2SQ(file, rank); // Getting 120 based square index
sq64 = SQ64(sq); // Convert to 64 based

if ((shiftMe << sq64) & bb) // If shifting 1ULL by the 64 based index and bitwise ended with bitboard, was nonzero
printf("X");
else
printf("-");

}
printf("\n");
}
printf("\n\n");
};


Loading

0 comments on commit 61cb265

Please sign in to comment.