Skip to content

Instantly share code, notes, and snippets.

@Michi83
Michi83 / GRAVITY.BAS
Created December 29, 2023 18:21
Gravity
'A gravity simulation of the solar system written in QuickBASIC
'Similar to something I wrote way back when I was still in school
'Units are km, kg and s
'Type declarations
TYPE vector
x AS DOUBLE
y AS DOUBLE
z AS DOUBLE
END TYPE
@Michi83
Michi83 / test.js
Last active April 3, 2019 18:45
Experiment with JS Array.prototype.includes
Array.prototype.equals = function (that) {
if (!Array.isArray(that)) {
return false
}
if (this.length !== that.length) {
return false
}
for (var i = 0; i < this.length; i++) {
if (this[i] !== that[i]) {
return false
@Michi83
Michi83 / brainfuck.py
Last active September 8, 2018 07:05
A Brainfuck interpreter
# A Brainfuck interpreter
from sys import argv, stdin, stdout
with open(argv[1], "r") as file:
# preparation
code = [] # the code without comments
codepointer = 0
data = 65536 * [0]
datapointer = 0
@Michi83
Michi83 / latrunculi.py
Last active July 5, 2018 18:44
A hypothetical reconstruction of the ancient Roman strategy game latrunculi.
from threading import Thread
from time import time
W = 1 # white
E = 0 # empty
B = -1 # black
# Tuples of two integers are used for coordinates. The first integer is rank,
# the second integer is file. Offsets are changes in coordinates as a result of
# moves. The following offsets describe rook-like and queen-like motion.
@Michi83
Michi83 / tinybasic.py
Created April 14, 2018 07:29
Implementation of Tiny BASIC using recursive descent
from collections import deque
# This is a demonstration of the recursive descent algorithm used to implement
# interpreters for a programming languages. As an example, Tiny BASIC is
# implemented here but of course the same technique can also be used to
# implement other languages as well.
#
# https://en.wikipedia.org/wiki/Tiny_BASIC
#
@Michi83
Michi83 / planets.py
Last active August 18, 2022 17:43
Gravity simulation of the solar system
import pygame
# units are kg, km and s
class Vector:
def __init__(self, x, y, z):
self.x = x
self.y = y