From: Siraaj Khandkar Date: Thu, 9 Aug 2012 18:26:39 +0000 (-0400) Subject: Ensuring sleep value is at least zero. X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=1e19baedcbab645fb8a91785f9cf0fdb2fa42065;p=cellular-automata.git Ensuring sleep value is at least zero. --- diff --git a/003/src/life.erl b/003/src/life.erl index f4b1fe5..605fa95 100644 --- a/003/src/life.erl +++ b/003/src/life.erl @@ -74,12 +74,16 @@ life_loop( }, NewTimeMil = NewTime / 1000, - NextGenDelay = round(?GEN_INTERVAL - NewTimeMil), + NextGenDelay = at_least_zero(round(?GEN_INTERVAL - NewTimeMil)), timer:sleep(NextGenDelay), life_loop(NewState). +at_least_zero(Integer) when Integer >= 0 -> Integer; +at_least_zero(_) -> 0. + + do_print_screen(Board, Bar, X, Y, N, GenCount, Time, PrintTime) -> ok = do_print_status(Bar, X, Y, N, GenCount, Time, PrintTime), ok = do_print_board(Board).