Skip to content

Instantly share code, notes, and snippets.

@jamis
jamis / sidewinder.rb
Created January 1, 2011 04:12
An implementation of the Sidewinder algorithm for maze generation.
# --------------------------------------------------------------------
# An implementation of the Sidewinder algorithm for maze generation.
# This algorithm is kind of a cross between the trivial Binary Tree
# algorithm, and Eller's algorithm. Like the Binary Tree algorithm,
# the result is biased (but not as heavily).
#
# Because the Sidewinder algorithm only needs to consider the current
# row, it can be used (like the Binary Tree and Eller's algorithms)
# to generate infinitely large mazes.
# --------------------------------------------------------------------
@jamis
jamis / recursive-division.rb
Created January 1, 2011 03:03
An implementation of the "Recursive Division" algorithm for maze generation.
# --------------------------------------------------------------------
# An implementation of the "Recursive Division" algorithm. This is a
# kind of fractal maze algorithm, recursively dividing the maze into
# smaller and smaller cells. This algorithm stops at the integer
# boundary, but theoretically the algorithm could continue infinitely
# to smaller and smaller scales.
#
# Note that this algorithm is implemented as a "wall adder", rather
# than a "passage carver", so the meaning of the bits in each cell
# is reversed: instead of the S bit (for instance) meaning "a passage
@jamis
jamis / recursive-backtracker.rb
Created December 24, 2010 22:41
Implementation of the recursive backtracking algorithm for maze generation
# Recursive backtracking algorithm for maze generation. Requires that
# the entire maze be stored in memory, but is quite fast, easy to
# learn and implement, and (with a few tweaks) gives fairly good mazes.
# Can also be customized in a variety of ways.
DIRS = (N, S, E, W = 1, 2, 4, 8)
DX = { E => 1, W => -1, N => 0, S => 0 }
DY = { E => 0, W => 0, N => -1, S => 1 }
OPPOSITE = { E => W, W => E, N => S, S => N }
@jamis
jamis / kruskals.rb
Created December 28, 2010 04:16
An implementation of Kruskal's algorithm for generating mazes.
# --------------------------------------------------------------------
# An implementation of Kruskal's algorithm for generating mazes.
# Fairly expensive, memory-wise, as it requires memory proportional
# to the size of the entire maze, and it's not the fastest of the
# algorithms (what with all the set and edge management is has to
# do). Also, the mazes it generates tend to have a lot of very short
# dead-ends, giving the maze a kind of "spiky" look.
# --------------------------------------------------------------------
# NOTE: the display routine used in this script requires a terminal
# that supports ANSI escape sequences. Windows users, sorry. :(
@jamis
jamis / ellers.rb
Created December 24, 2010 03:17
An implementation of Eller's algorithm for generating mazes
# --------------------------------------------------------------------
# Eller's algorithm for maze generation. Novel in that it only
# requires memory proportional to the size of a single row; this means
# you can generate "bottomless" mazes with it, that just keep going
# and going and going, using not only constant memory, but little
# memory in general.
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# 1. Allow the maze to be customized via command-line parameters
@jamis
jamis / recursive-backtracker2.rb
Created December 27, 2010 04:36
An implementation of the recursive backtracking algorithm that *gasp* actually uses recursion.
# --------------------------------------------------------------------
# Recursive backtracking algorithm for maze generation. Requires that
# the entire maze be stored in memory, but is quite fast, easy to
# learn and implement, and (with a few tweaks) gives fairly good mazes.
# Can also be customized in a variety of ways.
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# 1. Allow the maze to be customized via command-line parameters
# --------------------------------------------------------------------
@jamis
jamis / weave.rb
Created March 4, 2011 05:23
A "weave" maze implementation, using the Growing Tree maze algorithm.
# --------------------------------------------------------------------
# An implementation of a "weave" maze (with over/under passages),
# using the Growing Tree maze generation algorithm.
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# Helper data and methods
# --------------------------------------------------------------------
N, S, E, W, U = 0x01, 0x02, 0x04, 0x08, 0x10
@jamis
jamis / Easy Marshmallow Recipe
Created December 10, 2009 22:38
Easy Gourmet Marshmallows
EASY MARSHMALLOWS
-----------------
Marshmallows are perhaps one of the simplest confections you can make. They only
require a handful of ingredients, a batch can be thrown together in 10-15 minutes
(plus *cough* 3 hours for them to set), and you can flavor them however you like.
(You haven't LIVED until you've had coconut marshmallows!)
Hardware needed:
@jamis
jamis / Basic Baechu Kimchi
Last active May 23, 2020 21:18
Basic Baechu Kimchi
BASIC BAECHU KIMCHI
--------------------------------------------------------------------------
Baechu (Napa cabbage) kimchi is one of the staple foods in Korea. Spicy
and tangy, it is typically served as a side dish, with rice, but is also
found in various Korean soups and stews.
This basic version has just the fundamentals; once you're comfortable
with this version, you might try adding shredded carrots, Daikon radish,
pickled baby shrimp, or any number of other things. Search around online
@jamis
jamis / Basic Oi (Cucumber) Kimchi
Created November 6, 2010 20:07
Basic Oi (Cucumber) Kimchi
BASIC OI (CUCUMBER) KIMCHI
--------------------------------------------------------------------------
Oi (cucumber) kimchi is a delicious, refreshing variation on the
traditional Korean kimchi recipe.
This particular recipe is a modified version of the recipe posted by Dr.
Ben Kim, at http://www.drbenkim.com/how-to-make-cucumber-kim-chi.htm.
--------------------------------------------------------------------------