Esempio n. 1
0
    idx = 0
    for z in range(board_z):
        print 'LAYER {}'.format(z + 1)
        for y in range(n_dims_half, board_y + n_dims_half):
            for x in range(n_dims_half, board_x + n_dims_half):
                # ビアを赤色で表示
                if _pboards is not None and _boards[z][y][x]['type'] == 1 and _pboards[z][y][x]['type'] == 'via':
                   sys.stdout.write('\033[1;31;47m {} \033[0m'.format(nl.int2str(_boards[z][y][x]['data'], 36)))
                elif _boards[z][y][x]['type'] == 1:
                   sys.stdout.write('\033[1;30;47m {} \033[0m'.format(nl.int2str(_boards[z][y][x]['data'], 36)))
                else:
                    # 正しい配線形状
                    fr_color = '30'

                    # 途切れてないセル / 途切れてるセル
                    bg_color = '47'
                    if show_float:
                        if _boards[z][y][x]['float'] != None:
                            bg_color = '43'

                    sys.stdout.write('\033[1;{};{}m{}\033[0m'.format(fr_color, bg_color, shstr[_boards[z][y][x]['shape']]))

                    idx = idx + 1
            print ''

board_x, board_y, board_z, boards = nl3d.read_ansfile(input_answer, n_dims)
pboards = None
if problem_file is not None:
    _, _, _, pboards = nl3d.read_probfile(problem_file, n_dims)
show_board(boards, pboards)
Esempio n. 2
0
            if _from == 'east':
                return _find_path(_board, x - 1, y, 'east', depth) + cur
            elif _from == 'west':
                return _find_path(_board, x + 1, y, 'west', depth) + cur
            else:
                return []
        else:
            #raise Exception('Never reachable here')
            return []


# Testing phase
if (not args.answer):
    board_x, board_y, board_z, boards = nl3d.read_probfile(input_problem, n_dims)
else:
    board_x, board_y, board_z, boards = nl3d.read_ansfile(input_problem, n_dims)

x_data = [[] for z in range(board_z)]
for z in range(board_z):
    x_data[z], _ = nl.gen_dataset_shape(board_x, board_y, boards[z], n_dims, method)

x_test = [[] for z in range(board_z)]
for z in range(board_z):
    x_test[z] = np.array(x_data[z], dtype=np.float32)

result = [[] for z in range(board_z)]
for z in range(board_z):
    result[z] = evaluate(x_test[z])

# boards_pr: 予想される配線のボード
# `wrong` に間違った配線形状かどうか記録する