Skip to content

Instantly share code, notes, and snippets.

@ekimekim
ekimekim / probability.py
Last active June 29, 2025 00:13
slots.py is a tool for analyzing the slot machine in The Blue Prince. The text log is experimental data of how often each symbol has appeared. probability.py is a standalone library for considering weighted outcomes.
import collections
import random
from fractions import Fraction
class Outcomes:
"""
Represents a set of possible outcomes along with the probability they'll occur.
Supports the following operations:
outcomes1 * outcomes2:
#!/bin/env python2
import array
import fcntl
import argh
LIRC_MODE_PULSE = 2
def ioc(dir, type, nr, size):
#!/bin/bash
gen-keys() {
for control in "$@"; do
echo $enter "$control" $down
done
}
# weird key names
up=Up
@ekimekim
ekimekim / throws.py
Created August 3, 2021 18:05
hacked together brute force solver for necrodancer blood shop throws
from collections import namedtuple
class Point(namedtuple('_Point', ['x', 'y'])):
def __add__(self, other):
return Point(self.x + other.x, self.y + other.y)
shopkeeper = Point(2, 1)
rune = Point(2, 5)
size = Point(5, 7)
gold_weapon = Point(1, 3)
#!/bin/env python2
import os
import re
import time
import argh
PATTERNS = {
from urllib import urlencode
import requests
import argh
def build_url(base, **kwargs):
return '{}?{}'.format(base, urlencode(kwargs))
import itertools as it
import argh
def get_tries(codes, permute, start, offset, hardcodes):
"""
codes is list of codes
permute is a permutation of (0, 1, 2) where the value at index i
is the index (MSD first) of the digit in the counting number to be used in that position.
// Proof of concept for exploring an idea I had with using rust's type system
// to manage the di/ei instructions on a Gameboy (if I ever get rust-on-gb working).
// It works as follows: We have a zero-sized IntFlag object. It's zero sized
// because it is NOT actually maintaining the state. It mediates access to the state
// at compile time by being borrowed.
// Each function that MAY disable interrupts (either in itself or a child func) must
// take a &mut IntFlag. It can then borrow that for an IntDisableGuard,
// as long as it releases it before the original borrow's lifetime expires (ie. by returning).
@ekimekim
ekimekim / combat_log.py
Created April 10, 2020 01:45
Battletech combat log script - consumes debug logging output from game and pretty prints relevant info
import os
import re
import time
import argh
PATTERNS = {
# Hard code Player 1 here to ignore uselss matches like "World"
0eJzEve/OHjdy7XsrG/N5FDT/k+dWDg4Cj0fbI4wtC5Kc7CDIvZ+WZ09EvuVFriarnnxJPLbEqq6HLFaTv1r9n3/6y8+/vf/0+cPHr3/6f/7Xf/7pw9f3v9z/0P3bP/+vP3348dePX+5/+//e//3jX9//n/sf3f2vv3z46eMPP//+177+x6f33/7a73/9/k8ff/jl9//9w5cv73/5y88fPv707pcffvzbh4/v34U//dd//X/3H/m395+/fPj14/2nci3eV9eu4u9///7j1w9fP7z/v/Y+/frl/l+//7H//NN/3P/3nc/lX9L957558S64f0n/9c+/9B//+vG3X/7y/vP/de+fPnz+9S+/fvr189c/3X/wjweM3YDXHw/ouwH/8uGnd+9/fv/j188ffnz36def3+OR679c/xzZ3//8RyOHbuRf3v/1w2+/7Ax+/fHgUWNwBzxP24OXYfA/DHi+/91fP3y+h/vH3+2f5P3/+fT5/Zcv7758+vnD16/3H7//26+/ff3029d/vefsr5/vgX7/4T/89LfJr547J9ofP2EhnPj6+YePX77Nr3d/ef8zaQ4EtBLmfrsX4OefPv96//9/GLz/zH+vvo93CLAHaf3A7Y0H/uCB0/qB3UXYO3jiSLjgDoP+j4mHfQjrqDuvOM8C8czhjb18YK8SzxcVn88T9pKiPUfYY5IVa+8i7CnmpdQIe0xi2kkLCdhj0tDJmux9iH/sg2dS084zB2DvbR46sdfPoQzsvc05f5QDTmLc+1CAD2/zkNY8RvY089C1nsf+bR56GuPF9nYR0/htajpJ9Rcxjd+mJqWtxYPU5G1rpn5WQRfeZivtCqIPA5jZ4W22MgwDcsG6kOrDABZcYAoppTAgF5icdhKG7u3Xg0UYZnnu02+/fKLeUuDo/Xvfpw+f3r/7+uu7fzwMFzk07qyKIu0M0XHAzqx64qODRq+H0UHjzrIMG52+DvHgxMCq7gHPFZ3S+OgEpPf/2SmFI0bfP725iN/i7To+2Uwz8Vu