Exemple #1
0
    def calcAverageHollywoodNum(
            self, choseAccuracy
    ):  #higher accuracy takes far more time, let user chose
        #chose accuracy will be the number of people used in average
        if (choseAccuracy > len(self.peoples)):
            print("Error: specified accuracy exceeds size of database")
        sum = 0
        toReset = []  #list of people to set as not checked for future methods
        for x in range(choseAccuracy):
            #find random person to check
            use = self.peoples[random.randInt(0, len(self.peoples) - 1)]
            while (use.isChecked()):
                use = self.peoples[random.randInt(0, len(self.peoples) - 1)]
            toReset.append(use)
            if (len(toReset) < 2):
                use2 = self.peoples[random.randInt(0, len(self.peoples) - 1)]
                while (use2.isChecked()):
                    use2 = self.peoples[random.randInt(0,
                                                       len(self.peoples) - 1)]
                toReset.append(use2)
            else:
                use2 = toReset
            sum += self.calculateNumber(use, use2)

        avgNum = (sum * 1.0) / choseAccuracy

        for node in toReset:
            node.flipCheck()

        print("Average Bacon Number: " + avgNum + "\n")
Exemple #2
0
def mutateThatJohn(neuralNetToMutate, nodes_per_layer):
    #don't mutate the activation functions
    activation_funcs=neuralNetToMutate.activation_funcs
    #creates new neural network
    neuralNetToReturn= nn.NeuralNet(activation_funcs,nodes_per_layer)
    weightsOf=neuralNetToMutate.weights
    #turn weights to one dimension
    weights1d= turnThreeToOne(weightsOf)
    #get total amount of weights
    totalAmtOfWeights=len(weights1d)
    b=0
    c=0
    #loop until we get two different indices
    while c==b:
        b= random.randInt(0,totalAmtOfWeights)
        c= random.randInt(0,totalAmtOfWeights)
    #grab sublist from those indices
    if b<c:
        subList=weights1d[b:c]
    else:
        subList=weights1d[c:b]
    #reverse the list
    subList.reverse()
    #replace elements in the list with reversed list
    if b<c:
        weights1d[b:c]=subList
    else:
        weights1d[c:b]=subList
    #need it back in three dimensions
    weightsBack=turnOneToThree(weights1d, nodes_per_layer)
    #set mutated weights to new neural net
    neuralNetToReturn.weights=weightsBack
    #return mutated neural net
    return neuralNetToReturn
Exemple #3
0
def evaluation(population, selection, scoresDictionary, nodes_per_layer):
    #start list of next population
    nextPopulation=[]
    #grab the parents we will be using
    parents=selection.keys()
    #mutate some of the population and append them for the next generation
    nextPopulation.append(mutateThoseJohns(population, selection, scoresDictionary, nodes_per_layer))
    #append parents to the next population
    nextPopulation.append(parents)
    #loop until we have a full next population
    while len(nextPopulation)<population: 
        #parent indices
        par1=0
        par2=0
        #until two different parents
        while par1==par2:
            par1=random.randInt(0,len(parents)-1)
            par2=random.randInt(0,len(parents)-1)
        #grab the parents
        parent1=parents[par1]
        parent2=parents[par2]
        #create the child
        child= crossover(parent1, parent2, nodes_per_layer)
        #append the child
        nextPopulation.append(child)
    return nextPopulation
def generateGameTitle():
    title1 = ['Mario', 'Zelda', 'Portal', 'Minecraft', 'Borderlands', 'Roller Coaster']
    subtitle = [': Zero Mission', ': Breath of the Wild', ': Sword and Shield', " 2", " Party", " Tycoon"]
    title1Loc = random.randInt(0,4)
    subtitleLoc = random.randInt(0,5)
    title = title1[title1Loc] + subtitle[subtitleLoc]
    return title
def generateName():
    first = ['Bob', 'Steve', 'Joe', 'Katie', 'Jessica', 'Elizabeth']
    last = ['Jones', 'Smith', 'Williams', 'Brown', 'Davis', 'Miller']
    firstLoc = random.randInt(0,4)
    lastLoc = random.randInt(0,5)
    name = first[firstLoc] + " " + last[lastLoc]
    return name
