From e510f7cc5e6fa942ffec07780058a383410165b3 Mon Sep 17 00:00:00 2001 From: Felix Bauckholt Date: Sun, 3 Mar 2019 22:50:20 +0100 Subject: [PATCH] Switch around ordering of question combining This has the advantage that for some ModulusInformation object m and some modulus, ``` a = m.split(modulus); m.cast_down(x); ``` is equivalent to ``` m.cast_down(x*modulus); a = m.split(modulus); ``` This means that when using a ModulusInformation object to answer questions, we can answer the first question without needing to know how many questions there are. --- README.md | 4 ++-- src/strategies/information.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c1e8a05..e47e9fc 100644 --- a/README.md +++ b/README.md @@ -73,5 +73,5 @@ On the first 20000 seeds, we have these average scores and win rates: |---------|---------|---------|---------|---------| | cheat | 24.8594 | 24.9785 | 24.9720 | 24.9557 | | | 90.59 % | 98.17 % | 97.76 % | 96.42 % | -| info | 22.3249 | 24.7278 | 24.8919 | 24.8961 | -| | 09.81 % | 80.54 % | 91.67 % | 91.90 % | +| info | 22.3316 | 24.7246 | 24.8892 | 24.8969 | +| | 09.81 % | 80.38 % | 91.45 % | 91.94 % | diff --git a/src/strategies/information.rs b/src/strategies/information.rs index 0d6ed70..49cf466 100644 --- a/src/strategies/information.rs +++ b/src/strategies/information.rs @@ -29,7 +29,7 @@ impl ModulusInformation { } pub fn combine(&mut self, other: Self) { - self.value = self.value * other.modulus + other.value; + self.value = self.value + self.modulus * other.value; self.modulus = self.modulus * other.modulus; } @@ -39,10 +39,10 @@ impl ModulusInformation { let original_modulus = self.modulus; let original_value = self.value; self.modulus = self.modulus / modulus; - let value = self.value / self.modulus; - self.value = self.value - value * self.modulus; + let value = self.value % modulus; + self.value = self.value / modulus; assert!(original_modulus == modulus * self.modulus); - assert!(original_value == value * self.modulus + self.value); + assert!(original_value == value + modulus * self.value); Self::new(modulus, value) }