Skip to content

Instantly share code, notes, and snippets.

@Mr4k
Mr4k / differentialdithering.ipynb
Created September 9, 2020 02:32
DifferentialDithering.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Mr4k
Mr4k / artclasswithleibnitz.ipynb
Last active January 17, 2021 04:15
ArtClassWithLeibnitz.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
loss_grad = grad(loss)
loss_grad(circles) # this gives us the gradient with respect to the circles
def loss(circles):
return ((render(circles) - target) ** 2).sum()
@Mr4k
Mr4k / main.rs
Created January 6, 2020 16:31
Toy Lisp Interpreter
use std::env;
const EMPTY_NODE_ID: usize = 0;
// an intermediate representation for symbol data during the parse step
#[derive(Clone, Debug, PartialEq)]
struct ParseSymbol {
string: String,
debug_program_position: usize,
}
import numpy as np
from bintrees import FastAVLTree as AVLTree
import random
import time
def weightedRandom(weights):
"""
Draw from a general discrete distribution.
:param weights: A dictionary of weights that must sum to one.
:return: A random sample from it the distribution defined by the weights.
@Mr4k
Mr4k / q_learning.py
Created April 23, 2016 02:57
Learning Tic Tac Toe
import random
class QLearner:
def __init__(self, num_actions):
#play around with these parameters for different results
self.learning_rate = 0.03
self.discount_factor = 0.65
self.num_actions = num_actions
self.last_state = None
self.last_action = None