def generateConsole():
    first = ['Microsoft', 'Sony', 'Nintendo']
    last = ['Switch', 'Xbox', 'Playstation']
    firstLoc = random.randInt(0,2)
    lastLoc = random.randInt(0,2)
    console = first[firstLoc] + " " + last[lastLoc]
    return console
def get_guess_from_session(intent, session):
    session_attributes = {}
    reprompt_text = None

    if session.get('attributes', {}) and "numberOfDice" in session.get(
            'attributes', {}):
        number_of_dice = session['attributes']['numberOfDice']

        if number_of_dice == 1:
            numberRolled = random.randInt(1, 6)

            if guess == numberRolled:
                speech_output = "You guess correctly. Congratulations."
                should_end_session = True
            else:
                speech_output = "You guess incorrectly. Sorry."

        else:
            numberRolled = random.randInt(2, 12)

            if guess == numberRolled:
                speech_output = "You guess correctly. Congratulations."
            else:
                speech_output = "You guess incorrectly. Sorry."

    else:
        speech_output = "I don't know how many dice to roll. I can roll one or two dice."
        should_end_session = False

    return build_response(
        session_attributes,
        build_speechlet_response(card_title, speech_output, reprompt_text,
                                 should_end_session))
Exemple #8
0
def _find_external_v4_ip(config):
    v4_id = config.external_v4_id

    if v4_id:
        return v4_id
    else: # fallback to random value
        return '0.0.%d.%d' % (random.randInt(0, 255), random.randInt(0, 255))
def addRandom(board):
  addCount=0
  while addCount<5:
    delX=random.randInt(0,boardSize-1)
    delY=random.randInt(0,boardSize-1)
    if board[delY][delX]==0:
      addCount+=1
      board[delY][delX]=random.randInt(1,2)
Exemple #10
0
def dropItem(bossAlive, dropResult, dropChance, ownedItems):
    if (bossAlive = False): #ezt az ifet kivesszük, ha készen lesz az a függvény, ami a boss halálakor meghívja ezt a függvényt
        dropResult = rnd.randInt(0,100)
        if (dropResult <= dropChance[2]):
            if (dropResult <= dropChance[1]):
                if (dropResult <= dropChance[0]):
                    ownedItems.append(rnd.randInt(20,30)) #tier 3-as itemek sorszámai: 21-30
                else:
                    ownedItems.append(rnd.randInt(10,20)) #tier 2-es itemek sorszámai: 11-20
            else:
                ownedItems.append(rnd.randInt(0,10)) #tier 1-es itemek sorszámai: 1-10
        else:
Exemple #11
0
def crossover(neuralNetwork1, neuralNetwork2, nodes_per_layer):
    #get the weights of each neural network
    weights1=neuralNetwork1.weights
    weights2=neuralNetwork2.weights
    #get the activation functions of each neural network
    activation1=neuralNetwork1.activation_funcs
    activation2=neuralNetwork2.activation_funcs
    #get number of activation functions
    actives=len(activation1)
    #get random int for one-point crossover of activation functions
    cross=random.randInt(0,actives)
    activation_funcs=[]
    for a in range(0,actives):
        if a<cross:
            activation_funcs.append(activation1[a])
        else:
            activation_funcs.append(activation2[a])
    #create initial neural net to return
    net= nn.NeuralNet(activation_funcs,nodes_per_layer)
    #get total amount of weights
    totalAmtOfWeights=0
    for a in range(0,len(weights)):
        for b in range(0,len(weights[a])):
            for c in range(0,len(weights[a][b])):
                totalAmtOfWeights+=1
    #grab two random ints for two-point crossover
    b=0
    c=0
    while b==c:
        b= random.randInt(0,totalAmtOfWeights)
        c= random.randInt(0,totalAmtOfWeights)
    #find the lower index
    if b<c:
        first=b
        second=c
    else:
        first=c
        second=b
    counter=0
    #crossover weights to child
    for a in range(0,len(weights)):
        for b in range(0,len(weights[a])):
            for c in range(0,len(weights[a][b]))
                if counter<first:
                    net.weights[a][b][c]=weights1[a][b][c]
                else if counter>=first and counter<second:
                    net.weights[a][b][c]=weights2[a][b][c]
                else:
                    net.weights[a][b][c]=weights1[a][b][c]
                counter+=1
    #return child
    return net
