Skip to content

Instantly share code, notes, and snippets.

import itertools
values = "34567890JQKA2"
def cardRanker(card):
return values.index(card[0]), card
def sort_cards(hand):
return [c[1] for c in sorted(map(cardRanker,hand))]
def isStraight(play):
@akreer135
akreer135 / tic.py
Created March 18, 2014 16:54
tic tac toe
def print_board():
for i in range(0,3):
for j in range(0,3):
print map[2-i][austin],
if austin != 2:
print "|",
print ""
def check_done():
@akreer135
akreer135 / songplayr.py
Created January 14, 2014 19:39
the magical script that prints the lines to songs.
class Song(object):
def __init__(self, lyrics):
self.lyrics = lyrics
def sing_me_a_song(self):
for line in self.lyrics:
print line
pop_it = Song(["Pop it",
@akreer135
akreer135 / game.py
Created January 13, 2014 18:09
lesson 43
from sys import exit
from random import randint
class Scene(object):
def enter(self):
print "This scene is not yet configured. Subclass it and implement enter()."
exit(1)
class Engine(object):
@akreer135
akreer135 / loops2.py
Created December 2, 2013 00:08
lerps two
i = 0
numbers = []
while i < 6:
print "At the top i is %d" % i
numbers.append(i)
print "Numbers now: ", numbers
print "At the bottom i is %d" % i
@akreer135
akreer135 / loops1.py
Created December 2, 2013 00:08
lerps
i = 0
numbers = []
while i < 6:
print "At the top i is %d" % i
numbers.append(i)
i = i + 1
print "Numbers now: ", numbers
print "At the bottom i is %d" % i
@akreer135
akreer135 / newgame.py
Last active December 29, 2015 01:19
new game
scenes = [
["""Welcome to trailz, an interactive text game. The rules are simple, you will be given a scenario, and can type whatever is in the parentheses. Good luck!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Help: to pick up and item, type "take" and that particular items name. To check your inventory, type "list items".
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You are walking on a wooden trail and notice you are lost, and soon arrive at a crossroads right before huge trees fall across the path you have been walking on, so you may not turn back. Do you want to: (1) Go along the east path, (2) Go along the west path, or (3) Go along the north path.""", 5, 6, 7],
#This is the crossroads from the east: 1
["You again arrive at the crossroads. Do you want to: (1) Go along the north path, or (2) Go along the west path.", 7, 6],
#this is from the west: 2
print "You enter a dark room with two doors. Do you go through door #1 or door #2?"
door = raw_input("> ")
if door == "1":
print "There's a giant bear here eating a cheese cake. What do you do?"
print "1. Take the cake."
print "2. Scream at the bear."
bear = raw_input("> ")
@akreer135
akreer135 / wat.py
Last active December 28, 2015 19:19
a crazy game (still making)
print "This game only involes yes or no questions sometimes verbs, if it is special verb it will be higlighted like 'this'. Would you like to 'start'?"
start_game = raw_input(">")
if start_game == "start":
print "You are walking in the woods and see a small hole. Would you like to approach it?"
hole = raw_input("> ")
if hole == "yes":
heads, legs = map(float, raw_input().split())
chickens = legs/2
cows = 0
while heads < cows + chickens:
chickens -= 2
cows += 1
if cows*4 + chickens*2 == legs and cows + chickens == heads:
print "There are %d chickens and %d cows." % (chickens, cows)
else: