def fx(): L = ['\u2660', '\u2663', '\u2665', '\u2666'] l = [str(x) for x in range(2, 11)] l += [ 'A', 'J', 'Q', 'K', ] w = ['大王', '小王'] pai = [x + y for x in L for y in l] P = pai + w from random import shuffle as sh sh(P) k = 1 while True: i = input('按回车键发牌') if k == 1: f = P[0:17] elif k == 2: f = P[17:34] elif k == 3: f = P[34:51] else: print('底牌:\n%s' % P[51:54]) break print('第%d个人的牌:\n%s' % (k, sorted(f, key=lambda x: x[1]))) k += 1
def init_deck(mine, plant, tower, scours): global my_deck, opp_deck #my_deck my_deck = [0] * (40 - (mine + plant + tower + scours) - 1) mine_deck = [MINE] * mine plant_deck = [POWER_PLANT] * plant tower_deck = [TOWER] * tower scours_deck = [SCOURS] * scours my_deck = my_deck + mine_deck + plant_deck + tower_deck + scours_deck sh(my_deck) #opp_deck opp_deck = [0] * (40 - (mine + plant + tower) ) + opp_deck + mine_deck + plant_deck + tower_deck sh(opp_deck)
def loadfromtxt(self, fname='train1.txt', shuffle=True): path = os.path.join(self.labels_dir, fname) with (open(path, 'r')) as f: list = [line.rstrip().split('/')[2] for line in f] f.close() # loadcompleteimages the category and generate the look up table label = [] img = [] if shuffle: from random import shuffle as sh list = sh(list) for file in list: index, img = self._load(file) label.append(index) img.append(img) return np.array(img), np.array(label)
def loadfromtxt(self, fname='train.txt', shuffle=True): path = os.path.join(self.labels_dir, fname) # label, photo_id, x, y with (open(path, 'r')) as f: file_list = [line.rstrip().split(',') for line in f] f.close() # load the category and generate the look up table label = [] img = [] if shuffle: from random import shuffle as sh file_list = sh(file_list) for file in file_list: index, img = self._load(file) label.append(index) img.append(img) return np.array(img), np.array(label)
# import random # # x = random.randint(1,10) # for i in range (10): # print(random.randint(1,10)) from random import randint x = randint(1,20) print(x) from random import shuffle as sh list = [1,2,3,5,6,3] sh(list) print(list)
def shuffle(self): from random import shuffle as sh sh(self.deck)
def shuffle(self): sh(self.cards)
def shuffle(self): sh(self)
#!/usr/bin/env python # -*- coding:utf-8 -*- values = range(1, 11) + 'J Q K'.split() suits = 'Dianonds clubs hearts spades'.split() deck = ['%s of %s' % (v, s) for v in values for s in suits] from pprint import pprint as p p(deck) from random import shuffle as sh sh(deck) p(deck) print '-' * 30 while deck: raw_input(deck.pop())
def shuffle(self): from random import shuffle as sh self.new_regular() for x in range(7): sh(self.cards)