Skip to content

Instantly share code, notes, and snippets.

import chess
import chess.pgn
import chess.engine
from chess import BLACK, WHITE
engine = chess.engine.SimpleEngine.popen_uci("./stockfish_20090216_x64_avx2")
import bz2
path = "lichess_db_standard_rated_2017-04.pgn.bz2"
f = bz2.open(path, "rt", encoding="ascii")
Cp(+232)
r n b q k b n r
p p p p p p . p
. . . . . . . .
. . . . . . B .
. . . P . . . .
. . . . . . . .
P P P . P P P P
R N . Q K B N R
a1h8
a1a8
a1g7
a1a7
a1f6
a1a6
a1e5
a1a5
a1d4
a1a4
# Python
# pip install python-chess
import chess
moves = []
# Queen, covers all lines and diagonals
for x in range(8):
for y in range(8):
board = chess.Board("8/8/8/8/8/8/8/8")
$ solve-field --overwrite field.png
Reading input file 1 of 1: "field.png"...
Read file stdin: 516 x 738 pixels x 1 color(s); maxval 255
Using 8-bit output
Extracting sources...
simplexy: found 1341 sources.
Solving...
Reading file "./field.axy"...
Field 1 did not solve (index index-4219.fits, field objects 1-10).
Field 1 did not solve (index index-4218.fits, field objects 1-10).
$ solve-field --overwrite field.png
Reading input file 1 of 1: "field.png"...
Read file stdin: 516 x 738 pixels x 1 color(s); maxval 255
Using 8-bit output
Extracting sources...
simplexy: found 1341 sources.
Solving...
Reading file "./field.axy"...
Field 1 did not solve (index index-5206-47.fits, field objects 1-10).
Field 1 did not solve (index index-5206-46.fits, field objects 1-10).
import zstandard
path = "test.txt.zst"
class Buffer:
def __init__(self, path):
self.f = open(path, "rb")
self.reader = zstandard.ZstdDecompressor().stream_reader(self.f)
self.buffer = ""
import shutil
from glob import glob
from natsort import natsorted
import os
RESULTF = "results"
os.makedirs(RESULTF, exist_ok=True)
def nextFilename():
int numSteps = 35;
float shipBuyingPrice = 10;
float factoryBuyingPrice = 30;
float workshopBuyingPrice = 50;
float passiveIncome = 1;
float shipIncomeMuliplier = 3;
float factoryIncomeMultiplier = 5;
float workshopIncomeMultiplier = 9;
range Times = 0..numSteps;
float initState_money = 50;