From d5647a0328400801aa997ce977fa324c8417def0 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Fri, 9 Feb 2024 00:30:19 -0800 Subject: [PATCH] fix mass and off-by-one errors --- vacation.p8 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vacation.p8 b/vacation.p8 index bf1a135..1f4ba77 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -417,8 +417,8 @@ mknew(fuzzy, function(x) local p = (x.p or fuzzy.p) & 0xffff x.mass = 0 while p ~= 0 do - x.mass += p & 0x8000 - p = p << 1 + x.mass += p & 1 + p = (p >>> 1) & 0xffff end end) @@ -427,7 +427,7 @@ function fuzzy:update() if (self.n < self.interval) return self.n = 0 for i=1,self.tries do - local b = 1 << rnd(15) + local b = 1 << rnd(16) if b & self.p == 0 then if i == self.tries or not self.weight or self.mass <= self.weight then self.mass += 1