basic algorithm setup up except for the method for calculating next state