def setUp(self) -> None: self.w = Wheel() bb = BinBuilder(self.w) bb.buildBins() self.t = Table() self.p = Passenger57(self.t, self.w) self.g = Game(self.t, self.w) self.sim = Simulator(self.p, self.g)
def setUp(self) -> None: self.t = Table([]) self.w = Wheel() binBuilder = BinBuilder(self.w) binBuilder.buildBins() self.blackOutcome = self.w.getOutcomeByName('black') self.redOutcome = self.w.getOutcomeByName('red') self.blackOutcomeBin = Bin([self.blackOutcome]) self.redOutcomeBin = Bin([self.redOutcome]) self.m = Martingale(self.t, self.w) self.m.isPlaying = MagicMock(return_value=True) self.g = Game(self.t, self.w)
def run(self): w = Wheel() binBuilder = BinBuilder(w) binBuilder.buildBins() t = Table([]) g = Game(t, w) p1 = Passenger57(t, w) g.cycle(p1) g.cycle(p1) g.cycle(p1) g.cycle(p1) g.cycle(p1) g.cycle(p1) g.cycle(p1) g.cycle(p1) g.cycle(p1)
import argparse from openpyxl import load_workbook from src.Table import Table if __name__ == '__main__': parser = argparse.ArgumentParser( description='Convert excel table to latex table.', formatter_class=argparse.RawTextHelpFormatter, epilog="""Note: The height of every merged cell must not be less than the number of lines in your text. """ ) parser.add_argument('-s', default='table.xlsx', dest='source', help='source file (default: %(default)s)') parser.add_argument('-o', default='table.tex', dest='target', help='target file (default: %(default)s)') parser.add_argument('--setting', default='setting.tex', dest='setting', help='setting file (default: %(default)s)') # parser.add_argument('-w', default='\\linewidth', dest='width', help='table width (default: %(default)s)') parser.add_argument('--sig', default='utf-8', dest='encoding', nargs='?', const='utf-8-sig', help='set file encoding to utf-8-sig, only use when there is mess code.') parser.add_argument('-m', '--math', type=bool, default=False, dest='math', help='enable inline math', const=True, nargs='?') parser.add_argument('-e', '--excel-format', type=bool, default=False, dest='excel_format', help='enable all formats', const=True, nargs='?') args = parser.parse_args() wb = load_workbook(args.source) ws = wb.active t = Table(ws, args) with open(args.target, 'w', encoding=args.encoding) as f: f.write(t.tex)
def testStr(self): betList = [Bet(30, outcome)] t = Table(betList) self.assertEqual( str(t), "Bets list: ['Outcome: red, odds are 1, amount: 30']")
def testIter(self): betList = [Bet(30, outcome), Bet(10, outcome), Bet(5, outcome)] t = Table(betList) for i, el in enumerate(t): self.assertEqual(betList[i], el)
def testIsValidUnderMinimum(self): betList = [Bet(TABLE_MINIMUM - 0.1, outcome)] t = Table(betList) with self.assertRaises(InvalidBet): t.isValid()
def testIsValidOverLimit(self): betList = [Bet(TABLE_LIMIT + 1, outcome)] t = Table(betList) with self.assertRaises(InvalidBet): t.isValid()
def testPlaceBet(self): ilegalBet = Bet(TABLE_LIMIT + 1, outcome) t = Table() with self.assertRaises(InvalidBet): t.placeBet(ilegalBet)
def testTableInit(self): betList = [Bet(30, outcome), Bet(10, outcome)] t = Table(betList) self.assertCountEqual(t.bets, betList)
import os import time import random random.seed(1235) # Training log n_games = 10 log_file = 'log/ngames'+str(n_games)+'_RvR.pkl' logNN = LogNN(log_file) tic = time.clock() if not logNN.log_exists: print('Random vs Random') players = [Player('Blue', 'Random'), Player('Green', 'Random')] logNN.reset_wins() for _ in range(n_games): table = Table() winner_color = play_a_game(table, players, logNN) logNN.wins[winner_color] += 1 # logNN.printout() logNN.save() toc = time.clock() print(logNN.wins) print(n_games, 'games:', toc-tic, 'seconds') # Actual training hl_size = 1000 nn_file = 'log/trained_nn_' + str(hl_size) + '_hls.pkl' warm_start = True clf = MyMLPClassifier(nn_file, solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(hl_size,), random_state=1, verbose=False, warm_start=warm_start) tic = time.clock()
def setUp(self) -> None: self.w = Wheel() bb = BinBuilder(self.w) bb.buildBins() self.t = Table() self.p = Player(self.t, self.w)
def setUp(self) -> None: self.w = Wheel() binBuilder = BinBuilder(self.w) binBuilder.buildBins() self.t = Table([]) self.g = Game(self.t, self.w)
for outcome in winningBin: # Cycle through all outcomes in the winning bin if bet.outcome == outcome: print("Congratulations, you won!") player.win(bet) #else: #print("Sorry, this bet didn't win!") #player.lose(bet) if __name__ == "__main__": # Main entry point of the game wheel = Wheel() table = Table(100, 1) game = Game(wheel, table) # Creates a player playerName = input("Choose player name: ") player = Player(playerName, table, 100, 5) # Runs the Roulette game game.cycle(player)
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.resize(800, 800) self.setFont(QFont('Verdana')) self.setWindowTitle('Sand Table') self.i = 0 self.timer = QTimer(self) self.timer.setInterval(700) self.timer.timeout.connect(self.collapse) self.table = Table(3, 3, 4, self) self.tableView = View(self) self.tableView.setModel(self.table) #self.tableView.doubleClicked.connect(self.addOne) horizontal = QHeaderView(Qt.Horizontal) horizontal.setResizeMode(QHeaderView.Stretch) self.tableView.setHorizontalHeader(horizontal) vertical = QHeaderView(Qt.Vertical) vertical.setResizeMode(QHeaderView.Stretch) self.tableView.setVerticalHeader(vertical) self.collapseButton = QPushButton('Collapse', self) self.collapseButton.clicked.connect(self.collapse) self.collapseAllButton = QPushButton('Collapse All', self) self.collapseAllButton.clicked.connect(self.table.collapseAll) self.collapseAutoButton = QPushButton('Start Auto Collapse', self) self.collapseAutoButton.clicked.connect(self.toogleAuto) self.reloadButton = QPushButton('Reload', self) self.reloadButton.clicked.connect(self.load) self.saveButton = QPushButton('Save', self) self.saveButton.clicked.connect(self.save) self.clearButton = QPushButton('Clear', self) self.clearButton.clicked.connect(self.clear) self.reloadButton.setEnabled(False) self.saveButton.setEnabled(False) widget = QWidget(self) layout = QHBoxLayout() subLayout = QVBoxLayout() layout.addWidget(self.tableView) subLayout.addWidget(self.collapseButton) subLayout.addWidget(self.collapseAllButton) subLayout.addWidget(self.collapseAutoButton) subLayout.addWidget(self.clearButton) subLayout.addWidget(self.reloadButton) subLayout.addWidget(self.saveButton) layout.addLayout(subLayout) widget.setLayout(layout) self.setCentralWidget(widget) self.statusBar().showMessage('Welcome')
class MainWindow(QMainWindow): def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.resize(800, 800) self.setFont(QFont('Verdana')) self.setWindowTitle('Sand Table') self.i = 0 self.timer = QTimer(self) self.timer.setInterval(700) self.timer.timeout.connect(self.collapse) self.table = Table(3, 3, 4, self) self.tableView = View(self) self.tableView.setModel(self.table) #self.tableView.doubleClicked.connect(self.addOne) horizontal = QHeaderView(Qt.Horizontal) horizontal.setResizeMode(QHeaderView.Stretch) self.tableView.setHorizontalHeader(horizontal) vertical = QHeaderView(Qt.Vertical) vertical.setResizeMode(QHeaderView.Stretch) self.tableView.setVerticalHeader(vertical) self.collapseButton = QPushButton('Collapse', self) self.collapseButton.clicked.connect(self.collapse) self.collapseAllButton = QPushButton('Collapse All', self) self.collapseAllButton.clicked.connect(self.table.collapseAll) self.collapseAutoButton = QPushButton('Start Auto Collapse', self) self.collapseAutoButton.clicked.connect(self.toogleAuto) self.reloadButton = QPushButton('Reload', self) self.reloadButton.clicked.connect(self.load) self.saveButton = QPushButton('Save', self) self.saveButton.clicked.connect(self.save) self.clearButton = QPushButton('Clear', self) self.clearButton.clicked.connect(self.clear) self.reloadButton.setEnabled(False) self.saveButton.setEnabled(False) widget = QWidget(self) layout = QHBoxLayout() subLayout = QVBoxLayout() layout.addWidget(self.tableView) subLayout.addWidget(self.collapseButton) subLayout.addWidget(self.collapseAllButton) subLayout.addWidget(self.collapseAutoButton) subLayout.addWidget(self.clearButton) subLayout.addWidget(self.reloadButton) subLayout.addWidget(self.saveButton) layout.addLayout(subLayout) widget.setLayout(layout) self.setCentralWidget(widget) self.statusBar().showMessage('Welcome') def load(self): return 0 with open('table', 'rb') as fileObj: self.table = pickle.load(fileObj) def clear(self): self.table.clear() def collapse(self): """Step by step collapse.""" if(self.table.collapsable() != []): for cell in self.table.collapsable(): self.table.collapse(cell[0], cell[1]) else: self.stop() def save(self): return 0 with open('table', 'wb') as fileObj: pickle.dump(self.table, fileObj) def start(self): """Start the timer.""" if(not self.timer.isActive()): self.collapseButton.setEnabled(False) self.collapseAllButton.setEnabled(False) self.timer.start() self.statusBar().showMessage('Auto mode started') self.collapseAutoButton.setText('Stop Auto Collapse') def toogleAuto(self): """Toogle auto collapse""" if(not self.timer.isActive()): self.start() else: self.stop() def stop(self): """Stop the timer.""" self.timer.stop() self.statusBar().showMessage('Auto mode stopped') self.collapseAutoButton.setText('Start Auto Collapse') self.collapseButton.setEnabled(True) self.collapseAllButton.setEnabled(True) def addOne(self, index): self.table.addOne(index)