Skip to content

Instantly share code, notes, and snippets.

View neiled's full-sized avatar

Neil Edwards neiled

View GitHub Profile
public void AddDoors(Level level)
{
for (int y = RoomStart.Y - 1; y <= RoomStart.Y + Height; y++)
{
for (int x = RoomStart.X-1; x <= RoomStart.X + Width; x ++)
{
if (y != RoomStart.Y - 1 && y != RoomStart.Y + Height && x != RoomStart.X - 1 && x != RoomStart.X + Width)
continue;
if (y < 0) continue;
@neiled
neiled / min_spanning_tree
Created February 7, 2014 16:23
min spanning tree
private void connectRooms(List<Room> rooms)
{
/*
Input: A non-empty connected weighted graph with vertices V and edges E (the weights can be negative).
Initialize: Vnew = {x}, where x is an arbitrary node (starting point) from V, Enew = {}
Repeat until Vnew = V:
Choose an edge {u, v} with minimal weight such that u is in Vnew and v is not
* (if there are multiple edges with the same weight, any of them may be picked)
Add v to Vnew, and {u, v} to Enew
Output: Vnew and Enew describe a minimal spanning tree