Пример #1
0
def load(grid_id):
    "Load game state from examples"
    difficulty = request.args['difficulty']

    if grid_id not in grid_data or grid_data[grid_id] == None:
        return 'invalid id', 403

    grid = Grid(load_from=grid_data[grid_id])
    grid.read_file(f'examples/{grid.box_len}/{difficulty}.txt')

    grid_data[grid_id] = repr(grid)
    save_data()

    return 'loaded'
Пример #2
0
def load():
    box_len = get_box_len()

    difficulties = {1: 'easy', 2: 'medium', 3: 'hard', 4: 'harder'}

    print('Pick a difficulty to solve:')
    print('  1. Easy')
    print('  2. Medium')
    print('  3. Hard')
    print('  4. Harder')
    difficulty = difficulties[int(input())]

    choice = f'examples/{box_len}/{difficulty}.txt'
    grid = Grid(box_len)
    grid.read_file(choice)
    return grid