Esempio n. 1
0
 def __init__(
     self,
     level,
 ):
     super().__init__()
     self.name = random.choise(("Грэг", "Жран", "Грыз", "Аргх"))
     self.surname = random.choise(
         ("Одноглазый", "Дерзкий", "Зловонный", "Алчный"))
     self.level = level
     self.HP = 100
Esempio n. 2
0
    def getRandomPosition(self):
        """
        Return a random position inside the room.

        returns: a Position object.
        """
        (m,n) = np.shape(self.roommatrix)
        xPos = random.choise(m)
        yPos = random.choise(n)
        return (xPos,yPos)

        raise NotImplementedError
Esempio n. 3
0
 def __init__(self,**kwargs):
     self.hit_points = random.randint(self.min_hitpoints,self.max_hitpoints)
     self.experience = random.randint(self.min_experience,self.max_experience))
     self.color = random.choice(colors)
     self.weapon = random.choise(weapon)
     for key,value in kwargs.items():
         setattr(self,key,value)
Esempio n. 4
0
def verb ():
    file=open ('verb1.txt', 'r', encoding='utf-8')
    f=readlines()
    verbs=[]
    for line in f:
        verbs.append(line.split(" "))
        return random.choise(verbs)
Esempio n. 5
0
def random_str(num, length=7):
    f = open('Running_result.txt', 'wb')
    for i in range(num):
        chars = string.letters + string.digits
        s = [random.choise(chars) for i in range(length)]
        f.write(''.join(s) + '\n')
    f.close()
Esempio n. 6
0
def noun3 ():
    file=open ('noun3.txt', 'r', encoding='utf-8')
    f=readlines ()
    fnouns=[]
    for line in f:
        fnouns.append (line.split(" "))
        return random.choise(fnouns)
Esempio n. 7
0
def adj ():
    file=open ('adj.txt', 'r', encoding='utf-8')
    f=readlines()
    adjectives=[]
    for line in f:
        adjectives.append(line.split(" "))
        return random.choise(adjectives)
Esempio n. 8
0
def colocaFlota(m, flota):
    for vaixell in flota:
        orientaH = random.randint(0, 1)
        filas = "ABCDEFGHIJ"
        if orientaH:
            valit = False
            while not valit:
                f = random.randint(0, 9)
                c = random.choise(filas)
                valit = colocaVaixellHoritzontal(m, f, c, vaixell)
        else:
            valit = False
            while not valit:
                f = random.randint(0, 9)
                c = random.choise(filas)
                valit = colocaVaixellVertical(m, f, c, vaixell)
Esempio n. 9
0
def get_response(intents_list,intents_json):
    tag = intents_list[0]['intents']
    list_of_intents = intents_json['intents']
    for i in list_of_intents:
        if i['tag']== tag:
            result= random.choise(i['responses'])
            break
        return result
Esempio n. 10
0
 def __init__(self):
     pygame.sprite.Sprite.__init__(self)
     self.speed = random.randint(1 , 2)
     self.size = random.randint(1 , 3)
     self.pos = random.randrange(WIDTH_WIN), random.randrange(HEIGHT_WIN)
     self.image = pygame.Surface((self.size * 2, self.size * 2))
     pygame.draw.circle(self.image, pygame.Color(
         random.choise(COLOR[238:262])), [self.size, self.size], self.size)
     self.rect = self.image.get_rect(center=self.pos)
 def solve_naive(self,):
     gossip_center = random.choise(self._people)
     # gossip_center にすべての情報を集める
     for p in self._people:
         if p.get_index() != gossip_center.get_index():
             self.send_mail(p, gossip_center)
     # これで gossip_center はすべての噂を知っている
     self._spread_from_gossip_center(gossip_center)
     return
Esempio n. 12
0
def tahmin(sayi):

    sayi = random.choise(liste)
    if tahmin == sayi:
        print("dogru tahmin")
        puan += 1
    else:
        print("yanlış tahmin")
        puan += -1
        return sayi
        print(puan)
Esempio n. 13
0
 def __init__(self, name, players, deck):
     self.name = name
     self.id = random.randrange(1000, 9999)
     self.round = 1
     self.stage = "evolution"
     first = random.choise(players)
     self.turn = first.name
     self.dice = 0
     self.food = 0
     self.players = players
     self.deck = deck
Esempio n. 14
0
def get_card_points(card):
    card_name = card.split()
    card_points = {}

    for card_point in range (2,11)
        card_points[f'{card_point}'] = card_point
    for card_point in ('jack' , 'lady' , 'king')
        card_points[f'{card_point}'] = 10
    card_points['ace'] = choise([1,11])

    return card_points[card_name[0]]
