Loading sampling.py +16 −0 Original line number Diff line number Diff line """This module provides various (currently only one) strategies to draw pairs for the secret-Knecht-Robobert game.""" import random class Sampler(): """Parent class for all samplers implemented. Each sampler should be initialized for a set of elements to draw from, and should implement a method to sample a full set of pairs. """ def __init__(self, elements): self.elements = elements Loading @@ -8,6 +16,14 @@ class Sampler(): raise NotImplementedError() class HamiltonSampler(Sampler): """Probably the easiest solution is to implement generating a Hamiltonian path, which visits every node of a graph exactly once. This implementation works by shuffling the list of elements, and then letting the first person make a gift for the second person, the second for the third, ..., and the last person for the first one. https://en.wikipedia.org/wiki/Hamiltonian_path """ def sample_pairs(self): pairs = [] e = self.elements[:] Loading Loading
sampling.py +16 −0 Original line number Diff line number Diff line """This module provides various (currently only one) strategies to draw pairs for the secret-Knecht-Robobert game.""" import random class Sampler(): """Parent class for all samplers implemented. Each sampler should be initialized for a set of elements to draw from, and should implement a method to sample a full set of pairs. """ def __init__(self, elements): self.elements = elements Loading @@ -8,6 +16,14 @@ class Sampler(): raise NotImplementedError() class HamiltonSampler(Sampler): """Probably the easiest solution is to implement generating a Hamiltonian path, which visits every node of a graph exactly once. This implementation works by shuffling the list of elements, and then letting the first person make a gift for the second person, the second for the third, ..., and the last person for the first one. https://en.wikipedia.org/wiki/Hamiltonian_path """ def sample_pairs(self): pairs = [] e = self.elements[:] Loading