Skip to content

Instantly share code, notes, and snippets.

View Tyaedalis's full-sized avatar

Matt Liebrich Tyaedalis

View GitHub Profile
from os import walk
files = []
for (dirpath, dirnames, filenames) in walk('./data/'):
files.extend(filenames)
break
data = []
OFratio = None
for file in files:
@Tyaedalis
Tyaedalis / data_parser.py
Created July 31, 2017 21:37
Eases the data collection process for ProcEngines.
from os import walk
files = []
for (dirpath, dirnames, filenames) in walk('./data/'):
files.extend(filenames)
break
for file in files:
t = []
with open('./data/' + file) as f:
@Tyaedalis
Tyaedalis / cave_gen.py
Created November 14, 2012 05:49
Simple cave generator.
"""
TODO:
====
+ Fit grid to generated structure (with a border)
+ Generate a few small "rooms" and combine them to a grid
+ Corridors
+ Doors?
+ Func to determine where rooms should go
"""
@Tyaedalis
Tyaedalis / gist:3956085
Created October 25, 2012 23:19
Fighter
import random, math, sys
from room_gen import *
running = True
winTarget = 4 # how many wins until victory
def rollDice(sides, times=1):
"""
Simulates the rolling of die.
"""
from fractions import Fraction
def strToNum(string):
if '/' in string: #if user entered a fraction
string = string.split('/')
return Fraction(int(string[0]), int(string[1]))
elif '.' in string: #if user entered a decimal
return float(string)
else: return int(string)
def strToNum(string):
if '/' in string:
num, den = string.split('/')
return int(num)/int(den)
elif '.' in string:
return float(string)
else: return int(string)
run = 1
while run:
@Tyaedalis
Tyaedalis / gist:1862619
Created February 19, 2012 08:31
Challenge #1 [difficult]
from random import *
min, max, result = 1, 100, ''
while result != 'y':
guess = randint(min, max)
result = raw_input('Is your number {}? (Y|H|L) '.format(guess)).lower()[0]
if result == 'h': max = guess
elif result == 'l': min = guess
print "Your number is {}.".format(guess)
@Tyaedalis
Tyaedalis / gist:1862103
Created February 19, 2012 05:10
Challenge #1
name, age, userName = (raw_input('Name: '), raw_input('Age: '), raw_input('Reddit Username: '))
with open('UserInfo.txt', 'a') as f:
f.write('Name: {0}\nAge: {1}\nReddit Username: {2}\n\n'.format(name, age, userName))
print 'Your name is {0}, you are {1} years old, and your username is {2}.'.format(name, age, userName)