# HG changeset patch # User Brian Neal # Date 1371694005 18000 # Node ID 922b7a6ff65eb1570323feef0f77ec37d47e9591 # Parent 4db95b820ae217db9bbbe834398d2f691cb5ebb9 Started work on generating lug settings using manual data. Much work to do here. diff -r 4db95b820ae2 -r 922b7a6ff65e m209/keylist/generate.py --- a/m209/keylist/generate.py Wed Jun 19 20:45:13 2013 -0500 +++ b/m209/keylist/generate.py Wed Jun 19 21:06:45 2013 -0500 @@ -12,6 +12,7 @@ from ..converter import M209 from .. import M209Error from ..data import KEY_WHEEL_DATA +from .data import GROUP_A, GROUP_B # Maximum number of attempts to generate valid settings before giving up and @@ -69,6 +70,39 @@ def generate_lugs(): """Return random lug settings based on Army procedure.""" + + # From the manual: + # "2a: Select a set of numbers from either group A or group B in appenix II. + # Sets of numbers selected from group B must not exceed 10% of the total + # sets selected." + + # For our purposes, we'll just pick from group B 10% of the time. We also + # (currently) have no history of prior key list generations, so we don't + # worry about reusing sets or how often we've picked from group B. + rn = random.randint(0, 100) + group = GROUP_A if rn > 10 else GROUP_B + selection = random.choice(group) + + # 2b: Rearrange the numbers so they appear in a random order + random.shuffle(selection) + + # 2c: Distribution of Overlaps + overlap = sum(selection) - 27 + + # TODO: + # (1) Most of the six number should be involved + # (2) Overlaps should include numbers which are separated, and numbers which + # are side by side. + # (3) Several small overlaps should be used in preference to one large + # overlap + # (4) There must not be more than four overlaps between any two numbers. + + # 2d: Checking placement of overlaps + # TODO + + # Build lug string + # TODO + return ''