def simulate(t, d, trainingEpochs): ''' Runs the Monte Carlo simulation''' for currentEpoch in range(trainingEpochs): #Set experiment information in table t.currentEpoch = currentEpoch sim = montecarlo.Simulation(d, t) d.SetTrump(rnd.choice(d.suits)) d.DivideCards() t.DealCards(d) while t.players[0].hand != []: sim.run(d, t) t.PlayCards(d) winner = t.WhoWinsTrick(d) t.testingScores.append(t.roundScore.copy()) t.SetPlayerBehaviour( 0, "Network") #Back to the original values, as sim.run changes them. t.SetPlayerBehaviour(2, "Network")
def setUp(self): r = random.Random(1) self.sim = mc.Simulation(domain=[(-1, 1)] * 3, rand=r)
def setUp(self): r = random.Random(1) self.sim = mc.Simulation(domain=[(0, 1), (0, 1)], rand=r)
def test_2d(self): stub = RandomStub([0.5, 0.25]) sim = mc.Simulation(domain=[(10, 20), (1, 5)], rand=stub) self.assertEquals(40, sim.volume) self.assertEquals([15, 2], sim.sample())
def test_1d(self): stub = RandomStub([0.5]) sim = mc.Simulation(domain=[(10, 20)], rand=stub) self.assertEquals(10, sim.volume) self.assertEquals([15], sim.sample())
def test_empty(self): sim = mc.Simulation(domain=[]) self.assertEquals(1, sim.volume) self.assertEquals([], sim.sample())