Implementation of the shelling model in scala