Skip to content

Instantly share code, notes, and snippets.

# I removed the big tag up top for now. Feel free to add it if you like
# Also removed the '#!/bin/python' bit as this script will never be run
# The namedtuple will be used for handling locations
from collections import namedtuple
# I moved the grid to a separate file because it cluttered up this one.
# Might as well keep the ugly contained, ya know?
from grid import grid
"""The grid representing the Sleuth game board
Each cell in the two dimensional list represents a tile in the game. There are
three types of tiles that exist: inaccessable, normal, and door tiles. Tiles
are traversed only in the four cardinal directions (N, S, E, W). As such,
there exist two types of doors, North/South and East/West doors. The numbers
representing these tiles are defined as follows:
0 : Inaccessable Tile
1 : Normal Tile
@r3
r3 / decorators.py
Created June 25, 2013 04:56
Review decorators
def increment_result(func):
def wrapper(*args, **kwargs):
return func(*args, **kwargs) + 1
return wrapper
@increment_result
def square_it(number):
return number * number
@r3
r3 / gen.py
Created June 25, 2013 05:14
Teaching generators
from math import sqrt
def count(start, step):
"""Happens to be included in the standard library"""
number = int(start)
while True:
yield number
start += number
import random
import json
CONTENT_PATH = './content.json'
DEBUG = True
#raw_input = input # Hack for Python 3
class Scene(object):
{
"room_one": [
"You are in a deep, dark forest. You have wandered off the trail, and have lost your way.",
"A column of chimney smoke appears over the treetops in the failing light. What do you do?"
],
"cottage": [
"You enter the cottage. A table as tall as you stand in the center of the giant room,",
"and whole timbers burn in a cavernous fireplace. A cow on a spit roasts in the flames.",
"The room fills with the smell of perfectly done roast beef. Thundering footsteps",
"come closer and closer until a giant appears in the doorway be"
@r3
r3 / old_files.py
Last active August 29, 2015 14:10
import datetime
import itertools
import os
import pathlib
import smtplib
FIFTEEN_MINUTES = datetime.timedelta(minutes=15)