Optimized defending and attacking