Exemple #12
0
 def createRandomUnweightedGraph(n):
     graph = Graph()
     numbers = list(range(n))
     for number in numbers:
         graph.addNode(num)
     nodelist = graph.getAllNodes():
     for node1 in nodelist:
         indexatnode=nodelist.index(node1)
         randomNum = random.randInt(0, indexatnode)
         randomNum2 =random.randInt(1, n//2)
         randomNumUse = randomNum // randomNum2
         for node2 in randomNumUse:
             graph.addUndirectedEdge(node1, node2)
     
     return graph
Exemple #13
0
 def __init__(self, nPlayers, properties, places):
     self.players = [Player(i) for i in range(nPlayers)]
     self.properties = properties
     self.places = places
     self.nPlaces = len(places)
     possibleOrders = list(itertools.permutations(range(nPlayers)))
     turnOrder = possibleOrders[random.randInt(0, len(possibleOrders) - 1)]
	def e_Greedy(self, mode, network, state, testing_ep, subgoal, lastsubgoal):
		# handle the learn start
		print "enter e_greedy: ", mode
		if mode == 'meta':
			learn_start = self.meta_learn_start
		else:
			learn_start = self.learn_start
		if testing_ep:
			self.ep = testing_ep
		else:
			self.ep = (self.ep_end + max(0, (self.ep_start - self.ep_end) *\
			                                  (self.ep_endt - max(0, self.numSteps - learn_start))/self.ep_endt))
		subgoal_id = subgoal[-1]
		if mode != 'meta' and subgoal_id != 6 and subgoal_id != 8:
			self.ep = 0.1
		
		n_actions = None
		if mode == 'meta':
			n_actions = self.meta_args['n_actions']
		else:
			n_actions = self.transition_args['n_actions']
		print "enter e_greedy"
		# epsilon greedy
		self.ep = -1 ## To do: delete this after testing network
		if random.uniform(0,1) < self.ep:
			if mode == 'meta':
				chosen_act = random.randint(0, n_actions-1)
				while chosen_act == lastsubgoal:
					chosen_act = random.randint(0, n_actions-1)
				return chosen_act, None
			else:
				return random.randInt(0, n_actions-1), None
		else:
			return self.greedy(network, n_actions, state, subgoal, lastsubgoal)
Exemple #15
0
 def send(self, m):
     global cli
     global key
     cli.sendto(
         self.pub.encrypt(key.decrypt(m),
                          long(random.randInt(1, 999999))).encode(),
         self.addr)
Exemple #16
0
def mutateThoseJohns(population, selectionDictionary, scoresDictionary, nodes_per_layer, mutate=0.03):
    #get the list of neural networks
    listOfPotential=scoresDictionary.keys()
    #get the list of the selected neural networks
    listOfSelected=selectionDictionary.keys()
    #find the length of the list of potential
    totalLength=len(listOfPotential)
    #set amount selected to 0
    amountForMutate=0
    #set amount to select to the proportion of the population needed to
    #be mutated
    amountToMutate=population*mutate
    #list of mutated
    listOfMutated=[]
    #loop until all have been selected for mutation
    while(amountForMutate<amountToMutate):
        #get a random index to select
        randomIndex=random.randInt(0,totalLength-1)
        #select it
        neuralNetToMutate=listOfPotential[randomIndex]
        #if it was not already selected
        if(neuralNetToMutate not in listOfSelected):
            #mutate it
            neuralNetToMutate=mutateThatJohn(neuralNetToMutate, nodes_per_layer)
            #add it to the list
            listOfMutated.append(neuralNetToMutate)
            #increment
            amountForMutate+=1
    #return list
    return listOfMutated
Exemple #17
0
def behaviour3():
    strlen = random.randInt(1, 1000)
    randomstring = ''.join(
        random.choice(string.lowercase) for i in range(strlen))
    pyautogui.typewrite(randomstring)
    for x in range(1, 7):
        pyautogui.hotkey('ctrl', 'v')
def addDLC():
    for(int i = 0; i < 180; i++):
        if(random.randInt(0,1) == 0):
            query = "Insert into DLC(" + i + ", " + generatePrice() + ", " + generateGame() + " Expansion Pass, true, false)"
            insertRecord(query)
        else:
            query = "Insert into DLC(" + i + ", " + generatePrice() + ", " + generateGame() + " Expansion Pass, false, true)"
            insertRecord(query)
Exemple #19
0
 def spinWheel():
     randomVal = random.randInt(0,36)
     if randomVal in red:
         return ('red', randomVal)
     elif randomVal in black:
         return ('black', randomVal)
     else:
         return ('green', randomVal)
Exemple #20
0
def main():
    randomlist = []
    for i in range(10):
        randomlist.append(random.randInt(0, 100))
    print(randomlist)
    evenindex(randomlist)
    evenelement(randomlist)
    x = firstandlast(randomlist)
Exemple #21
0
def p2_move():
    global board
    move = True
    # Winning
    for row in range(3):
        for col in range(3):
            copy_board = copy.deepcopy(board)
            if copy_board[row][col] == ' ':
                copy_board[row][col] = current_player
                if move and is_winner(copy_board, current_player):
                    board[row][col] = current_player
                    move = False
    # Blocking
    if move:
        for row in range(3):
            for col in range(3):
                copy_board = copy.deepcopy(board)
                if copy_board[row][col] == ' ':
                    copy_board[row][col] = 'X'
                    if move and is_winner(copy_board, 'X'):
                        board[row][col] = current_player
                        move = False
    # Cornering
    if move:
        corner_list = [(0, 0), (0, 2), (2, 0), (2, 2)]
        for pos in corner_list:
            if board[pos[0]][pos[1]] != ' ':
                corner_list.remove(pos)
        if len(corner_list) > 0:
            rand_side = random.choice(corner_list)
            board[rand_side[0]][rand_side[1]] = current_player
            move = False
    # Center
    if move:
        if board[1][1] == ' ':
            board[1][1] = current_player
            move = False
    # Sides
        else:
            while move == True:
                rand_int_row = random.randInt(0, 2)
                rand_int_col = random.randInt(0, 2)
                if board[rand_int_row][rand_int_col] == ' ':
                    board[rand_int_row][rand_int_col] = current_player
                    move = False
Exemple #22
0
def move(my_history, their_history, my_score, their_score):
    chance = random.randInt(1, 8)
    if 'b' in their_history:
        if chance == int(1):
            return 'c'
        else:
            return 'b'
    else:
        return 'c'
Exemple #23
0
def genRandom(population, nodes_per_layer):
    neuralNets=[]
    layers=len(nodes_per_layer)
    for p in range(0,population):
        activation_funcs=[]
        for q in range(0,layers):
            activation_funcs.append(random.randInt(0,9))
        net= nn.NeuralNet(activation_funcs,nodes_per_layer)
        neuralNets.append(net)
    return neuralNets
Exemple #24
0
def arcPath():
    loopNum = 0
    sideLength = 0
    import random
    i = 0
    sideLength = random.randInt(10)
    angle = 360 / loopNum
    for _ in range(loopNum):
        controller.move("forward", sideLength)
        controller.turn("left", angle)
	def __init__(self, dataHandler):
		# Player 1 = 0
		# Player 2 = 1
		playerTurn = 0

		# Access player 1:
		#    faceUpFigures[0]
		# Access player 2:
		#    faceUpFigures[1]
		indices = range(0,dataHandler.numFigures)
		faceUpFigures = indices + indices

		# Access player 1:
		#    playerFigures[0]
		# Access player 2:
		#    playerFigures[1]
		playerFigures = [0,0]
		while playerFigures[0] == playerFigures[1]:
			playerFigures = [rand.randInt(0,dataHandler.numFigures-1),
							 rand.randInt(0,dataHandler.numFigures-1)]
Exemple #26
0
 def admit(self, patient):
     if len(self.patients) >= capacity:
         print(
             "{} is currently at full capacity. We cannot admit {} at this time."
             .format(self.name, patient.name))
         return self
     else:
         self.patients.append(patient)
         patient.bed_number = random.randInt(1, self.capacity)
         print("Admission successful!")
         return self
Exemple #27
0
def dropSingle(u):
  r = random.randint(0, 10000)
  if r >= 9900:
    return rand_three_star(u)
  if r >= 9000:
    return rand_two_star(u)
  elif r >= 4000:
    return rand_one_star(u)
  else:
    r = random.randInt(100, 1000)
    return item.Item("Mora", r)
Exemple #28
0
 def splitData( self, k, seed, data=None, M=8 ):
     self.testdata = {}
     self.traindata = {}
     data = data or self.data
     random.seed( seed )
     for user, item, record in data:
         if random.randInt(0, M) == k:
             self.testdata.setdefault( user, {} )
             self.testdata[user][item] = record
         else:
             self.traindata.setdefault( user, {} )
             self.traindata[user][item] = record
Exemple #29
0
def main():
    win = gr.GraphWin("Press a key", 400, 400, False)
    shapes = []
    c = gr.Circle(gr.Point(250, 250, 10))
    c.draw(win)
      
    shapes.append(c)
      
    while True
        time.sleep(0.5)
        for thing in shapes:
            dx=random.randInt(-10,10)
            dy = random.randInt(-10,10)
            thing.move(dx,dy)
        
        win.update()
        
        if win.checkMouse()
            break
            
    win.close()    
Exemple #30
0
 def splitData(self, k, seed, data=None, M=8):
     self.testdata = {}
     self.traindata = {}
     data = data or self.data
     random.seed(seed)
     for user, item, record in data:
         if random.randInt(0, M) == k:
             self.testdata.setdefault(user, {})
             self.testdata[user][item] = record
         else:
             self.traindata.setdefault(user, {})
             self.traindata[user][item] = record
Exemple #31
0
def coinPath():
	coinFlip = random.randInt(1,2)
	if coinFlip == 1:
		path = "left"
		coinResult = "heads"
		print("Heads. You begin taking the longer path to the left")
		time(6)
	if coinFlip == 2:
		path = right
		coinResult = "tails"
		print("Tails. You rush into the forest")
		time(3)
Exemple #32
0
	def __init__(self):
		# random number for inital direction of ball
		num = random.randInt(0,9)
		# keep score
		self.tally = 0
		# initalize positions of our paddle
		self.paddle1YPos = WINDOW_HEIGHT / 2 - PADDLE_HEIGHT / 2
		self.paddle2YPos = WINDOW_HEIGHT /2 - PADDLE_HEIGHT / 2
		# ball direction definition
		self.ballXDirection = 1
		self.ballYDirection = 1
		# starting point
		self.ballXPos = WINDOW_HEIGHT / 2 - BALL_WIDTH / 2
Exemple #33
0
 def __init__(self):
     #definindo número aleatório para direção inicial da bola
     num = random.randInt(0, 9)
     #recupera o ponto
     self.tally = 0
     #Inicializando a posição inicial da raquete
     self.paddle1YPos = WINDOW_HEIGHT / 2 - PADDLE_HEIGHT / 2
     self.paddle2YPos = WINDOW_HEIGHT / 2 - PADDLE_HEIGHT / 2
     #definindo a direção da bola
     self.ballXDirection = 1
     self.ballYDirection = 1
     #ponto inicial
     self.ballXpos = WINDOW_HEIGHT / 2 - BALL_WIDTH / 2
Exemple #34
0
    def tell(self,character,obj):
        if random.rand()>0.8:
            self.refuse()
            return false
        myobj = remember(obj)
        if myobj is None:
            printutils.formatdialog(self.pronouns,"I'm afraid I don't know anything about that","said")
            printutils.new_paragraph()
            return false
		
        if type(myobj) is Location:
            #TODO: say its catchphrase and attributes and up to five times either: a character who is there, a route that goes there, an item that's there
            printutils.print_single("Ah, yes, I've been there. "+myobj.catchphrase+" "+myobj.attributes)
            for i in range(random.randInt(1,5)):
                if i>0:
                    
                else:
                    
                #TODO: learn the asker the relevant info, add knowledge item to character's knowledge
        if type(myobj) is Item:
            #TODO: say its catchphrase and attributes and up to five times either: where it is/who has it, what it does, or what it can accomplish (one state it can be used to get to)
            for i in range(random.randInt(1,5)):
                pass
                #TODO: learn the asker the relevant info
            re
        if type(myobj) is Character:
            #TODO: say its catchphrase and attributes and up to five times either: their current location, their current goal, an item they have, a bit of history
            for i in range(random.randInt(1,5)):
                pass
                #TODO: learn the asker the relevant info
        if type(myobj) is State:
            if myobj.character.name != character.name:
                printutils.formatdialog(self.pronouns,"I'm afraid you won't be able to do that at all!","explained")
            else:
                pass
                #TODO: learn the asker all inputs to this state (yes i realize a person won't always know everything about how to achieve something, but we're going to assume they do to simiplify algorithms
        return true
Exemple #35
0
def encourage(e, q):
	x = randInt(1,6)
	if q >= .75:
		if x <= 3:
			output("You are doing fantastic! Do you even need me?")
		else:
			output("Absolute perfection! Why am I here?")
	if .75 > q >= .5:
		if x <= 2:
			output("Almost there, try concentrating on your form!")
		if 4 >= x > 2:
			output("I knew you could do it, now make it perfect!")
		else:
			output("Keep going, today is the day you set a new PR")

	if .5 > q >= .25:
		if x <= 3:
			output("Try slowing down and really working on your technique.")
		else:
			output("Nobody was perfect on their first try, keep working at it.")
	if q < .25:
		output("Is everything okay? Try watching the help videos.")
Exemple #36
0
    def explode(self, maxObjects=3):
        for geom in self.objExplode:
            x, y, z = geom.getPosition()

            if geom.getBody():
                self.space[0].remove(geom)
            self.removeGeom(geom)

            try:
                for _ in range(randInt(0, maxObjects)):
                    g = self.create_geom(maxSize=0.3)

                    for _ in range(self.maxInsertTrials):
                        g.setPosition(self.randomPos(x, y, z, 0.3))
                        if not self.insertCollision(g):
                            self.addGeom(g)
                            self.GetProperty(g).SetOpacity(0.25)
                            break
            except ValueError:
                print ("not my fault")

        self.objExplode = []
def boss_room():
	global maxhealth
	global health
	global attack_min
	global attack_max
	global bosshealth 
	global bossdamage 
	print "You open the door and walk inside to see a room that is warm and cozy. Not dark like the other but well lit with torches and candles"
	print "You also see the one that has kept you here an old slim man"
	print "So you think you can escape my castle good luck"
	print "What do you do?"
	print "1) Kill the boss."
	nextfinal = raw_input(">")
	if nextfinal == "1":
		while bosshealth <= 0:
			bossdamage = bossdamage + random.randInt(0,5)
			health = bossdamage - health
			bosshealth = bosshealth - random.randint(0+ attack_min,20+attack_max)
			if health <= 0:
				print "Now you are here forever"
				exit()
	print "it cant be"
Exemple #38
0
    def create_geom(self, minSize=0.1, maxSize=0.5,
                    minDensity=100, maxDensity=100, minmaxForce=100):
        """Create a box body and its corresponding geom."""
        element = randInt(1, 3)

        if element == 1:
            body, geom = self.create_sphere(rand(minDensity, maxDensity),
                                            rand(minSize, maxSize))
        elif element == 2:
            body, geom = self.create_capsule(rand(minDensity, maxDensity),
                                             rand(minSize, maxSize),
                                             rand(minSize, maxSize))
        elif element == 3:
            body, geom = self.create_box(rand(minDensity, maxDensity),
                                         rand(minSize, maxSize),
                                         rand(minSize, maxSize),
                                         rand(minSize, maxSize))

        body.addForce((rand(-minmaxForce, minmaxForce),
                       rand(-minmaxForce, minmaxForce),
                       rand(-minmaxForce, minmaxForce)))

        return geom
def parsecodes(allStates):
    url = 'https://web3.ncaa.org/hsportal/exec/hsAction'
    codehtmlfilename = 'schoollist.html'
    codetextfile = 'codes.txt'
    user_agent = {
        'User-agent':
            'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36'}
    session = requests.Session()

    try:
        os.remove(codetextfile)
    except OSError:
        pass

    try:
        for state in allStates:
            print state
            response = session.post(url, headers=user_agent, data={'hsActionSubmit': 'Search', 'state': state})
            time.sleep(randInt(2, 4))

            with open(codehtmlfilename, 'w') as codefile:
                print >> codefile, response.text.encode('utf-8')

            with open(codehtmlfilename) as f:
                pagedata = f.read()
                soup = BeautifulSoup(pagedata, "html.parser")
                allvalues = soup.find_all('input', {'name': 'hsCode'})
                for s in allvalues:
                    codevalue = s.attrs['value'].strip()
                    print codevalue
                    if codevalue:
                        with open(codetextfile, 'a') as myfile:
                            myfile.write(state + '|' + codevalue + '\n')
    finally:
        session.close()
        print 'Finished saving the codes'
Exemple #40
0
"	정재훈	",
"	정지윤	",
"	정현지	",
"	정희영	",
"	조대연	",
"	조승완	",
"	진유림	",
"	차강혁	",
"	천상원	",
"	최가람	",
"	최병훈	",
"	최봉재	",
"	최정연	",
"	최현묵	",
"	추은선	",
"	하동현	",
"	하조은	",
"	하태지	",
"	한웅제	",
"	홍은진	",
"	Hanur Lee	",
"	Hyesu Bae	",
"	Jinho Jung	",
"	xodla	"
]

