if width_line != width_map:
raise ArgError('map line width %s unequal map width %s' % (width_line, width_map))
self.terrain = self.terrain[:y * width_map] + line +\
- self.terrain[(y + 1) * width_map:]
+ self.terrain[(y + 1) * width_map:]
def get_position_index(self, yx):
return yx.y * self.geometry.size.x + yx.x
def __init__(self, source_maps, source_center, radius, get_map):
self.source_maps = source_maps
self.radius = radius
- example_map = get_map(YX(0,0))
+ example_map = get_map(YX(0, 0))
self.source_geometry = example_map.geometry
size, self.offset, self.center = \
self.source_geometry.define_segment(source_center, radius)
if self.terrain[j] < self.terrain[i] - 1:
self.terrain[i] = self.terrain[j] + 1
shrunk = True
- #print('DEBUG Dijkstra')
- #line_to_print = []
- #x = 0
- #for n in self.terrain:
- # line_to_print += ['%3s' % n]
- # x += 1
- # if x >= self.size.x:
- # x = 0
- # print(' '.join(line_to_print))
- # line_to_print = []
+ # print('DEBUG Dijkstra')
+ # line_to_print = []
+ # x = 0
+ # for n in self.terrain:
+ # line_to_print += ['%3s' % n]
+ # x += 1
+ # if x >= self.size.x:
+ # x = 0
+ # print(' '.join(line_to_print))
+ # line_to_print = []
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
- self.terrain = '?' * self.size_i #self.size.y * self.size.x
+ self.terrain = '?' * self.size_i
self[self.center] = '.'
self.shadow_cones = []
self.circle_out(self.center, self.shadow_process)
def in_shadow_cone(new_cone):
for old_cone in self.shadow_cones:
if old_cone[0] <= new_cone[0] and \
- new_cone[1] <= old_cone[1]:
+ new_cone[1] <= old_cone[1]:
return True
# We might want to also shade tiles whose middle arm is inside a
# shadow cone for a darker FOV. Note that we then could not for
if unmerged:
self.shadow_cones += [cone]
- step_size = (CIRCLE/len(self.circle_out_directions)) / distance_to_center
+ step_size = (CIRCLE / len(self.circle_out_directions)) / distance_to_center
number_steps = dir_i * distance_to_center + dir_progress
- left_arm = correct_arm(step_size/2 + step_size*number_steps)
+ left_arm = correct_arm(step_size / 2 + step_size * number_steps)
right_arm = correct_arm(left_arm + step_size)
# Optimization potential: left cone could be derived from previous
# and skip evaluation of already shaded tile. (This only works if tiles
# shading implies they completely lie in existing shades; otherwise we
# would lose shade growth through tiles at shade borders.)
- circle_in_map = True
distance = 1
yx = YX(yx.y, yx.x)
while distance <= self.radius: