Exemplo n.º 1
0
parser.add_argument('--th', type=int, default=2500)
args = parser.parse_args()

with open(args.hcp, 'rb') as f:
    f.seek(args.start * HuffmanCodedPos.itemsize)
    hcps = np.fromfile(f, HuffmanCodedPos, args.end - args.start)

print('read num', len(hcps))
delhcps = np.zeros(len(hcps), HuffmanCodedPos)

os.chdir(os.path.dirname(args.usi))
engine = Engine(args.usi)

for option in args.usi_options.split(','):
    k, v = option.split(':')
    engine.setoption(k, v)

engine.isready(print)

ptn = re.compile(r'score (cp|mate) ([+\-0-9]+)')

class Listener:
    def __init__(self):
        self.info1 = None
        self.info2 = None

    def __call__(self, line):
        self.info1 = self.info2
        self.info2 = line
listener = Listener()
Exemplo n.º 2
0
from cshogi.usi import Engine
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('engine')
parser.add_argument('model')
parser.add_argument('--gpus', type=int, default=1)
parser.add_argument('--threads', type=int, default=2)
parser.add_argument('--nodelimit', type=int, default=10000000)
parser.add_argument('--batch', type=int, default=128)
parser.add_argument('--byoyomi', type=int, default=1000)
parser.add_argument('--options')
args = parser.parse_args()

engine = Engine(args.engine, debug=True)
engine.setoption('USI_Ponder', 'false')
engine.setoption('Resign_Threshold', '0')
engine.setoption('PV_Interval', '0')
engine.setoption('DNN_Model', args.model)
engine.setoption('Byoyomi_Margin', '0')
engine.setoption('UCT_NodeLimit', str(args.nodelimit))
engine.setoption('DNN_Batch_Size', str(args.batch))
engine.setoption('ReuseSubtree', 'false')
engine.setoption('UCT_Threads', str(args.threads))
for i in range(2, args.gpus + 1):
    engine.setoption('UCT_Threads' + str(i), str(args.threads))
if args.options:
    for option in args.options.split(','):
        name, value = option.split(':')
        engine.setoption(name, value)
engine.isready()
Exemplo n.º 3
0
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--gpus', type=int, default=1)
parser.add_argument('--threads', type=int, default=2)
parser.add_argument('--hash', type=int, default=1048576)
parser.add_argument('--batch', type=int, default=128)
parser.add_argument('--engine',
                    default=r'H:\src\DeepLearningShogi\x64\Release\usi.exe')
parser.add_argument(
    '--model',
    default=r'F:\model\model_rl_val_fused_wideresnet10_selfplay_179')
args = parser.parse_args()

engine = Engine(args.engine, debug=True)
engine.setoption('USI_Ponder', 'false')
engine.setoption('DNN_Model', args.model)
engine.setoption('Byoyomi_Margin', '0')
engine.setoption('UCT_Hash', str(args.hash))
engine.setoption('DNN_Batch_Size', str(args.batch))
engine.setoption('ReuseSubtree', 'false')
engine.setoption('UCT_Threads', str(args.threads))
for i in range(2, args.gpus + 1):
    engine.setoption('UCT_Threads' + str(i), str(args.threads))
engine.isready()

positions = [
    '',
    '7g7f 7a6b 2g2f 4a3b 2f2e 8c8d 6i7h 5a4a 2e2d 2c2d 2h2d P*2c 2d2h 8d8e 3i3h 3c3d 3h2g 8e8f 8g8f 8b8f 2g3f 8f8d 3f4e 4a5b P*8e 8d8e 4e3d 8e3e 8h2b+ 3a2b B*5f 2c2d P*8b B*5e 8b8a+ 5e9i+ 8i7g L*5d 3g3f 3e3f 3d4e 5d5f 4e3f 5f5g+ N*6i 5g5f 8a9a P*3e 3f3e P*8h 7i8h 9i8i 5i6h B*6d 2h2f',
    '2g2f 8c8d 2f2e 4a3b 7g7f 8d8e 2e2d 2c2d 2h2d P*2c 2d2f 3c3d 6i7h 7a7b P*2d 2c2d 2f2d 5a4b 2d3d 2b3c 3d3f 3a2b 5i5h 3c8h+ 7i8h B*2g 3f2f 2g5d+ 8h7g 6c6d 3i3h 8e8f 8g8f 7c7d 3g3f 7d7e 7f7e P*7f 7g8h 8b8f P*8g 8f8d P*2d P*2c 2d2c+ 2b2c 3f3e P*2d',
    '7g7f 8b4b 2g2f 3c3d 5i6h 2b8h+ 7i8h 3a2b 3i4h 5a6b 4g4f 6b7b 4h4g 7b8b 9g9f 9c9d 4i5h 2b3c 6h7h 4b2b 4g5f 7a7b 8g8f 3c4d B*7g 2b5b 2f2e 5c5d 2e2d 5d5e 5f4g 2c2d 2h2d P*2b 8h8g 8c8d 7g6f 7b8c 3g3f 4a3b 2i3g 2a3c 8i7g 6c6d 6i6h 6a7b 8f8e 8d8e P*8d 8c7d 4f4e 3c4e 3g4e 4d4e 2d2e 4c4d 5g5f 9d9e 9f9e P*9h 9i9h N*8f 7h6i 8f9h+ 8g9h 9a9e P*9g B*4c N*8g 3d3e 2e2g L*2e P*2f 4c7f 7g8e 7d8e N*7e 7c7d 8d8c+ 7b8c',