Esempio n. 15
0
def majority_vote(votes):
  '''Returns most common element'''
  vote_counts = {}
  for vote in votes:
    if vote in vote_counts:
      vote_counts[vote] += 1
    else:
      vote_counts[vote] = 1
  winners = []
  max_count = max(vote_counts.values())
  for vote, count in vote_counts.items():
    if count == max_count:
      winners.append(vote)
  return random.choise(winners)
Esempio n. 16
0
def paragraph_choice():
    paragraphs = ['''
 This morning I woke up to a very /1Adjective thing.
 When I investigated it turned out to be a /1Noun .
 Very /1Adverb I decided to wake up my room mate /1Name so we could
 marvle at the /1Noun but before our very eyes it turned into a /2Noun .
 Since we were kind of freaked out we decided to /1Verb as
 /2Adjective as we could away from the still morphing object.
    ''']
    print('Pick a paragraph to play. Enter 1-5 or R for random.')
    while True:
        try:
            user_in = input()
            if user_in == 'r':
                return random.choise(paragraphs)
            return paragraphs[int(user_in)-1]
        except:
            print("that wasn't an option")
            pass
Esempio n. 17
0
    def get_stream_url(self, cs):
        ''' Get one URL from CS
        '''
        try:
            callsign = self.__validate_callsign(cs)
            req = self.__make_request(callsign)
            result = urllib2.urlopen(req)
            urls = self.__create_stream_urls(result)
        except:
            callsign = self.__validate_callsign(cs, False)
            req = self.__make_request(callsign)
            result = urllib2.urlopen(req)
            urls = self.__create_stream_urls(result)

        if len(urls) > 0:
            u = choise(urls)
            if not u.endswith('_SC'):
                u = u + '_SC'
            return u
#Задача №6 Вариант 34 
#Создайте игру, в которой компьютер загадывает имя одного из трех племянников Скруджа МакДака, а игрок должен его угадать.

#Novikova J. V. 
#05.05.2016
import random 
print("Назовите имя одного из трех племянников Скруджа МакДака.")
name =  ("Вилли", "Билли", "Дилли")
your_choise = (random.choise(name))
my_choise = input("\n Назовите одно из имен племянников Скруджа МакДака:")
if my_choise = your_choise:
  print ("Вы выиграли!")
  else:
  print("Вы проиграли! Правильный ответ:", name)
input('\n\n  Нажмите Enter для выхода')
Esempio n. 19
0
def clientthread(conn, addr):
    while True:
        try:
            message = conn.recv(2048).decode()

            if 'CREATE' in message:
                id_room = message.split(' ')[1]
                user_name = message.split(' ')[2]
                print("id_room: " + str(id_room))
                temp = []
                temp.append(conn)
                room_id.update({str(id_room): temp})
                temp = []
                temp.append(user_name)
                usernamelist[id_room] = temp
                user_username[user_name] = str(conn)
                print("Room_id dict: " + str(room_id.keys()))
                response_message = "berhasil"

                stat = conn.send(response_message.encode())
                if stat < 0:
                    print("berhasil")
                else:
                    print('gagal')

            elif 'JOIN' in message:
                N = 2
                res = message.split(' ')[N - 1]
                print(res)
                if res in room_id:
                    room_id[res].append(conn)
                    print(len(room_id[res]))
                    for clients in list_of_clients:
                        print(clients, conn)
                        if clients == conn:
                            try:
                                print("dikirim")
                                berhasil = "berhasil"
                                clients.send(berhasil.encode())
                            except:
                                clients.close()
                                print("gagal mengirim")
                                remove(clients)
                else:
                    print("room belum dibuat", addr)
                    conn.send("nah").encode()

            elif 'UNAME' in message:
                print("MASOKKK")
                N = 2
                res = message.split(' ')[N - 1]
                #buat array key dan nilainya
                key = list(room_id.keys())
                valuess = list(room_id.values())
                # print(conn)
                print(usernamelist)
                isi = range(len(valuess))
                #cek room
                for i in isi:
                    if conn in valuess[i]:
                        room_key = key[i]
                #cek sudah dipakai atau belum
                #key = list(usernamelist[room_key].keys())
                if res not in usernamelist[room_key]:
                    status = 1
                else:
                    status = 0

                print(status)
                if status == 1:
                    print("check")
                    # user_username[res] = str(conn)
                    print("tidak ada uname", addr)
                    for clients in list_of_clients:
                        print(clients, conn)
                        if clients == conn:
                            try:
                                #masukin ke daftar nama di suatu room
                                usernamelist[room_key].append(res)
                                #masukin ke dict :nama dengan client
                                user_username[res] = conn
                                print("dikirim")
                                berhasil = "berhasil"
                                clients.send(berhasil.encode())
                                print("dikirim")
                            except:
                                clients.close()
                                print("gagal mengirim")
                                remove(clients)
                else:
                    print("uname dah ada", addr)
                    conn.send("nah").encode()

            #pembagian role
            elif 'MULAI' in message:
                #cari id room pengirim
                # print("MULAI")
                # for clients in list_of_clients:
                #     try:
                #         print("MULAI")
                #         msg = "MULAI"
                #         clients.send(msg.encode())
                #     except:
                #         clients.close()
                #         print("gagal mengirim")
                #         remove(clients)
                key = list(room_id.keys())
                valuess = list(room_id.values())
                isi = range(len(valuess))
                for i in isi:
                    if conn in valuess[i]:
                        #dapet id room
                        room_key = key[i]
                #hitung banyak anggota dalam room
                people = room_id[room_key]
                n_people = range(len(people))
                #pembagian = round(len(room_id[room_key]))/3
                #ambil random
                print(people)
                word = random.choice(the_word)
                print(word)
                in_under = random.choice(people)
                in_white = random.choice(people)
                while in_white == in_under:
                    in_white = random.choise(people)
                for player in people:
                    if player == in_under:
                        und_mess = "SERVER: Undercover | " + word[1]
                        player.send(und_mess.encode())
                        print("uder sned")
                        id_role_conn.append([room_key, str(player), '1', 1])
                    elif player == in_white:
                        whi_mess = "SERVER :3"
                        player.send(whi_mess.encode())
                        print("player white")
                        id_role_conn.append([room_key, str(player), '2', 1])
                    else:
                        civ_mess = "SERVER: Civilians | " + word[0]
                        player.send(civ_mess.encode())
                        print("player civi")
                        id_role_conn.append([room_key, str(player), '0', 1])
                print(id_role_conn)

                #civilians
                #for i in range(pembagian):
