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() 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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h7g 7a6b 1f1e 5a4b 2h6h 5c5d 3i3h 4b3b 7i7h 2b4d 7h6g 4d5c 6h8h 7c7d 5i4h 6a5b 4h3i 2a3c 4g4f',
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() board = Board() p = 0