""" casino similator driver programpython driver.py -gGAME [-nSAMPLES] [-ds] [-wMESSAGE,MESSAGE...] PLAYER ...-gGAME is the game name [ craps, roulette, blackjack ]-nSAMPLES is the number of samples, by default 100-d gives a detailed log of all activity-s suppresses all logging-wMESSAGE,... watches any of the various messagesPLAYER is a player strategy"""""" TODO:	Break each sim1, sim2, sim3, sim4 into basic game rules and player strategy modules and the player factory.	This allows someone to tweak the players without touching anything else.		The player strategy module name should be a command-line arg, allowing multiple files with 	player strategy classes; may be some way to automate creation of the PlayerFactory."""from simlog import *;from simulator import *;import sys;import getopt;def process( gameName, samples, roundLimit, players, reportTo=sys.stdout ):	reportTo.writelines( gameName, "\n" );	reportTo.flush();		if( gameName == "craps" ):		import sim1;		players= sim1.CrapsPlayerFactory().playerSet( players );		game= sim1.CrapsGame();	if( gameName == "roulette" ):		import sim2;		players= sim2.RoulettePlayerFactory().playerSet( players );		game= sim2.RouletteGame();	if( gameName == "blackjack" ):		import sim3;		players= sim3.BlackjackPlayerFactory().playerSet( players );		game= sim3.BlackjackGame();	if( gameName == "caribbeanpoker" ):		import sim4;		players= sim4.CaribPokerPlayerFactory().playerSet( players );		game= sim4.CaribPokerGame();		analyzer= Analyzer();	s= Simulator( players, game, analyzer );	s.generate( samples, roundLimit );	analyzer.report( reportTo );	reportTo.writelines( "%7d  "%s.work, " games\n" );	reportTo.writelines( "%9.1f"%s.duration, " seconds\n" );	reportTo.writelines( "%9.1f"%s.performance(), " games per second\n" );def main():	players= {		"craps":["come1","come2","come1sl"],		"roulette":["lastcol","watchcol","red7","red7sl"],		"blackjack":["simple","wizodds","silberstang"],		"caribbeanpoker":["simple","aceking","acekingjack","wizodds"]	};	log= Simlog().instance().summary();		if( len(sys.argv) <= 1 ):		samples= 10;		for game in ["craps","roulette","blackjack","caribbeanpoker"]:			process( game, samples, 100, players[game] );	else:		samples= 100;		gameName= "roulette";		reportTo= sys.stdout;		try:			opts, args= getopt.getopt( sys.argv[1:], "dsn:g:w:f:" );		except getopt.GetoptError:			print __doc__;			sys.exit();		for opt,val in opts:			if( opt in ["-n"] ):   samples= int(val);			elif( opt in ["-g"] ): gameName= val;			elif( opt in ["-d"] ): log.detail();			elif( opt in ["-s"] ): log.summary();			elif( opt in ["-w"] ): log.watch( val.split(",") );			elif( opt in ["-f"] ): reportTo= open( val, "w" );			else:				print "problem!";		if( len(args) == 0 ):			args= players[gameName];		print "%s, %d samples, %s" % (gameName, samples, str(args));		process( gameName, samples, 100, args, reportTo );		reportTo.close();	if( __name__ == "__main__" ):	main();