def test_translate_board(): board = '7@28,18 0 8@25,17 5 15@27,17 3 17@29,15 3 18@28,14 0 20@28,16 3 32@25,15 2 34@27,15 0 35@26,16 2 52@24,16 3' boardstring = tu.translate_board(board) assert boardstring == [[7, 8, 15, 17, 18, 20, 32, 34, 35, 52], [[28, 18], [25, 17], [27, 17], [29, 15], [28, 14], [28, 16], [25, 15], [27, 15], [26, 16], [24, 16]], [0, 5, 3, 3, 0, 3, 2, 0, 2, 3]]
def test_translate_empty_board(): board = '' boardstring = tu.translate_board(board) assert boardstring == [ [], [], [] ]
51:"GBRBRG", 52:"GRBRBG", 53:"RBGBGR", 54:"RGBGBR", 55:"BRGRGB", 56:"BGRGRB"} tiles = {} for i, tile in enumerate(all_tiles): thistile = tu.Tile(tile, 0, all_tiles[tile], 'stack') tiles[thistile.ID] = thistile del all_tiles # boardstring comes from example in Oliver's pdf, Fig 4.1 THESE TWO COME FROM THE TANTRIX SERVER orig_boardstring = '7@28,18 0 8@25,17 5 15@27,17 3 17@29,15 3 18@28,14 0 20@28,16 3 32@25,15 2 34@27,15 0 35@26,16 2 52@24,16 3' orig_rack = '0:G 47 25 5 3 46 19 1:B 36 31 6 11 40 48' board = tu.translate_board(orig_boardstring) rack_player, rack_opponent = tu.translate_rack(orig_rack) # Due to this board thing, update the tiles: for i, tile in enumerate(board[0]): # The rotate updates colors and position tiles[tile].rotate(board[2][i]) tiles[tile].place = 'board' tiles[tile].coords = board[1][i] for tile in rack_player: tiles[tile].place = 'rack_player' for tile in rack_opponent: tiles[tile].place = 'rack_opponent' #print coords_in_dir([27,15],0)