Better for of war algorithm