A boat on Port tack (where the wind is coming from the left and the boom is on the right) gives way to a boat on starboard tack (wind from the right and boom on the left), ie. Starboard has right of way.
A boat on Starboard tack with right of way may shout ”Starboard” if you are on Port tack and they think you are about to get in their way and collide.
A boat to windward (closest to where the wind is coming from) gives way to a boat to leeward (the boat further away from the wind).
At a mark, the boat on the inside, nearest the mark, will usually need to be given room to round the mark without hitting it or you! This is where you can call “Water at the mark!”
The aim of these basic rules is to prevent collisions.