add dice algorithm