コード例 #1
0
ファイル: Day11.py プロジェクト: AlexGirardDev/AdventOfPython
def day11_1():
    dir = False
    x = 100
    y = 100
    painted = {(x,y): 0}
    direction = 0 

    f = og.copy()
    comp = Computer(f,1,100000)
    while not comp.done:
        output = comp.iterate(painted[(x, y)])
        if dir:
            direction = set_direction(direction, output)
            if direction == 0:
                y -= 1
            elif direction == 1:
                x += 1
            elif direction == 2:
                y += 1
            elif direction == 3:
                x -= 1
            painted[(x, y)] = painted[(x,y)] if painted.get((x,y)) is not None else 0
        else:
            painted[(x, y)] = output
        dir = not dir
    print(len(painted))
    for x in range(200):
        output = ""
        for y in range(200):
            if painted.get((x, y)):
                output += "#" if painted[(x, y)] == 1 else "."
            else:
                output += "."
        print(output)
コード例 #2
0
    if idx == 3: return "▃"
    if idx == 4: return "⚽"

com = Computer(og, 0, 10000)
idx = 0
x = 0
y = 0
code = 0
grid_size = 100
grid = [[None for y in range(26)] for x in range(46)]
counter = 0
last_score = 0
ball_x = 0
block_x = 0
while not com.done:
    output = com.iterate(None)
    if output is None:
        print(last_score)
        temp_grid = np.transpose(grid)
        output = ""
        for x2 in range(len(temp_grid)):
                
                for y2 in range(len(temp_grid[x2])):
                    if get_tile(temp_grid[x2][y2]) is not None:
                        output += get_tile(temp_grid[x2][y2])
                if output != "":
                    output += "\n"
        print(output)
        
        sleep(0.08)
        #system('cls')