Skip to content

Commit

Permalink
added config, edited UCIEngine to support limited depth in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRedLancer committed Apr 26, 2022
1 parent 23b15f0 commit e0209f9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/pychess/Players/CECPEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ def __sendAnalyze(self, inverse=False):
print("analyze", file=self.engine)
self.engineIsAnalyzing = True

if not conf.get("infinite_depth"):
self.__setDepth(conf.get("max_depth_spin"))
if not conf.get("infinite_analysis"):
loop = asyncio.get_event_loop()
loop.call_later(conf.get("max_analysis_spin"), self.__stop_analyze)
Expand Down
15 changes: 10 additions & 5 deletions lib/pychess/Players/UCIEngine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import collections
from lib.pychess.System import command

from pychess.compat import create_task
from pychess.Utils import wait_signal
Expand Down Expand Up @@ -433,7 +434,7 @@ def setOption(self, key, value):
def hasOption(self, key):
return key in self.options

# Internal
# Internal

def _newGame(self):
print("ucinewgame", file=self.engine)
Expand Down Expand Up @@ -476,11 +477,15 @@ def _searchNow(self, ponderhit=False):

if self.analysis_depth is not None:
commands.append("go depth %s" % self.analysis_depth)
elif conf.get("infinite_analysis"):
commands.append("go infinite")
else:
move_time = int(conf.get("max_analysis_spin")) * 1000
commands.append("go movetime %s" % move_time)
if not conf.get("infinite_depth"):
commands.append("go depth %s" % conf.get("max_depth_spin"))
else:
commands.append("go infinite")
if not conf.get("infinite_analysis"):
loop = asyncio.get_event_loop()
loop.call_later(conf.get("max_analysis_spin"), lambda : print("stop", file=self.engine))


if self.hasOption("MultiPV") and self.multipvSetting > 1:
self.multipvExpected = min(self.multipvSetting,
Expand Down
2 changes: 2 additions & 0 deletions lib/pychess/System/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ def _(text):
"saveOwnGames": True,
"dont_show_externals_at_startup": False,
"max_analysis_spin": 3,
"max_depth_spin": 20,
"variation_threshold_spin": 50,
"fromCurrent": True,
"shouldWhite": True,
"shouldBlack": True,
"ThreatPV": False,
"infinite_analysis": False,
"infinite_depth": True,
"opening_check": False,
"opening_file_entry": default_book_path,
"book_depth_max": 13,
Expand Down
2 changes: 2 additions & 0 deletions lib/pychess/widgets/preferencesDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ def on_invanalyzer_check_toggled(check):

uistuff.keep(self.widgets["max_analysis_spin"], "max_analysis_spin")
uistuff.keep(self.widgets["infinite_analysis"], "infinite_analysis")
uistuff.keep(self.widgets["infinite_depth"], "infinite_depth")
uistuff.keep(self.widgets["max_depth_spin"], "max_depth_spin")


# Sound initing
Expand Down

0 comments on commit e0209f9

Please sign in to comment.