Skip to content

Instantly share code, notes, and snippets.

View Butjok's full-sized avatar

Viktor Fedotov Butjok

View GitHub Profile
(use-modules (srfi srfi-1))
(use-modules (ice-9 format))
(define val cons)
(define stmt car)
(define expr cdr)
(define (compile x return?)
(cond ((number? x) (val "" (fmt "~a" x)))
((string? x) (val "" (fmt "~s" x)))
def pairs(l):
return zip(l[::2], l[1::2])
def vm(ops, env={}):
class closure:
def __init__(self, pc, env): self.pc, self.env = pc, env
def popn(n):
if len(stack) < n: print 'not enough elements for pop: %d needed, %d left' % (n, len(stack))
top = stack[-n:]
stack[-n:] = []
@Butjok
Butjok / vm.py
Created November 14, 2015 02:37
def pairs(l):
return zip(l[::2], l[1::2])
def vm(ops, env={}):
class closure:
def __init__(self, pc, env): self.pc, self.env = pc, env
def popn(n):
if len(stack) < n: print 'not enough elements for pop: %d needed, %d left' % (n, len(stack))
top = stack[-n:]
stack[-n:] = []
def lex(text):
sym = r'[\w+\-*/=<>]+'
toks = (
r';.*?\n\s*',
lambda m: None,
r'-?(\d+)?\.\d+(e-?\d+)?\s*',
lambda m: ['val', float(m.group(0))],
r'-?\d+\s*',
lambda m: ['val', int(m.group(0))],
r"'((?:[^'\\]|\\.)*)'\s*",
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections.Generic;
using System.Diagnostics;
// https://www.microsoft.com/en-us/research/wp-content/uploads/2004/12/tr-2004-136.pdf
@Butjok
Butjok / gist:90f57cfaf4365cdcc4ef21bea46fbdcb
Created July 12, 2018 11:14 — forked from McFunkypants/gist:87f07ac5e8affad34391
Sid Meier's 10 Rules of Game Design
Sid Meier's 10 Rules of Game Design
1. Choose a topic you have a passion for. Game Design is about creativity.
2. Do research after the game is done. Tap into the player’s brain.
3. Define your axioms, refine your axioms. Prototype, prototype, prototype; sit in all the chairs.
4. Double it or cut it in half. You are more wrong than you think.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Priority_Queue;
internal class Program
{
private const int infinity = 999;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
[JsonObject(MemberSerialization.OptIn)]
public class CircularStack<T>
{
[JsonProperty] public int maxVirtualCount;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Pool<T> where T : Component, ISpawnable
{
public HashSet<T> freeInstances = new HashSet<T>();
public Transform parent;
public T prefab;
using System;
using System.Collections.Generic;
public static class Observers
{
public static Dictionary<int, HashSet<Action>> observers = new Dictionary<int, HashSet<Action>>();
public static List<Action> list = new List<Action>();
public static void Notify(int entityId)
{