From b6dca5a6ab31476b060bb081cbabeb9dc85023bf Mon Sep 17 00:00:00 2001 From: kartofen Date: Wed, 24 Aug 2022 21:45:43 +0300 Subject: fix div by 0 --- src/markov.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/markov.h b/src/markov.h index 2fdaf16..2cb22ce 100644 --- a/src/markov.h +++ b/src/markov.h @@ -69,6 +69,8 @@ void generate_chain(char *file_path) for(int j = 0; j < ITEMS; j++) all += items_seen[i][j]; + if(all == 0) continue; + for(int j = 0; j < ITEMS; j++) chain[i][j] = (double)items_seen[i][j]/all; } -- cgit v1.2.3