You'll need to plan this out on paper first, that would be the best way to do it. You could then figure out all of the variables you will need to use and what kind of logic to go with it. ...