def setupGame(r): print 'Welcome.' tiles = [] for i in range(7): for j in range(i, 7): tiles.append((i, j)) random.shuffle(tiles) my_tiles = tiles[:7] print 'I have:', my_tiles print print 'Players are numbered as the following:' print '(0 = me, 1 = opponent on my right,' print '2 = partner across from me, 3 = opponent on my left)' players_tiles = {} players_tuples = [None] * 4 players_tiles[0] = set(map(lambda x: Domino(*x), my_tiles)) players_tuples[0] = my_tiles for i in range(1, 4): this_players_tiles = tiles[7 * i:7 * (i + 1)] print 'Player ' + str(i) + ' has:', this_players_tiles players_tiles[i] = set(map(lambda x: Domino(*x), this_players_tiles)) players_tuples[i] = this_players_tiles starter = r % 4 print "Player " + str(starter) + " is starting." print return ((Dominoes(tiles, my_tiles, starter), Dominoes(tiles, players_tuples[2], (starter + 2) % 4)), players_tiles)
def setupGame(): ''' Enter the tiles that I have. Enter who is starting the game. A little bit of checking about validity of inputs and organizing/standardizing/cleaning but please don't input something too crazy. @returns - Dominoes ''' print 'Welcome.' tiles = [] for i in range(7): for j in range(i, 7): tiles.append((i, j)) while True: my_tiles_input = raw_input('Enter one computer\'s tiles (e.g. 45) seperated by spaces: ').split() if len(my_tiles_input) == 7: break else: print "I need 7 tiles!" my_tiles = [] for t in my_tiles_input: my_tiles.append(tuple([int(num) for num in t])) print 'I have:', my_tiles print while True: other_tiles_input = raw_input('Enter other computer\'s tiles (e.g. 45) seperated by spaces: ').split() if len(other_tiles_input) == 7: break else: print "I need 7 tiles!" other_tiles = [] for t in other_tiles_input: other_tiles.append(tuple([int(num) for num in t])) print 'I have:', other_tiles print print 'Players are numbered as the following:' print '(0 = me, 1 = opponent on my right,' print '2 = partner across from me, 3 = opponent on my left)' while True: starter = int(raw_input('Who is starting? ')) if starter < 4 and starter >= 0: break else: print "Not valid, try again" print "Player " + str(starter) + " is starting." print return (Dominoes(tiles, my_tiles, starter), Dominoes(tiles, other_tiles, (starter+2)%4))
def setupGame(r): print 'Welcome.' tiles = [] for i in range(8): for j in range(i, 8): tiles.append((i, j)) random.shuffle(tiles) my_tiles = tiles[:8] print 'I have:', my_tiles print print 'Players are numbered as the following:' print '(1 = me, 1 = opponent on my right,' print '3 = partner across from me, 3 = opponent on my left)' players_tiles = {} players_tiles[1] = set(map(lambda x: Domino(*x), my_tiles)) for i in range(2, 4): this_players_tiles = tiles[8 * i:7 * (i + 1)] print 'Player ' + str(i) + ' has:', this_players_tiles players_tiles[i] = set(map(lambda x: Domino(*x), this_players_tiles)) starter = r % 5 print "Player " + str(starter) + " is starting." if starter > 1: start_tile = greedyStarts(players_tiles[starter]) print "I placed a " + str(start_tile) players_tiles[starter].remove(start_tile) start_tile = start_tile.vals else: start_tile = greedyStarts(my_tiles) print "I placed a " + str(start_tile) start_tile = start_tile.vals print return (Dominoes(tiles, my_tiles, starter, start_tile), players_tiles)
def setupGame(): ''' Enter the tiles that I have. Enter who is starting the game. A little bit of checking about validity of inputs and organizing/standardizing/cleaning but please don't input something too crazy. @returns - Dominoes ''' print 'Welcome.' tiles = [] for i in range(7): for j in range(i, 7): tiles.append((i, j)) while True: my_tiles_input = raw_input( 'Enter my tiles (e.g. 45) seperated by spaces: ').split() if len(my_tiles_input) == 7: break else: print "I need 7 tiles!" my_tiles = [] for t in my_tiles_input: my_tiles.append(tuple([int(num) for num in t])) print 'I have:', my_tiles print print 'Players are numbered as the following:' print '(0 = me, 1 = opponent on my right,' print '2 = partner across from me, 3 = opponent on my left)' while True: starter = int(raw_input('Who is starting? ')) if starter < 4 and starter >= 0: break else: print "Not valid, try again" print "Player " + str(starter) + " is starting." if starter > 0: print 'Write down your move (e.g. 23):' move = raw_input("").strip() start_tile = tuple([int(v) for v in move]) else: start_tile = greedyStarts(my_tiles) # TODO: change print "I placed a " + str(start_tile) print return Dominoes(tiles, my_tiles, starter, start_tile)
def setupGame(): ''' Enter the tiles that I have. Enter who is starting the game. A little bit of checking about validity of inputs and organizing/standardizing/cleaning but please don't input something too crazy. @returns - Dominoes ''' print 'Welcome.' tiles = [] for i in range(7): for j in range(i, 7): tiles.append((i, j)) while True: my_tiles_input = raw_input('Enter my tiles (e.g. 4-5) seperated by spaces: ').split() if len(my_tiles_input) == 7: break else: print "I need 7 tiles!" my_tiles = [] for t in my_tiles_input: my_tiles.append(tuple(sorted([int(num) for num in t.split('-')]))) print 'You have:', my_tiles print print 'Players are numbered as the following:' print '(0 = me, 1 = opponent on my right,' print '2 = partner across from me, 3 = opponent on my left)' while True: starter = int(raw_input('Who is starting? ')) if starter < 4 and starter >= 0: break else: print "Not valid, try again" print "Player " + str(starter) + " is starting, places 6-6 on the board." if starter == 0: my_tiles.remove((6, 6)) print alg = bad # TODO: change this to actual function name return Dominoes(tiles, my_tiles, starter, alg)