Even if I have a more favourable trade with the bank, can I still do a 4:1 trade to get rid more excess resources (e.g. to avoid the robber)?
Based on my read of the rules, specifically the section in the Almanac on Maritime Trade, I don't see any reason why you couldn't trade at the 4:1 rate even when you have a better rate available. I even see this text:
Generic Harbor (3:1): Here you may exchange 3 identical resource cards for 1 other resource card during your trade phase.
The use of the word "may" makes me think it's optional. If they wanted you to only be able to trade 3:1 after getting a port, they probably would have used stronger language.
I agree with Ben's assessment that you could, but I am pretty sure you don't want to.
Anecdotally, I've played a lot of Settlers and never even considered this move (20 years and something new!). Compress to avoid the robber, yes. Compress at a worse than optimal ratio to avoid the robber, no.
The probability of the robber happening before your next opportunity to spend your resources is:
- 1-(30/36)^3 = 42% (3 player)
- 1-(30/36)^4 = 52% (4 player)
- 1-(30/36)^5 = 60% (5 player)
- 1-(30/36)^6 = 67% (6 player)
But that's not the whole story.
You'll be drawing more resources depending on the dice rolls.
You'll be trading with other people, sometimes card for card but sometimes effectively compressing or expanding.
In 5 & 6 player games you have the intra-turn exact-spend opportunity which you might be able to take advantage of.
With all of that it's very murky whether compressing less than optimally (instead of compressing optimally) delivers more benefit (sometimes avoiding the robber) than cost (compressing away extra cards).
Edit: Intra, not inter. No english points for me today.