diff safe.py @ 26:5488b5d3ba10

use indentation and colour to differentiate safe from unsafe landing place
author Henry Thompson <ht@markup.co.uk>
date Mon, 31 May 2021 15:01:38 +0100
parents 6df2f6dcc809
children 668d788cac47
line wrap: on
line diff
--- a/safe.py	Sat May 29 21:32:41 2021 +0100
+++ b/safe.py	Mon May 31 15:01:38 2021 +0100
@@ -119,7 +119,22 @@
         done[k[0]]=1
         aa,ll=hits[k]
         laa=sorted(list(aa))
-        print("(%s %s %s)@%0.1f: %s %s"%(k[0][0],laa[0][0],k[0][1],k[1],laa,sorted(list(ll))))
+        lll=sorted(list(ll))
+        lowAir=laa[0][0]
+        highLava=-1
+        j=-1
+        for i,(_,h) in enumerate(lll):
+          if h>highLava and h<lowAir:
+            highLava=h
+            if h+1==lowAir:
+              j=i
+              break
+        if j>-1:
+          lava='['+','.join(str(e) if i!=j else \
+                            "(%s,%s)"%(e[0],RedFmt%e[1]) for i,e in enumerate(lll))+']'
+          lowAir=RedFmt%lowAir
+        print("%s(%s %s %s)@%0.1f: %s %s"%(' ' if j>-1 else '',
+                                           k[0][0],lowAir,k[0][1],k[1],laa,lava))
   else:
     print(' No nearby landing zones')