Last active
January 16, 2025 17:13
-
-
Save sadimanna/53251ac681526f565bad9a2e17da316f to your computer and use it in GitHub Desktop.
Dummy Chess Engine for communicating with Chess GUI using UCI Protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import re | |
if __name__ == '__main__': | |
while True: | |
line = sys.stdin.readline().strip() #input() | |
tokens = [ x.strip().lower() for x in re.split("\s+", line.strip()) ] | |
if tokens[0] == "uci": | |
sys.stdout.write("id name DummyCE\n") | |
sys.stdout.write("id author TheOwl\n") | |
sys.stdout.write("uciok\n") | |
sys.stdout.flush() | |
elif tokens[0] == "isready": | |
sys.stdout.write("readyok\n") | |
sys.stdout.flush() | |
elif tokens[0] == "position": | |
pass | |
elif tokens[0] == "go": | |
sys.stdout.write("info string NNUE evaluation using nn-ad9b42354671.nnue enabled\n") | |
sys.stdout.write("info depth 1 seldepth 1 multipv 1 score cp 18 nodes 20 nps 4000 hashfull 0 tbhits 0 time 5 pv e2e4\n") | |
sys.stdout.write("info depth 2 seldepth 2 multipv 1 score cp 46 nodes 66 nps 11000 hashfull 0 tbhits 0 time 6 pv d2d4\n") | |
sys.stdout.write("info depth 3 seldepth 2 multipv 1 score cp 51 nodes 120 nps 20000 hashfull 0 tbhits 0 time 6 pv e2e4\n") | |
sys.stdout.write("info depth 4 seldepth 2 multipv 1 score cp 58 nodes 144 nps 18000 hashfull 0 tbhits 0 time 8 pv d2d4\n") | |
sys.stdout.write("info depth 5 seldepth 2 multipv 1 score cp 58 nodes 174 nps 15818 hashfull 0 tbhits 0 time 11 pv d2d4 a7a6\n") | |
sys.stdout.write("info depth 6 seldepth 7 multipv 1 score cp 34 nodes 1303 nps 81437 hashfull 0 tbhits 0 time 16 pv e2e4 c7c5 g1f3 b8c6 c2c3\n") | |
sys.stdout.write("info depth 7 seldepth 6 multipv 1 score cp 29 nodes 3126 nps 120230 hashfull 1 tbhits 0 time 26 pv d2d4 g8f6 e2e3 d7d5 c2c4 d5c4\n") | |
sys.stdout.write("info depth 8 seldepth 7 multipv 1 score cp 26 nodes 5791 nps 152394 hashfull 4 tbhits 0 time 38 pv g1f3 g8f6 d2d4 d7d5 e2e3\n") | |
sys.stdout.write("info depth 9 seldepth 9 multipv 1 score cp 31 nodes 8541 nps 174306 hashfull 5 tbhits 0 time 49 pv g1f3 c7c5 e2e4 e7e6 d2d4 c5d4 f3d4\n") | |
sys.stdout.write("info depth 10 seldepth 13 multipv 1 score cp 25 nodes 20978 nps 209780 hashfull 10 tbhits 0 time 100 pv e2e4 c7c5 g1f3 b8c6 f1c4 e7e6 e1g1 g8f6\n") | |
sys.stdout.write("info depth 11 seldepth 13 multipv 1 score cp 32 nodes 29040 nps 220000 hashfull 14 tbhits 0 time 132 pv e2e4 c7c5 c2c3 g8f6 e4e5 f6d5 d2d4\n") | |
sys.stdout.write("info depth 12 seldepth 14 multipv 1 score cp 38 nodes 41207 nps 242394 hashfull 18 tbhits 0 time 170 pv e2e4 e7e6 d2d4 d7d5 b1c3 d5e4 c3e4\n") | |
sys.stdout.flush() | |
elif tokens[0]=="stop": | |
sys.stdout.write("info depth 13 seldepth 14 multipv 1 score cp 38 nodes 45531 nps 247451 hashfull 21 tbhits 0 time 184 pv e2e4 e7e6 d2d4 d7d5 b1c3 d5e4 c3e4\n") | |
sys.stdout.write("bestmove e2e4 ponder e7e6\n") | |
sys.stdout.flush() | |
elif tokens[0] == "quit": | |
sys.exit(0) | |
else: | |
sys.stdout.write("Unknown Command\n") | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment