Craps Test Python
Nov 3rd, 2016
I'm new to Python and I'm working on a craps game. I got the basic code down, but I need to simulate a total of 200 games and track the number of wins. I need a counter in my program, but I can't figure out how to do this. Here's what I have so far: import random def roll: die1 = random.randrange. Scipy.stats.ttestrel¶ scipy.stats.ttestrel (a, b, axis = 0, nanpolicy = 'propagate') source ¶ Calculate the t-test on TWO RELATED samples of scores, a and b. This is a two-sided test for the null hypothesis that 2 related or repeated samples have identical average (expected) values.
Never
Not a member of Pastebin yet?Sign Up, it unlocks many cool features!
Craps Test Python Training
- fromitertoolsimport count
- random= SystemRandom()
- class Holder: # simple class for holding a value so I can assign and retrieve it inside of a while loop
- defset(self, val): self.val= val;return val
- ifself.verbose:
- print(datum, **kwargs)
- def__init__(self, starting_balance, verbose=False):
- self.wins,self.losses=0,0
- self.verbose= verbose
- self.rolls={i + 1: 0for i inrange(12)}
- r1, r2 =self.random.randint(1,6),self.random.randint(1,6)
- self.print('Rolled {} and {} ({}).'.format(r1, r2, r))
- assertisinstance(bet,int)
- pass# keep rolling until you get a 4-11.
- self.rolls[r] +=1
- whileself.holder.set(self.roll())in{4,5,6,7,8,9,10,11}:
- self.rolls[r] +=1
- self.wallet += bet
- r =self.holder.get()
- self.wallet -= bet
- def safe_cast(new_type, val, default=None):
- default = new_type(val)
- return default
- def run(self, cnt=None):
- iterations = count()if cnt isNoneelserange(cnt)
- bet =None
- while bet isNoneor(isinstance(bet,int)and bet >self.wallet):
- bet =self.safe_cast(int,input('Enter a bet (Cash: ${}): '.format(self.wallet)))
- print('Invalid. ')
- print('You only have %{}'.format(self.wallet))
- ifself.wallet0:
- return
- c = Craps(100,True)
Craps Test Python Cheat
RAW Paste Data