When attacking with a cannon a unit must be next to an enemy unit. Next to is defined as being any of the 8 squares that surround a unit, up, down, left, right or diagonally.