This repository has been archived on 2026-10-01. You can view files and clone it, but cannot push or open issues or pull requests.
2026-rff_mp/SobolevNS/docs/data/task2_maze/generate_weighted_choice.py
2026-05-22 13:45:29 +03:00

20 lines
797 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""generate_weighted_choice.py - создаёт лабиринт, где Dijkstra/A* реально
обходят 'болото' и находят более дешёвый путь, чем BFS."""
W, H = 21, 13
grid = [[' '] * W for _ in range(H)]
# периметр
for x in range(W):
grid[0][x] = '#'; grid[H-1][x] = '#'
for y in range(H):
grid[y][0] = '#'; grid[y][W-1] = '#'
# центральное болото 5х5 (вес 3)
for y in range(4, 9):
for x in range(8, 13):
grid[y][x] = '~'
# старт слева в центре, выход справа в центре
grid[H//2][1] = 'S'
grid[H//2][W-2] = 'E'
with open('mazes/weighted_choice.txt','w') as f:
f.write('\n'.join(''.join(row) for row in grid) + '\n')
print(open('mazes/weighted_choice.txt').read())