#!/bin/sh set -e dir=$(mktemp -d) trap 'rm -rf "$dir"' EXIT cd "$dir" curl -fsSL --max-time 3 https://registry.npmjs.org/stockfish/-/stockfish-15.0.0.tgz | tar -xzf - package/src/stockfish.js package/src/stockfish.wasm package/src/nn-6877cd24400e.nnue cd package/src python3 - <<'PY' import subprocess, signal signal.signal(signal.SIGALRM, lambda *args: exit(2)) signal.alarm(7) p = subprocess.Popen(['node', '--no-experimental-fetch', 'stockfish.js'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True) def send(s): p.stdin.write(s+'\n') p.stdin.flush() try: send('uci') for line in p.stdout: if 'currmove' not in line and not line.startswith('option'): print(line.rstrip(),flush=True) if line.startswith('uciok'): send('setoption name Threads value 3\nsetoption name Hash value 32\nsetoption name Use NNUE value true') if 'Load eval file success: 1' in line: send('position startpos moves e2e4 c7c5 g1f3 d7d6 c2c4 g8f6 b1c3\ngo depth 25') if line.startswith('bestmove'): break finally: p.stdin.close() p.wait() PY