I spent the whole evening debugging the LOS algorithm. The problem was that the last (unpassable) tile was not drawn. The unit can’t see behind a wall, but still, he is able to see the actual wall blocking the way, and that part didn’t work as supposed. Well I’m glad that this is now fixed.
I must admit that hidden tiles around the unit boosts the game atmosphere significantly. This is also the principle how fog of war works in games.
