Ship algorithm