Skip to content

Instantly share code, notes, and snippets.

@gregglind
Created August 22, 2010 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregglind/544039 to your computer and use it in GitHub Desktop.
Save gregglind/544039 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
simple simulation of the wire card game, version 0
"""
import random
def roll(n=1,d=6):
return sum((random.randint(1,d) for x in xrange(n)))
class Deck(object):
pass
class Player(object):
"""
base class for players.
override def move(self,game) for
strategy
"""
def __init__(self,name=None):
self.cards = None
self.name = name
self.strategy = None
def __repr__(self):
return "name: %(name)s strategy: %(strategy)s" % self.__dict__
def move(self):
pass
def draw(self,deck):
pass
def sit_out_turn(self):
pass
class RandomPlayer(Player):
"""
player who just played one of his damn cards and responds
randomly to all choices
"""
def __init__(self,*args,**kwargs):
Player.__init__(self,*args,**kwargs)
self.strategy='random'
class SmartPlayer(Player):
"""
"""
def __init__(self,*args,**kwargs):
Player.__init__(self,*args,**kwargs)
self.strategy='smart'
'''
rules and strategies all take a "game" object and manipluate it
'''
def CrisisDeck(wire=1):
return list()
class Wire(object):
def __init__(self):
self.up=False
class Game(object):
def __init__(self):
self.murders = list()
self.episode = 0
self.max_episodes = 10
self.crisis_deck = []
self.actions = list()
self.discards = list()
self.wire = Wire()
def setup_game(self):
pass
def trial(self):
pass
# lieutenant
# move wire
# setup
# 2 cards per player
playernames = ("McNulty","Prez","Kima","Freemon","Daniels","HercCarver")
def create_players(n):
if not 0<n<=6:
raise ValueError("n must be betwewen 1 and 6")
players = list()
names = random.sample(playernames,n)
return [RandomPlayer(name=x) for x in names]
if __name__ == "__main__":
players = create_players(5)
print "\n".join(map(str,players))
for x in range(10):
print roll(2,6), " ",
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment