Thanks for improving my algorithm... It looks like that Treasure Map is an improvement to pure Masterpiece. You're right about rushing Duchies more aggressively. The reason I didn't by TM on turn 7 or 8 is that you want to connect them in your shuffle of turns 7-9, and I thought that if you failed to connect them then, you'd be doomed anyway, so I'm actually surprised that buying TM more aggressively gives such a significant improvement.
You can specify what to discard for e.g. warehouse using
discardPriority: (state, my) -> [ *list of stuff* ]
(for more documentation, see
here)