diff options
| author | eug-vs <eugene@eug-vs.xyz> | 2022-09-13 21:12:18 +0300 | 
|---|---|---|
| committer | eug-vs <eugene@eug-vs.xyz> | 2022-09-13 21:12:18 +0300 | 
| commit | 7a4d16e5ebd45b15b0c4925894c25a81c2e135c6 (patch) | |
| tree | 6b26532d97128a6bd2df8c0c5976f7a74f8fd861 | |
| download | j1chess-7a4d16e5ebd45b15b0c4925894c25a81c2e135c6.tar.gz | |
chore: initialize project
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | Makefile | 23 | ||||
| -rw-r--r-- | README.md | 14 | ||||
| -rw-r--r-- | src/board.h | 29 | ||||
| -rw-r--r-- | src/main.c | 7 | ||||
| -rw-r--r-- | src/types.h | 5 | 
6 files changed, 82 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..65ce78c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +obj +main +.ccls-cache +*.exe diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8730842 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +CC=gcc +CFLAGS=-g -Ofast -fsanitize=address -static-libasan +SRC=src +OBJ=obj +SOURCES=$(wildcard $(SRC)/*.c) +OBJECTS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SOURCES)) +BIN=main + + +run: $(BIN) +	./$(BIN) + +build: $(BIN) + +$(BIN): $(OBJECTS) +	$(CC) $(CFLAGS) $(OBJECTS) -o $(BIN) + +$(OBJ)/%.o: $(SRC)/%.c $(SRC)/*.h +	$(CC) -c $< -o $@ + +clean: +	rm -r $(BIN) $(OBJ)/*.o + diff --git a/README.md b/README.md new file mode 100644 index 0000000..16f487f --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# j1chess +Chess engine powered by footguns! + +## Knowledge sources +https://www.chessprogramming.org/ + +## Board representation +Piece-centric [bitboard approach](https://www.chessprogramming.org/Bitboards) is used to represent the board. + +**LSF** (Least Significant File) square mapping is used, meaning that the square index is calculated as follows: +``` +square = 8 * rank + file; +``` + diff --git a/src/board.h b/src/board.h new file mode 100644 index 0000000..6cde670 --- /dev/null +++ b/src/board.h @@ -0,0 +1,29 @@ +#include "types.h" + +#define WHITE  0b0000 +#define BLACK  0b0001 + +#define PAWN   0b0000 +#define KNIGHT 0b0010 +#define BISHOP 0b0100 +#define ROOK   0b0110 +#define QUEEN  0b1000 +#define KING   0b1010 + +typedef QWORD Bitboard; + +typedef struct { +  Bitboard pieces[12]; +  BYTE side; +  BYTE castling_rights; +  BYTE en_passant_square; +} Board; + +const char* pieces[] = { +  "♟︎", "♙", +  "♞", "♘", +  "♝", "♗", +  "♜", "♖", +  "♛", "♕", +  "♚", "♔", +}; diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..e9902b2 --- /dev/null +++ b/src/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> +#include "board.h" + +int main() { +  printf("Size of board: %lu bytes\n", sizeof(Board)); +  return 0; +} diff --git a/src/types.h b/src/types.h new file mode 100644 index 0000000..4f95bb3 --- /dev/null +++ b/src/types.h @@ -0,0 +1,5 @@ +typedef unsigned char  BYTE; +typedef unsigned short WORD; +typedef unsigned long QWORD; + +  |