def __init__(self, imgFName='img', parent=None): QWidget.__init__(self, parent=None) self.palette = QPalette() self.cwd = os.getcwd() self.setup = Setup(os.path.join(self.cwd, 'SetupData')) self.detectors = self.setup.detectors self.motors = self.setup.motors self.scalers = self.setup.scalers self.imgFName = imgFName self.vblayout = QVBoxLayout(self) self.mainDock = DockArea(self, parent) self.vblayout.addWidget(self.mainDock) self.imageFlag = 0 self.pdIn = False self.beamIn = False self.mirrorIn = False self.align = True self.delay = 0.1 self.detPV = 'None' self.detParDock = Dock('Detector Parameters', size=(1, 1)) self.imgDock = Dock('Image', size=(1, 10)) self.mainDock.addDock(self.imgDock, 'left') self.mainDock.addDock(self.detParDock, 'left') self.mainDock.moveDock(self.imgDock, 'bottom', self.detParDock) self.create_imgDock() self.create_detParDock() self.fileWatcher = FileWatcher()
def main(): print "---------Iniciando Dragon Ball Z Beat'm All--------------" Setup() print "-----------Configuracion inicial, Terminada--------------" diccionarioEstados = { "PantallaInicio": States.PantallaInicio("Pantalla de Inicio", "Menu"), "Menu": States.MenuPrincipal("Menu principal", "Prologo"), "Prologo": States.Prologo("Prologo", "Tutorial"), "Tutorial": States.LevelTutorial("Tutorial", "Level1"), "Level1": States.Level1("Level 1", "QUIT"), "Interludio1": None, "LevelFinal": States.LevelFinal("Level Final", "Menu"), "Interludio2": None, "Level3": None, "Interludio3": None, "Creditos": None, "GameOver": None, "Victoria": None } diccionarioEstados["Tutorial"].setup() controlador = Control() controlador.preparar_estados(diccionarioEstados, diccionarioEstados["LevelFinal"]) print "-----------Sistema de estados, Inicializado--------------" controlador.main() print "-----------------Aplicaion Finalizada--------------------"
def __init__(self): # Initialize window variables and several labels pygame.init() self.size = self.width, self.height = screenWidth, screenHeight self.white = 255, 255, 255 self.screen = pygame.display.set_mode(self.size) # Various screen fonts and labels self.byeFont = pygame.font.SysFont("freeserif", 100) self.winFont = pygame.font.SysFont("freeserif", 50) self.scoreKeeper = pygame.font.SysFont("freeserif", 25) self.wait = self.winFont.render( "Player 2 has not connected, please wait...", 1, (0, 0, 0)) self.bye = self.byeFont.render("Goodbye!", 1, (0, 0, 0)) self.lost = self.winFont.render("Game Server Connection Lost.", 1, (0, 0, 0)) # Setup game mode and difficulty self.player_num = 0 self.connected = 0 self.setup = Setup() self.mode, self.diff, self.player_img, self.ball_img = self.setup.run_setup( ) ### Check chosen mode ### # If quit occurred, leave game if self.mode == 0: self.goodbye() # If player want to play computer, set that up elif self.mode == 1: self.player_num = 1 self.connected = 1 self.player = Player(self.player_num, self.player_img) spriteGroup.add(self.player) self.computer = Computer(self.diff, self.player_img) self.ball = Ball(self.player, self.diff, self.ball_img, self.computer) spriteGroup.add(self.computer) # If mode 2 selected, set a variable for other score elif self.mode == 2: self.other_score = 0 self.player = Player(self.player_num, self.player_img) self.ball = Ball(self.player, self.diff, self.ball_img) spriteGroup.add(self.player) # Initialize other player attributes self.barWidth = 30 self.barHeight = 80 self.other_img = pygame.image.load(self.player_img) self.other_img = pygame.transform.scale( self.other_img, (self.barWidth, self.barHeight)) self.other_rect = self.other_img.get_rect() self.other_rect.x = -50 self.other_rect.y = 900
def initUI(self): # Add the widgets self._setup = Setup() self._negf_para = Negf_para() self._species = species() self._misc = Misc() self._grids = Grids() self._mdscf = Mdscf() self._io = IOcontrol() self._configuration = Configuration() self._default_input = default_input_para() #self._widgets = [self._setup, self._misc, self._mdscf, self._io, # self._species, self._grids, self._default_input, # self._configuration, self._negf_para] self._widgets = [ self._setup, self._misc, self._mdscf, self._io, self._species, self._grids, self._default_input, self._negf_para ] # Main layout #layout = QtGui.QVBoxLayout() layout = QtGui.QGridLayout() layout.setSpacing(10) self.setLayout(layout) # Setup Groupbox savebtn = QtGui.QPushButton('Save') self.savedir = QtGui.QLineEdit(os.getcwd()) choosedir = QtGui.QPushButton('...') choosedir.clicked.connect(self.selectdir) savebtn.clicked.connect(self.save) layout.addWidget(savebtn, 1, 0, 1, 1) layout.addWidget(self.savedir, 1, 1, 1, 4) layout.addWidget(choosedir, 1, 5, 1, 1) form_layout = QtGui.QTabWidget() layout.addWidget(form_layout, 2, 0, 1, 10) #form_layout = QtGui.QTabWidget(group_box) form_layout.addTab(self._setup, self.tr('Setup')) form_layout.addTab(self._mdscf, self.tr('MD SCF')) form_layout.addTab(self._grids, self.tr('Grids')) form_layout.addTab(self._negf_para, self.tr('NEGFctrl')) form_layout.addTab(self._species, self.tr('Species')) form_layout.addTab(self._misc, self.tr('Misc')) form_layout.addTab(self._io, self.tr('IO')) form_layout.addTab(self._configuration, self.tr('Configuration')) form_layout.currentChanged.connect(self.configurationChanged) # self.connect(form_layout, QtCore.SIGNAL("currenChanged(int)"), self.configurationChanged) self.setGeometry(2000, 2000, 750, 750) self.setWindowTitle('NCSU RMG-NEGF GUI') self.show()
def __init__(self, playerId, board, players, setup='random', discard='random', rob='random', trade='none', build='best'): self.Setup = Setup(setup, playerId, board, players) self.Discard = Discard(discard, playerId, board, players) self.Rob = Rob(rob, playerId, board, players) self.Trade = Trade(trade, playerId, board, players) self.Build = Build(build, playerId, board, players)
def __init__(self): self._s = Setup() length = len(self._s.getSet()) # randomly generate byte array self.position = [] for i in range(length): if random() > 0.5: self.position.append(0) else: self.position.append(1) # generate the velocity self._velocity = [random() for i in range(length)] # define best global,best neighbor and best personal self._bestGlobal = None self.bestPersonal = self.position self._bestFitness = self.fitness()
def __init__(self): super().__init__() self.actions = [acpc.ActionType.FOLD, acpc.ActionType.CALL, acpc.ActionType.RAISE] self.action_probabilities = [0] * 3 self.action_probabilities[0] = 0.3 # fold probability self.action_probabilities[1] = (1 - self.action_probabilities[0]) * 0.5 # call probability self.action_probabilities[2] = (1 - self.action_probabilities[0]) * 0.5 # raise probability self.bets = None self.contrib = None self.state_controller = ESMCCFRPlusTraining(rules=Leduc(), setup=Setup(stack_size=10, big_blind=1, small_blind=1), blueprint='strategy-leduc-10-1-1.csv', abstracting=False) self.startingplayer = 0 self.player = None
def main(): rules = Leduc() setup = Setup(small_blind=1, big_blind=1, stack_size=10) pov = Human(rules, setup) opponent = ESMCCFRPlusTraining(rules, setup, 'strategy-leduc-10-1-1.csv') contest = Contest(rules=rules, setup=setup, logger=Logger(rules=rules, setup=setup, players=(pov, opponent)), players=(pov, opponent)) games = 0 total = 0 for _ in range(100): total += contest.play() games += 1 print("@%d %s Total: (%.2f avg) %d" % ( games, pov, (1.0 *total) / games, total))
def main(): # Create Setup object bus = Setup() # Create Sensor object sense = Sensor() # Setup the SPI bus bus.busSetup() while True: # Retrieve the SPI bus channel_1, channel_2 = bus.getBus() # Setup the sensors sense.setTemperatureInC(channel_1) sense.setTemperatureInF(channel_1) sense.setLuminosity(channel_2) # Fetch temperature in degrees C temperatureC = sense.getTemperatureInC() # Fetch temperature in degrees F temperatureF = sense.getTemperatureInF() # Fetch luminosity as a percentage luminosity = sense.getLuminosity() # print output print( "Temperature in degrees Celsius: {:5.2f} deg".format(temperatureC)) print("Temperature in degrees Fahrenheit: {:5.2f} deg".format( temperatureF)) print("Luminosity as a percentage: {:6.2f} %".format(luminosity)) print("\n") # time delay between readings sleep(1)
def main(): # Create Setup object bus = Setup() # Create Sensor object sense = Sensor() # Setup the SPI bus bus.busSetup() while True: # Retrieve the SPI bus channel_1, channel_2 = bus.getBus() # Setup the sensors sense.setTemperatureInC(channel_1) sense.setTemperatureInF(channel_1) sense.setLuminosity(channel_2) # Fetch temperature in degrees C temperatureC = sense.getTemperatureInC() # Fetch temperature in degrees F temperatureF = sense.getTemperatureInF() # Fetch luminosity as a percentage luminosity = sense.getLuminosity() # Open file for output outfile = open(r"/home/pi/share/data.txt", "a") # Write temperature and luminosity readings to file outfile.write("\n{:5.2f}\t\t{:6.2f}\t\t{}".format( temperatureC, luminosity, datetime.now())) # Close file stream outfile.close() # Close the input file # time delay between readings sleep(30)
def scan(): from Config import Config from Setup import Setup import Params as params table = 'hlt2_mon' config = Config(top=params.home,have_archive=True) Setup(config.config(),credentials=params.credentials,table=table) \ .createDirectories().createTables().printSummary() hlt2 = Scanner(config.config(),mondb=params.mondb,rundb=params.rundb,table=table) hlt.prepareWork = makeXML log(INFO, 'last Run Ready: %d'%(hlt2.lastRunReady(),)) while 1: hlt2.populateFromConditions() hlt2.createWork() hlt2.checkDone() hlt2.checkFailed() hlt2.dump() time.sleep(5)
def main(): parser = argparse.ArgumentParser( description='Determine PacBio read support for gaps in scaffolds', usage=usage()) # Main arguments parser.add_argument('scaffolds', action='store', help='The input scaffolds in Fasta format') parser.add_argument('subreads', action='store', help='The PacBio subreads in BAM format') parser.add_argument('-t', '--threads', dest='threads', type=int, \ help='Number of threads to use for multi-threaded processes, default=1', default=1) # Arguments for Setup setup_args = parser.add_argument_group('Setup') setup_args.add_argument('-n', '--min_gap', dest='min_gap', type=int, default=200, \ help='Minimum number of consecutive Ns to be considered a gap, default=200') setup_args.add_argument('-x', '--max_gap', dest='max_gap', type=int, default=1000000, \ help='Maximum number of consecutive Ns to be considered a gap, default=Inf') setup_args.add_argument('-f', '--flank_size', dest='flank_size', type=int, default=1000, \ help='Number of extracted bases flanking gaps and scaffold ends, default=1000') # Arguments for Support support_args = parser.add_argument_group('Support') support_args.add_argument('-b', '--blasr', dest='blasr', type=str, \ help='Parameters to pass to BLASR', default='') support_args.add_argument('-d', '--min_reads', dest='min_reads', type=int, \ help='The minimum number of reads required to support a gap', default=5) support_args.add_argument('-w', '--wiggle', dest='wiggle', type=int, \ help='The percent deviation allowed from predicted gap size', default=0.5) # Arguments for Assembly assembly_args = parser.add_argument_group('Assembly') assembly_args.add_argument('-m', '--minimap', dest='minimap', \ help='Parameters to pass to Minimap', default='-Sw5 -L100 -m0') assembly_args.add_argument('-a', '--miniasm', dest='miniasm', \ help='Parameters to pass to Miniasm', default='') assembly_args.add_argument('-r', '--racon', dest='racon', \ help='Parameters to pass to Racon', default='') # Parse the arguments args = parser.parse_args() # Initialize classes setup = Setup() support = Support() assembly = Assembly() placement = Placement() # Check for save point try: save = open('jelly2.save', 'r').read() print "Found save point:", save except IOError: write_save('setup') # Run Setup if check_save('setup'): setup.run(args) write_save('mapping') # Run Support if check_save('mapping'): support.mapping(args) write_save('sorting') if check_save('sorting'): support.sorting(args) write_save('indexing') if check_save('indexing'): support.indexing(args) write_save('support') if check_save('support'): support.find_support(args) write_save('assembly') # Run Assembly if check_save('assembly'): assembly.assemble_gaps(args) write_save('placement') # Run Placement if check_save('placement'): placement.load_data(args) placement.fill_gaps()
from Setup import Setup from Game import Game import sys if __name__ == '__main__': config_file = sys.argv[1] ship_info = {} with open(config_file) as config: size = config.readline() row, col = size.split() for line in config: (key, val) = line.split() ship_info[key] = val s = Setup(row, col, ship_info) # Game setup rows, cols, ship_info, p1_name, p1_board, p2_name, p2_board = s.setup() # Game begins battle = Game(p1_name, p1_board, p2_name, p2_board, rows, cols, **ship_info) battle.play()
def __init__(self): Setup() Input()
from Setup import Setup setup = Setup() #define analysis regions from StopsDilepton.analysis.regions import regions1D, regions3D regions = regions3D from StopsDilepton.analysis.MCBasedEstimate import MCBasedEstimate from StopsDilepton.analysis.DataDrivenDYEstimate import DataDrivenDYEstimate from StopsDilepton.analysis.DataDrivenTTZEstimate import DataDrivenTTZEstimate #from collections import OrderedDict bkgEstimators = [ #DataDrivenDYEstimate(name='DY-DD', cacheDir=setup.cacheDir), #DataDrivenTTZEstimate(name='TTZ-DD', cacheDir=setup.cacheDir), MCBasedEstimate(name='DY', sample=setup.sample['DY'], cacheDir=None), #setup.defaultCacheDir()), MCBasedEstimate(name='TTJets', sample=setup.sample['TTJets'], cacheDir=None), #setup.defaultCacheDir()), MCBasedEstimate(name='TTZ', sample=setup.sample['TTZ'], cacheDir=None), #setup.defaultCacheDir()), MCBasedEstimate(name='other', sample=setup.sample['other'], cacheDir=None), #setup.defaultCacheDir()), ] nList = [e.name for e in bkgEstimators] assert len(list(set(nList))) == len( nList), "Names of bkgEstimators are not unique: %s" % ",".join(nList)
from AvailableBets import AvailableBets from Setup import Setup # throw error when it's not my turn available_bets = AvailableBets(Setup(small_blind=2, big_blind=5, stack_size=11)) exception_thrown = False try: available_bets.get_bets_as_numbers(6, 5) except: exception_thrown = True assert exception_thrown exception_thrown = False try: available_bets.get_bets_by_action_type(6, 5) except: exception_thrown = True assert exception_thrown # throw error when I'm out of chips available_bets = AvailableBets(Setup(small_blind=2, big_blind=5, stack_size=11)) exception_thrown = False try: available_bets.get_bets_as_numbers(8, 7) except: exception_thrown = True assert exception_thrown
def setup(): password = '' if platform == 'darwin' or platform == 'linux': password = getpass() setup = Setup() setup.setup(password)
def loadSetup(self, filename): with open(filename) as f: return Setup(json.load(f))
# Update the expected value value += player_strategy[bet_index] * va for bet_index in range(len(possible_bets)): # Update the cumulative regret of each bet strategy.regret_sum[bet_index] += value_bet[bet_index] - value return value elif player_turn == other_player: # Sample one bet and increment bet counter bet_index = self.get_random_bet(player_strategy) bet = possible_bets[bet_index] strategy.count[bet_index] += 1 memento = state.update(bet) val = self.traverse_ESMCCFR(state, player) state.reverse_update(memento) return val else: raise Exception('How did we get here? There are no other players') if __name__ == "__main__": # cProfile.runctx("ESMCCFR_P(100000)",globals(),locals()) ESMCCFR_P = ESMCCFR_P(rules=Leduc(), setup=Setup(stack_size=10, big_blind=1, small_blind=1), abstracted=False) ESMCCFR_P.run(20000)
'''Main Prog''' #Load functions from Reader import Reader from Setup import Setup from Game import Game from Applier import Applier from Win import Win from End import End Win = 0 Rules = -1 Turn = 0 #Whos Turn is it? [Card_set, Players, Starting_Hand, Rule_set] = Reader() while True: [Player_lst, Master] = Setup(Card_set, Players, Starting_Hand) while Win == 0: Game(Master, Player_lst, Turn, Rule_set) #calls Applier Win() #qick check of Master End()