Light up a Roguelike Given a board, write the shortest program or function to display or return which characters are in sight of the player. A character is in sight if is possible to draw a line between it and the player, without crossing any characters that block vision.

Input:


@ represents the player's position. There will only be one of these in the input.
any character that matches the regex [#A-Z] blocks vision.
any character that matches [ a-z] allows vision.
there will be no invalid characters
you are guaranteed a rectangular input


Lines are defined as follows:


define vector to be a magnitude and a direction
a direction is one of N,NE,E,SE,S,SW,W,NW
a magnitude is how many chars along that direction to count
let the initial vector be called d1; the second vector be called d2
one of d1 or d2 must have a magnitude of 1; the other may have whatever magnitude
d1's direction must be adjacent to d2's direction (e.g: N and NE)


A line is defined to be all chars along the path marked by applying d1, then d2, d1, d2 ....

Sample line (given by the .s):
d1 = (magnitude: 4, direction: E)
d2 = (magnitude: 1, direction NE)

               .....
          .....
     .....
@.... 


Output:


each visible character in the right position, . substitutes for space.
Space for each non-visible character.


Sample input:

@         
    K     
 J        

    L   




         o


Corresponding output:

@.........
....K.....
.J.....   
..........
.. .L.....
..  . ....
... .. ...
...  .. ..
...   .  .
....  ..  


Sample Input:

 B###M#  by 
 #Q   # Zmpq
 # # aaa    
@  m #      
# ##P#      
# ####      
# ####      
#M ###      
######      


Corresponding Output:

.B  #M      
.# ..   Z pq
.#.#.aaa..  
@..m.#      
#.##P#      
 .#         
 .#         
 M.         
  #         


Sample input:

  w                 

     O  l   gg  rT  
   QQL      Ag  #b  
   qqqqq         XqQ
 x     V# f@aa      
   Y        aaa     
   uU  E  l TaKK    
  e  dd  FF d opi   
   e       d        


Corresponding output:

   ..........  .....
    ......... ..... 
     O..l...gg..rT  
...QQL......Ag..#b..
...qqqqq.........XqQ
        #.f@aa......
   Y........aaa.....
...uU..E..l.TaKK....
      d..FF.d.op    
     .... .d. ...
GolfScript, 171 characters
.n?):L)[n*.]*1/:I'@'?{\+[{1$+}*]..{I=26,{65+}%&quot;#
&quot;+\?)}??)&lt;}+{[L~.).)1L)L.(-1L~]&gt;2&lt;`{[.[~\]]{1/~2$*+L*.-1%}%\;~}+L,%~}8,%%{|}*`{1$?)I@=.n=@|\.' '={;'.'}*' 'if}+I,,%''*n%n*

The input must be provided on STDIN.
The output for the examples given above is slightly different. I verified the responses by hand and think they are correct.
Example 1:
@.........
....K.....
.J.....   
..........
.. .L.....
..  . ....
... .. ...
...  .. ..
...   .  .
....  ..  

Example 2:
.B  #M      
.# ..   Z pq
.#.#.aaa..  
@..m.#      
#.##P#      
 .#         
 .#         
 M.         
  #         

Example 3:
   ..........  .....
    ......... ..... 
     O..l...gg..rT  
...QQL......Ag..#b..
...qqqqq.........XqQ
        #.f@aa......
   Y........aaa.....
...uU..E..l.TaKK....
      d..FF.d.op    
     .... .d. ...