Puzzle
There are some mirrors located throughout a grid. A ray of light enters the grid from some position. It travels through the grid in a straight line trying to escape. On encountering with a mirror it changes its course by 90 degrees. This continues to happen until it breaks free from the maze. The challenge is simply this: Guide the light ray to an exit.
Elements
Grid - The grid is a square composed of n x n blocks. A block is either empty or contains a mirror.
Mirror - Both faces of the mirror are reflective. They have two orientations - 45o left or right(see figure).
Light ray - It always travels straight and reflects from the mirror surface upon incidence (i=r=45o).
Code
Input - The user will input 3 values - n, m and s.
n represents the value of grid's length (no of blocks). You are free to choose the type of this value; It could be a string, integer, float or any other data type. This cannot be zero/empty.
m is a sequence of two values indicating where the mirrors are and what their orientations will be. You are free to choose the sequence type. For example, if 0 and 1 are the two orientations of the mirror and each block in the grid is marked from 1 to n2, you may input a sequence such as {(5,0), (3,1), (6,0),...}. Since you're free to choose this type, you may even squeeze them in to a string and decode it properly. In other words, it only needs to be legible to your code. This can be zero for no mirrors.
s represents the starting position of the light ray. Again, you may choose this type based on the rest of your code. Any form of data is valid.
NOTE The user is responsible for inputing the correct values. If they enter an invalid value such as placing a mirror out of the grid or not providing a starting position, your code doesn't have to deal with it.
Process - Calculate the position from which the light ray will emerge out of the grid. You are free to mark your grid (or not) in any way you like. The same goes with start and exit positions. Include these details in your answer below. How you represent these data will influence the output. See scoring rubrics for details.
Output - Display the emerging position of the light ray. Detailed output can score more. See scoring rubrics for details.
You are free to use any libraries or extensions to implement any part of the maze, but not the entire maze. The only restriction here is this: if the library is for GUI, or implementing the Grid or anything like that it's fine. If it already contain a preset grid with mirrors (highly unlikely), you can't use it.
Scoring
- +64 for keeping your code less than 10 kilobytes (10240 bytes).
- -2 for every byte after the 10240th byte
- +16 for including the path of the ray in the output. Any representation is OK, but explain it in the answer. You may mark your grid with numbers, alphabets or in any other way you like.
- +64 for drawing the grid with the solution (see figure). It could be a GUI or CLI! The drawing must at least include the grid and the ray of light from start to exit. Numbers, markings and everything else are optional. If you do this, you shouldn't add the +16 points above.
- +128 for inventing partially reflective mirrors. These mirrors will guide the light in to two locations. One that is perpendicular to the original ray and one that passes straight through them. You may of course combine multiple mirrors like these with the normal ones for added effect. There may be 2 exit rays for this type of mirrors which you must display in your solution. If you choose to do this, change the user input m to suit the code accordingly (it must be a sequence of 3 elements rather than 2, the third value being the type of mirror). See figure below.
- +128 for inventing the absorber mirror. Absorber mirror absorbs the light ray and stops it from exiting the grid. The solution to this case should be something like 'LIGHT RAY ABSORBED!' (you can show anything as long you explain it in the answer below.) Everything else is same as the partially reflective mirror shown above.
- +128 for inventing the laser mirror. A laser mirror's reflection will destroy any other mirror that is in it's way. So, if the light strikes a laser mirror(m1) and then falls on another mirror (m2), it (m2) will be destroyed. The ray now travels straight as if that block is empty. Everything else is same as the partially reflective mirror shown above.
- +128 for inventing a new kind of mirror and explaining its action. Make it really cool. ;)
TIE BREAKER: In case of a tie, the shortest code shall win. If by some strange coincidence, that happens to be the same, the winner shall be decided based on how many numbers there are in the code (every single digit of integers, floats and even numbers in variables) - the least one wins!
Example
The first one is a typical solution with a GUI output. It marks the positions as integers from 1 to 12 and shows the path of the ray along with 2 mirrors. The second one shows the partially reflective mirror (bonus points) that has 2 exit rays. The third example is a CLI output model (this one is tough!). It shows the same thing as our GUI. The normal output without any diagrams (no bonus) could be as short as a single number or any value (eg: 7 or G) indicating from where the ray has emerged. The way you chose to name the positions must be included in your answer.
^
__:___ ______ ______ ______ ______
| : | | | | |
<...|..\\..|.<....|..\ | | |
|______|______|__:__ |______|______|
| | | : | | |
| | | ^ | | |
|______|______|__:___|______|______|
| | | : | | |
....|..>...|......|../ | | |
|______|______|______|______|______|
| | | | | |
| | | | | |
|______|______|______|______|______|
/ = normal mirror
// = partially reflecting mirror