Of course, you right on that, it can have some elaborated program logic behind it. (when release private blockchain, when to drop it and follow the main chain, ect.)
But I think
RoeiDimi can first implement something simple. Something like:
if (privateChainLen > 4)
releasePrivateChain();
else (nBlocksBehindOfMainChain > 2)
dropPrivateChain();
Agreed, some refinements could be made. Selfish mining works the best if you can at least compete with others when they are at the same block height as you. When you're in this attack, you should be connected to the peers which are the major mining pools. If any of them relay a block, you would also broadcast your own block. As such, there is still a chance for the network to build on your chain.