Skip to content

Instantly share code, notes, and snippets.

@foxor
foxor / sln.py
Created January 2, 2022 06:13
Markov chain win rate model
#!/usr/bin/env python3
class markov_node:
def __init__(self, name, outcomes):
self.name = name
self.probability = 0.0
self.incoming_probability = 0.0
self.outcomes = outcomes
def push(self):
for (probability, node) in self.outcomes:
using UnityEngine;
using System.Collections;
public class BusController : MonoBehaviour
{
protected static readonly float ATTACK_MODIFIER = 7f;
protected static readonly float FLIGHT_MODIFIER = 250f;
protected static readonly float BRAKE_MODIFIER = -0.7f;
protected static readonly float PITCH_CORRECT_TARGET_TIME = 0.2f;
#!/usr/bin/env python
class QMN:
def __init__(self, streak, total, chance):
self.streak = streak
self.total = total
self.chance = chance
def childNodes(self):
enemyChance = 0.1 * (self.streak + 1)
@foxor
foxor / AutoInstantiate.cs
Created June 4, 2018 14:52
Unity will serialize changes to scriptable objects to disk in edit mode. To avoid this, you need to instantiate objects, but only in edit mode. This script automates this process efficiently, and with minimal API overhead.
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public abstract class AutoInstantiate<T> where T : Object
{
[SerializeField]
private T data;
#if UNITY_EDITOR
@foxor
foxor / combo_mulligan_simulator.py
Created March 31, 2015 05:14
Figure out the hit-rate for a hearthstone combo
#!/usr/bin/env python
import random
_memoize = []
def fac(x):
if x < 0:
return 1
if len(_memoize) <= x:
_memoize.append(1 if x == 0 else x * fac(x - 1))
using UnityEngine;
using System.Collections;
public class GlobalSomething : MonoBehavior {
public static GlobalSomething Singleton;
public void Awake() {
Singleton = this;
}