stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE | |
commit | b2bec083864cef9c987174088cd2ad5169032cc3 |
parent | 1ecc793cac68e9c8768895ee4d358cb6b3ce1c31 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Fri, 28 Jul 2023 16:46:31 +0200 |
Switch to cmake, use cul library
Diffstat:M | .clang-format | | | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------- |
M | .gitignore | | | ++---------------------------------------------------------- |
A | CMakeLists.txt | | | +++++++++++++++++++++++++++++ |
D | Makefile | | | --------------------------------------- |
M | src/CBoard.c | | | ++-- |
M | src/engine.c | | | ++-- |
6 files changed, 94 insertions(+), 122 deletions(-)
diff --git a/.clang-format b/.clang-format
@@ -1,25 +1,44 @@
---
Language: Cpp
# BasedOnStyle: LLVM
# BasedOnStyle: Microsoft
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignArrayOfStructures: Right
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: true
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortEnumsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
@@ -32,7 +51,7 @@ BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
@@ -49,8 +68,8 @@ BraceWrapping:
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
@@ -60,8 +79,8 @@ BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
@@ -71,6 +90,10 @@ DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- foreach
@@ -100,9 +123,10 @@ IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 2
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
@@ -121,15 +145,19 @@ PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyReturnTypeOnItsOwnLine: 1000
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RequiresClausePosition: OwnLine
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
@@ -143,6 +171,16 @@ SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
@@ -165,7 +203,7 @@ StatementAttributeLikeMacros:
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
diff --git a/.gitignore b/.gitignore
@@ -1,58 +1,2 @@
.ccls-cache/
.ccls
docs/*
bin
bin/*
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
build
.cache
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.25.2)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(
Engine
VERSION 0.0.0
DESCRIPTION "Chess engine and utilities"
HOMEPAGE_URL https://git.dimitrijedobrota.com/engine.git
LANGUAGES C
)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
file(GLOB sources "src/*.c")
add_executable(engine ${sources})
target_link_libraries(engine "cul")
set_target_properties(engine PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
target_include_directories(engine
PRIVATE "${PROJECT_SOURCE_DIR}/include"
)
diff --git a/Makefile b/Makefile
@@ -1,39 +0,0 @@
NAME = engine
CC = gcc
CFLAGS = -I include
LDFLAGS = -lm
SRC = src
OBJ = obj
BINDIR = bin
SRCS := $(wildcard $(SRC)/*.c)
OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
TRGT=$(BINDIR)/$(NAME)
ifeq ($(DEBUG),Y)
LDFLAGS += -lciid
CFLAGS += -Wall -Wextra -Werror -Wpedantic -fsanitize=address -ggdb
else
LDFLAGS += -lcii
CFLAGS += -Ofast -flto
endif
all: pre $(TRGT)
pre:
@mkdir -p $(BINDIR)
@mkdir -p $(OBJ)
$(TRGT): $(OBJS)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
$(OBJ)/%.o: $(SRC)/%.c
$(CC) -c $< -o $@ $(CFLAGS) $(LDFLAGS)
clean:
rm $(TRGT) $(OBJS)
.PHONY: all clean pre
diff --git a/src/CBoard.c b/src/CBoard.c
@@ -2,8 +2,8 @@
#include <stdio.h>
#include <string.h>
#include <cii/assert.h>
#include <cii/mem.h>
#include <cul/assert.h>
#include <cul/mem.h>
#include "CBoard.h"
#include "attack.h"
diff --git a/src/engine.c b/src/engine.c
@@ -7,8 +7,8 @@
#include "attack.h"
#include "utils.h"
#include <cii/assert.h>
#include <cii/mem.h>
#include <cul/assert.h>
#include <cul/mem.h>
/* DEBUGGING */