for i in range(0, 20):
	member_count = len(9xd_members)
	idx = random.randInt(member_count)
	print(9xd_members.pop(idx))
Exemple #41
0
import random

class AI(BaseAI):
  """The class implementing gameplay logic."""
  @staticmethod
  def username():
    return "Shell AI"

  @staticmethod
  def password():
    return "password"

  CLAW, ARCHER, REPAIRER, HACKER, TURRET, WALL, TERMINATOR, HANGAR = range(8)

  def spawn(self)
    self.players[self.playerID].orbitalDrop(0,0,random.randInt(0,7))
	return
  
  ##This function is called once, before your first turn
  def init(self):

    pass

  ##This function is called once, after your last turn
  def end(self):
    pass

  ##This function is called each time it is your turn
  ##Return true to end your turn, return false to ask the server for updated information
  def run(self):
    
Exemple #42
0
import RPi.GPIO as GPIO
from time import sleep
import random

GPIO.setmode(GPIO.BCM)

GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(25, GPIO.OUT)

coins = 6
GPIO.output(25,GPIO.LOW)

result = random.randInt(1,9)

jackpot = 10
halfWin = 5
moneyBack = 1

while True:
	sleep(2)

	if result == jackpot or result == halfWin or result == moneyBack:
		GPIO.wait_for_edge(24, GPIO.RISING)
		coins += 1
		
		if result == jackpot:
	 		if coins == 10:
				GPIO.output(25,GPIO.LOW)
				print "jackpot"
			else:
				GPIO.output(25,GPIO.HIGH)
def getRandomKey():
	while True:
		keyA = random.randInt(2,len(SYMBOLS))
		keyB = random.randInt(2,len(SYMBOLS))
		if(gcd(keyA,len(SYMBOLS)) == 1):
			return keyA * len(SYMBOLS) + keyB