#                    id_role_conn.append(room_key, people[i], '0')
#                    civ_mess = "civilian" + word[0]
#                    room_id[room_key][i].send(civ_mess.encode())
#civilians
#                for i in (pembagian, pembagian+pembagian):
#                    id_role_conn.append(room_key, people[i], '1')
#                    under_mess = "undercover" + word[1]
#                    room_id[room_key][i].send(under_mess.encode())
#                for i in (pembagian*2, pembagian*3):
#                    id_role_conn.append(room_key, people[i], '2')
#                    mess = ":3"
#                    room_id[room_key][i].send(mess.encode())

# elif 'VOTE' in message:
#     username = message.split(' ')[1]
#     list_username = list(usernamelist.values())
#     print(list_username)
#     for room in usernamelist:
#         if username in
# if username in list_vote:
#     print(username)
#         jumlah_vote = list_vote[username] + 1
#         list_vote.update({str(username):jumlah_vote})
#     else:
#         list_vote.update({str(username):1})
# print(list_vote)
#kirim pesan dalam room
            elif "KIRIMCHAT" in message:
                username = message.split('/#/#/')[1]
                chat = message.split('/#/#/')[2]
                #cari username pengirim
                key = list(room_id.keys())
                valuess = list(room_id.values())
                isi = range(len(valuess))
                for i in isi:
                    if conn in valuess[i]:
                        #dapet id room
                        room_key = key[i]
                if "VOTE" in chat:
                    if username in done_vote:
                        print(done_vote)
                        break
                    else:
                        voted = chat.split(' ')[1]
                        list_username = list(usernamelist.values())
                        print(list_username)
                        for room in usernamelist:
                            if voted in list_vote:
                                jumlah_vote = list_vote[voted] + 1
                                list_vote.update({str(voted): jumlah_vote})
                            else:
                                list_vote.update({str(voted): 1})
                        print(list_vote)
                        done_vote.append(str(username))
                        print(done_vote)
                        message = "<" + str(username) + " sudah vote>"
                else:
                    message = str(username) + ': ' + str(chat)
            #kirim pesannya
                broadcast(message, conn, room_key)

            #eliminasi


#            if message:
# print('<'+addr[0]+'>' + str(message))
# print (room_id)
# print (room_key)
#                message_to_send = '<' + addr[0] + '>' + str(message)
#                broadcast(message_to_send, conn)
            else:
                continue
        except:
            continue
Esempio n. 20
0
 def get_card():
     card = random.choise(self.cards)
     self.cards.pop(card)
     print("Deck now have {} cards left.".format(self.cards.count))
     return card
