Skip to content

Instantly share code, notes, and snippets.

View AndyGrant's full-sized avatar

Andrew Grant AndyGrant

View GitHub Profile
#!/usr/bin/env python3
import argparse
import os
import subprocess
from multiprocessing import Pool
CMD_SEQUENCE = [
'setoption name Minimal value true',
#!/usr/bin/env python3
# Given a .pgn file containing a single game, attempt to create a series of UCI commands
# for the specified player, which aims to perfectly recreate the game, down to the node.
#
# Bugs, oddities, or just interesting situations, are often seen in PGNs from games played.
# Those games are almost always played with standard Fischer time controls. As a result,
# reproducing those games can be very challenging.
#
# FastChess, and OpenBench's fork of cutechess, supply the node counters most recently
#!/usr/bin/env python3
import argparse
import chess
import chess.pgn
import sys
import traceback
import io
from subprocess import Popen, PIPE
import typing
import multiprocessing
class BatchedExecutionPool():
def __init__(
self,
input_generator : typing.Generator,
process_function : typing.Callable[..., typing.Any],
process_function_args : typing.Optional[typing.Iterable[typing.Any]]
import argparse
import chess
import chess.pgn
def iterate_uci_options(unknown):
for arg in unknown:
if '=' in arg and arg.startswith('--option.'):
yield arg[len('--option.'):].split('=')
def main():
#!/bin/python3
import numpy as np
import argparse
from network import Network
def check_for_overflow(acc_weights, acc_biases):
# Given the accum weights (L1, 22528), and accum biases (L1), determine a bound on
#!/bin/python3
import argparse
import chess
import chess.pgn
import chess.syzygy
import io
import multiprocessing
import numpy as np
import sys
#!/bin/python3
import argparse
import chess
import chess.pgn
from subprocess import Popen, PIPE, call
from multiprocessing import Process, Queue
class Engine():
#!/bin/python3
import os
from itertools import combinations_with_replacement
def tablebase_names(K=6):
letters = ['', 'Q', 'R', 'B', 'N', 'P']
# Generate many potential K[] v K[], including all valid ones
@AndyGrant
AndyGrant / sim.py
Last active January 25, 2023 11:59
from random import uniform
from concurrent.futures import ThreadPoolExecutor
ITERATIONS = 1000 # Number of times to run the simulation, to reduce variance
LENGTH = 300 * 1000 # Fight is 300 seconds, or 300,000 milliseconds
AA_SPEED = LENGTH / 154.0 # We just compute your in-practice AA-speed, based on the first sim
BASE_CD = 45 * 1000 # This is the CD of Wake of ashes. We assume at-least 1 cast per 45s
INITIAL_CAST = 5.875 * 1000 # According to your first sim, you do not press Wake until this time
PROC_RATE = 0.042 # This is the probability of getting a Wake proc on an auto attack