Dr. Stuart Walker suggests two great rules of thumb when sailing upwind (or downwind) in an oscillating breeze. The first is that when you become able to tack and cross ahead of other boats, you should do so. If you don’t consolidate your gain in a favorable windshift, you will lose when the wind shifts back the other way. In the diagram, Boat B gets headed (position 2) and that puts her ahead of Boat A, so she tacks (position 3) to cross ahead of A.
A corollary to this principle is, “Don’t let other boats cross you.” When A sees B tack and realizes that B will cross ahead of her, A tacks to leeward and ahead of B (position 4). This way A will beat B to the next shift. You almost never want to cross behind a boat that is sailing on a lift in an oscilating breeze.