A guitar is a non-linear instrument. That is to say, across the board there is no consistent flow of notes. The guitar works on a 4th tuning principle, which means that the standard tuning EADGBE is followed on the principle that every other string is tuned to the 4th interval of the string below it. For instance, A is the 4th of E, D is the 4th of A and so on.
Hence thinking of a guitar as 6 different pianos stacked up together with different starting points might help you figure out how to improvise on a guitar. Every other principle works the same, just the non linearity is the only concern. remembering that a step down a string will have you move 4 intervals makes it easier to remember where you are in a scale, hence making it easier to improvise.