Interactions between lasers, targets and sources are prettier.
This commit is contained in:
@@ -160,13 +160,16 @@ def generate_lasers(playfield):
|
||||
sources = ((pos, obj.direction) for pos, obj
|
||||
in filter(lambda posobj: isinstance(posobj[1], Source),
|
||||
playfield.items()))
|
||||
lasers = []
|
||||
lasers, lasers_flat = [], set()
|
||||
def add(start, end):
|
||||
t = (min(start, end), max(start, end))
|
||||
if not t in lasers:
|
||||
lasers.append(t)
|
||||
if not t in lasers_flat:
|
||||
laser.append(t)
|
||||
lasers_flat.add(t)
|
||||
for start, direc in sources:
|
||||
end = start
|
||||
laser = []
|
||||
lasers.append(laser)
|
||||
while True:
|
||||
cur = playfield.get(end)
|
||||
if cur is Target:
|
||||
@@ -176,7 +179,7 @@ def generate_lasers(playfield):
|
||||
add(start, end)
|
||||
break
|
||||
if cur in (MirrorLeft, MirrorRight):
|
||||
if (start, end) in ((start, end) for (start, end), direc in lasers):
|
||||
if (start, end) in ((start, end) for (start, end), direc in lasers_flat):
|
||||
break
|
||||
add(start, end)
|
||||
direc = _mirror_new_direc(cur, direc)
|
||||
|
||||
Reference in New Issue
Block a user