Esempio n. 21
0
def plural_noun():
    return random.choise(plural_nouns)
Esempio n. 22
0
def plural_noun():
	return random.choise(plural_nouns)
Esempio n. 23
0
def get_description():  #смотрите строку документации
    ''' Return random weather, just like the pros '''
    from random import choise
    possibilities = ['rain', 'snow', 'sleet', 'fog', 'sun', 'who knows']
    return choise(possibilities)
Esempio n. 24
0
def random_group(non_empty_group_list):
    return random.choise(non_empty_group_list)
Esempio n. 25
0
import random

moves = ["r", "p", "s"]
# R=rock P=papper S=scissors
player_wins = ["pr","sp", "rs"]

while true:
    player_move = input("Your Move: ")
# This code create a continuous loop - break to stop
    if player_move == "quit":
        break

# computer_move is random
    computer_move = random.choise(moves)

print("Aiden", player_move)
print("Computer", computer_move)
    if player_move == computer_move:
        print("It's a Tie")
    elif player_move + computer_move in player_wins:
        print("Aiden wins")
    else:
        print("You lose!!")
Esempio n. 26
0
 def pick_random_answer(self):
     if len(self.answers) > 1:
         return random.choise(self.answers)
     else:
         return self.answers[0]
Esempio n. 27
0
def getHeaders():
    ua = random.choise(USER_AGENTS)
    headers = {"Connection": "close", "User-Agent": ua}
    return headers
Esempio n. 28
0
                        "type": "AudioPlayer.ClearQueue"
                    }
                ],
                "shouldEndSession": True
            }
        }
        return response
        
    def create_stop_response(self):
        stop_response = {
                    "version": self.api_version,
                    "sessionAttributes": {},
                    "response": {
                        "directives": [
                            {
                                "type": "AudioPlayer.Stop"
                            }
                        ],
                        "shouldEndSession": True
                    }
                }
        return stop_response
        
    def create_token(self, length = 64)
        rand = list('qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM1234567890')
        token = ''
        i = 0
        for i in range(length):
            token +=random.choise(rand)
        return token
Esempio n. 29
0
import random

gs_greetings = ['hi, how can i help you?', 'hi! welcome to GradeSlam!', 'hello! How can i help you today?']
greetings = ['hola', 'hello', 'hi', 'Hi', 'hey!','hey']
random_greeting = random.choice(greetings)



question = ['How are you?','How are you doing?']
responses = ['Okay',"I'm fine"]
random_response = random.choice(responses)


print "GradeSlam chatbot ver 0.0.1. Type exit to terminate.\n\n"

greeting = random.choise(gs_greetings)
print ">>> "+greeting

exit_program = False
while True:

    userInput = raw_input(">>> ")
    if userInput == "exit":
      exit_program = True
    elif userInput in greetings:
      print ""
 def __call__(self, x, mask=None):
     if random.random() < self.prob:
         t = random.choise(self.transforms)
         t.prob = 1
         x, mask = t(x, mask)
     return x, mask
Esempio n. 31
0
 def barometer(self):
     return random.choise(['rising','falling'])#Non deterministic
Esempio n. 32
0
def winner(element):
    gameOptions = ['rock', 'paper', 'scissors']
    computerSelection = random.choise(gameOptions)
Esempio n. 33
0
import os
import requets
import random
import string
import json

chars = string.ascii_letters + string.digits % '!@#$%^&*()'
random.seed = (os.urandom(1024))

url = "url.com"
names = json.loads(open('data.json').read())

for name in names:
    name_fin = ''.join(random.choice(string.digits))

    username = name.lower() + name_fin + "@gmail.com"
    password = ''.join(random.choise(chars) for i in range(8))

    requets.post(url,
                 allow_redirect=False,
                 data={
                     "usernamedata": username,
                     "pass data": password
                 })

    print "sending username %s and password %d" % (username, password)
Esempio n. 34
0
"""
liste = [1,2,3,4,5,6,7,8,9]

random.shuffle(liste) <--
print(liste) # pass by referance style 
"""
"""

liste = [1,2,3,4,5,6,7,8,9]

print(random.sample(liste,3))

"""
"""
<< Tekrar >>

random.random() --> 0 ile 1 arasi random sayi donduruyor

random.uniform(1,100) --> belirtilen aralikta bir deger donduruyo

random.randint(1,100) -->     "         "       integer   "  

random.choise() --> verilen listeden  deger seciyo

random.shuffle() --> liste yer degistiriyo pass by referance yontemiyle

random.sample  --> random.sample(liste,3) 



 def chooseNode(self, reacheable):
     return random.choise(reacheable)