For a dedicated server, the solution is quite simple. Test for value b < value a and the calculate as appropriate. Of course this has already been stated and known .

PS: The longest I've seen anyone ever play a game was 27 days before he fell asleep at the keyboard. Poor fool only had to play 3 more days to win the bet.