|
|
|
|
|
|
|
|
def refineDungeon(d_map, d_lmt=None, a_lmt=None): |
|
|
def refineDungeon(d_map, d_lmt=None, a_lmt=None): |
|
|
""" Refines the grid. |
|
|
""" Refines the grid. |
|
|
""" |
|
|
""" |
|
|
d_lmt = 3 if d_lmt == None else int(d_lmt) |
|
|
|
|
|
|
|
|
d_lmt = 4 if d_lmt == None else int(d_lmt) |
|
|
a_lmt = 4 if a_lmt == None else int(a_lmt) |
|
|
a_lmt = 4 if a_lmt == None else int(a_lmt) |
|
|
new_map = [] |
|
|
new_map = [] |
|
|
for j in range(len(d_map)): |
|
|
for j in range(len(d_map)): |
|
|
|
|
|
|
|
|
x, y = i, j |
|
|
x, y = i, j |
|
|
n_count = countAliveNeighbors(d_map, x, y) |
|
|
n_count = countAliveNeighbors(d_map, x, y) |
|
|
if d_map[y][x]: |
|
|
if d_map[y][x]: |
|
|
if n_count <= d_lmt: |
|
|
|
|
|
|
|
|
if n_count >= a_lmt: |
|
|
new_line.append(False) |
|
|
new_line.append(False) |
|
|
else: |
|
|
else: |
|
|
new_line.append(True) |
|
|
new_line.append(True) |
|
|
else: |
|
|
else: |
|
|
if n_count >= a_lmt: |
|
|
|
|
|
|
|
|
if n_count <= d_lmt: |
|
|
new_line.append(True) |
|
|
new_line.append(True) |
|
|
else: |
|
|
else: |
|
|
new_line.append(False) |
|
|
new_line.append(False) |