From 73f32e859852a00f997e722d11073c1efb5e0319 Mon Sep 17 00:00:00 2001 From: TiynGER Date: Sat, 15 May 2021 02:10:29 +0200 Subject: [PATCH] project structure The project previously wasnt structured very well. Now the engine has its own module so its more visible what file belongs to what topic. --- .gitignore | 3 +++ src/{ => engine}/engine.nim | 4 ++-- src/{ => engine}/lichessBridge.nim | 8 ++++---- src/engine/nim.cfg | 1 + src/game.nim | 4 ++-- src/nim.cfg | 2 ++ tests/engineTest.nim | 2 +- 7 files changed, 15 insertions(+), 9 deletions(-) rename src/{ => engine}/engine.nim (98%) rename src/{ => engine}/lichessBridge.nim (96%) create mode 100644 src/engine/nim.cfg create mode 100644 src/nim.cfg diff --git a/.gitignore b/.gitignore index cd0cb80..898637f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +*.db + bin docs +pgn secret.nim diff --git a/src/engine.nim b/src/engine/engine.nim similarity index 98% rename from src/engine.nim rename to src/engine/engine.nim index 6869e13..7bad6a0 100644 --- a/src/engine.nim +++ b/src/engine/engine.nim @@ -1,6 +1,6 @@ import algorithm -import ./chess.nim +import chess type MoveTree = object @@ -184,7 +184,7 @@ proc bestMove*(chess: Chess, depth: int): Move = var tmpChess = chess tmpChess.checkedMove(move) var tmpEval = -tmpChess.negaMax(depth, LoVal, HiVal) - #echo("move:", moveToNotation(move, tmpChess.board), "; eval:", tmpEval) + echo("move:", moveToNotation(move, tmpChess.board), "; eval:", tmpEval) if tmpEval > bestEval: bestEval = tmpEval bestMove = move diff --git a/src/lichessBridge.nim b/src/engine/lichessBridge.nim similarity index 96% rename from src/lichessBridge.nim rename to src/engine/lichessBridge.nim index 12f4aa5..acec904 100644 --- a/src/lichessBridge.nim +++ b/src/engine/lichessBridge.nim @@ -1,9 +1,9 @@ import nimpy import asyncnet, asyncdispatch -import ./secret.nim -import ./chess.nim -import ./engine.nim +import chess +import engine/secret +import engine/engine let berserk = pyImport("berserk") @@ -11,7 +11,7 @@ var session = berserk.TokenSession(secret.api_token) var client = berserk.Client(session = session) let engineID = "tiyn-ychess" -let engineDifficulty = 3 +let engineDifficulty = 2 let toAccept = ["tiynger"] diff --git a/src/engine/nim.cfg b/src/engine/nim.cfg new file mode 100644 index 0000000..f944151 --- /dev/null +++ b/src/engine/nim.cfg @@ -0,0 +1 @@ +--outdir:"../../bin/src" diff --git a/src/game.nim b/src/game.nim index 76da237..127a5c3 100644 --- a/src/game.nim +++ b/src/game.nim @@ -1,7 +1,7 @@ import parseutils -import ./chess.nim -import ./engine.nim +import chess +import engine/engine proc runGameHotseat*(): void = ## Initializes and runs a game of chess as hotseat. diff --git a/src/nim.cfg b/src/nim.cfg new file mode 100644 index 0000000..5f03f93 --- /dev/null +++ b/src/nim.cfg @@ -0,0 +1,2 @@ +--outdir:"../bin/src" +--path:"." diff --git a/tests/engineTest.nim b/tests/engineTest.nim index bc9323a..6608f54 100644 --- a/tests/engineTest.nim +++ b/tests/engineTest.nim @@ -1,7 +1,7 @@ import einheit include chess -include engine +include engine/engine testSuite ChessTest of TestSuite: