Ejemplo n.º 1
0
    private IEnumerator ShowRuleSeed()
    {
        yield return(null);

        yield return(null);

        NumberText.text = RuleSeed.GetRNG().Seed.ToString();
        Debug.Log(string.Format("[Rule Seed Modifier] The Seed is {0}", NumberText.text));
    }
Ejemplo n.º 2
0
    void Start()
    {
        moduleId = moduleIdCounter++;

        for (var i = 0; i < Buttons.Length; i++)
        {
            Buttons[i].OnInteract += ButtonPressed(i);
        }

        Initiate.OnInteract += delegate
        {
            if (moduleSolved || resetActive)
            {
                return(false);
            }
            StartCoroutine(Input());
            return(false);
        };
        var rnd = KMRuleSeedable.GetRNG();

        if (rnd.Seed != 1)
        {
            rnd.ShuffleFisherYates(Receptacles);
            rnd.ShuffleFisherYates(devices);
        }
        StartCoroutine(Reset());
    }
Ejemplo n.º 3
0
    void Start()
    {
        var rnd  = Ruleseed.GetRNG();
        int seed = rnd.Seed;

        kum = seed == 1 ? new int[3] {
            6, 9, 20
        } : new int[3] {
            rnd.Next(4, 8), rnd.Next(8, 15), rnd.Next(14, 24)
        };
        Debug.LogFormat("[Chicken Nuggets #{0}] Ruleseed {1}: The nuggets counts are {2}, {3}, and {4}.", moduleId, seed, kum[0], kum[1], kum[2]);
        if (!_chickenNuggetsInfos.ContainsKey(seed))
        {
            _chickenNuggetsInfos[seed] = new ChickenNuggetsInfos();
        }
        _chickenNuggetsInfo = _chickenNuggetsInfos[seed];
        if (_chickenNuggetsInfo.First)
        {
            for (int i = 0; i < 201; i++)
            {
                SearchAllSolutions(i);
            }
        }
        _chickenNuggetsInfo.First = false;
        StartCoroutine(GenerateMcNumeros());
        COMMIE = UnityEngine.Random.Range(0, 101);
        if (COMMIE == 69)
        {
            Commie.GetComponent <MeshRenderer>().material = McDonalds[1];
        }
    }
Ejemplo n.º 4
0
    void Start()
    {
        StartCoroutine(animateButton(slot1Transform, true));

        // Rule seed!
        var rnd = RuleSeedable.GetRNG();
        if (rnd.Seed == 1)
        {
            _drinktionary = _seed1_drinktionary;
            _customerPreferences = _seed1_customerPreferences;
            _ingredientValues = _seed1_ingredientValues;
            _chaser = _seed1_chaser;
            _big = _seed1_big;
        }
        else
        {
            _drinktionary = new Recipe[12];
            var nonBottledDrinks = rnd.ShuffleFisherYates(Drink.AllDrinks.Where(d => !d.Bottled).ToList());
            for (var dr = 0; dr < _drinktionary.Length; dr++)
            {
                var ingredients = new int[5];
                var iter = 0;
                do
                {
                    iter++;
                    for (var ing = 0; ing < 5; ing++)
                        // Cube the random number to allow lower numbers to occur more frequently and high numbers less frequently
                        ingredients[ing] = (int) (10 * Math.Pow(rnd.NextDouble(), 3));
                    if (iter > 1000)
                    {
                        Debug.LogFormat(@"<Bartending #{0}> iteration fail", _moduleId);
                        return;
                    }
                }
                while (_drinktionary.Take(dr).Any(d => d.Ingredients.SequenceEqual(ingredients)));

                _drinktionary[dr] = new Recipe { Drink = nonBottledDrinks[dr], Ingredients = ingredients, Aged = rnd.Next(0, 2) != 0, Iced = rnd.Next(0, 2) != 0, State = rnd.Next(0, 2) != 0 ? DrinkState.Blended : DrinkState.Mixed };
                Debug.LogFormat(@"<Bartending #{0}> Drinktionary entry {1}: {2} [{3}] Aged={4}, Iced={5}, {6}", _moduleId, dr + 1, _drinktionary[dr].Drink.Name,
                    _drinktionary[dr].Ingredients.Join(", "), _drinktionary[dr].Aged, _drinktionary[dr].Iced, _drinktionary[dr].State);
            }

            var allDrinks = nonBottledDrinks.Take(_drinktionary.Length).Concat(Drink.AllDrinks.Where(d => d.Bottled)).ToList();
            _customerPreferences = new Drink[_patronNames.Length][];
            for (var c = 0; c < _patronNames.Length; c++)
            {
                rnd.ShuffleFisherYates(allDrinks);
                _customerPreferences[c] = allDrinks.Take(6).ToArray();
                Debug.LogFormat(@"<Bartending #{0}> Customer {1} preferences: {2}", _moduleId, _patronNames[c], _customerPreferences[c].Select(d => d.Name).Join(", "));
            }
            _ingredientValues = rnd.ShuffleFisherYates(new[] { 1, 2, 3, 4, 5 });
            Debug.LogFormat(@"<Bartending #{0}> Ingredient values = [{1}]", _moduleId, _ingredientValues.Join(", "));
            var chars = rnd.ShuffleFisherYates("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()).Join("");
            _chaser = chars.Substring(0, 6);
            _big = chars.Substring(6, 3);
            Debug.LogFormat(@"<Bartending #{0}> Chaser = {1}, Big = {2}", _moduleId, _chaser, _big);
        }

        GenerateModule();
        closeMenu();
    }
Ejemplo n.º 5
0
    void Start()
    {
        rnd = RuleSeed.GetRNG();

        var ixs = Enumerable.Range(0, allConditions.Count).ToList();

        rnd.ShuffleFisherYates(ixs);

        for (int i = 0; i < 4; i++)
        {
            leftSwitch.Add(new Switch {
                Explanation = allConditions[ixs.First()].Explanation, Cond = allConditions[ixs.First()].Cond, SwitchValue = rnd.Next(1, 5)
            });
            ixs.RemoveAt(0);
            rightSwitch.Add(new Switch {
                Explanation = allConditions[ixs.First()].Explanation, Cond = allConditions[ixs.First()].Cond, SwitchValue = rnd.Next(1, 5)
            });
            ixs.RemoveAt(0);
        }

        leftSwitch.Add(new Switch {
            Explanation = "Otherwise", Cond = button => true, SwitchValue = rnd.Next(1, 5)
        });
        rightSwitch.Add(new Switch {
            Explanation = "Otherwise", Cond = button => true, SwitchValue = rnd.Next(1, 5)
        });

        MixButtons();
        StartCoroutine(Game());
    }
Ejemplo n.º 6
0
    void Start()
    {
        startingTime        = BombInfo.GetTime();
        startingModuleCount = BombInfo.GetSolvableModuleNames().Count;

        var ruleSeedRnd = RuleSeedModifier.GetRNG();
        var generator   = new FizzBuzzRuleGenerator(ruleSeedRnd, this);

        table             = generator.GenerateOffsetTable();
        ruleSet           = generator.GenerateRuleSet();
        divisibilityRules = generator.GenerateDivisibilityRules();

        moduleId = moduleIdCounter++;

        GetComponent <KMBombModule>().OnActivate += OnActivate;

        for (int i = 0; i < 3; i++)
        {
            var j = i;
            SelectionButtons[i].OnInteract += delegate { HandlePress(j); return(false); };
            Nums[i]        = GenNum();
            Labels[i].text = "";

            int color = Rnd.Range(0, 5);
            Colors[i]       = color;
            Labels[i].color = ColorMats[color];
        }

        SubmitButton.OnInteract += delegate { Submit(); return(false); };
    }
Ejemplo n.º 7
0
    void SetUpRuleseed()
    {
        var rnd = ruleseed.GetRNG();

        rnd.ShuffleFisherYates(phraseValues);
        rnd.ShuffleFisherYates(surroundingValues);
    }
    void Start()
    {
        var rnd  = Ruleseed.GetRNG();
        int seed = rnd.Seed;

        NuggetValues = seed == 1 ? new int[3] {
            6, 9, 20
        } : new int[3] {
            rnd.Next(4, 8), rnd.Next(8, 15), rnd.Next(14, 24)
        };
        Debug.LogFormat("[Chicken Nuggets #{0}] Ruleseed {1}: The nuggets counts are {2}, {3}, and {4}.", moduleId, seed, NuggetValues[0], NuggetValues[1], NuggetValues[2]);
        if (!_chickenNuggetsInfos.ContainsKey(seed))
        {
            _chickenNuggetsInfos[seed] = new ChickenNuggetsInfos();
        }
        _chickenNuggetsInfo = _chickenNuggetsInfos[seed];
        if (_chickenNuggetsInfo.First)
        {
            for (int i = 0; i < 201; i++)
            {
                SearchAllSolutions(i);
            }
        }
        _chickenNuggetsInfo.First = false;
        StartCoroutine(GenerateAnswer());
        CommunismEasterEgg = UnityEngine.Random.Range(0, 101);
        if (CommunismEasterEgg == 69)
        {
            BackgroundGO.GetComponent <MeshRenderer>().material = Backgrounds[1];
        }
    }
    private void GenerateRules()
    {
        MonoRandom rnd = RuleSeedable.GetRNG();

        Debug.LogFormat(@"[VaricoloredSquares #{0}] Rule Generator: generating rules according to rule seed {1}", _moduleId, rnd.Seed);

        // Add more random spread
        for (int i = 0; i < 13; i++)
        {
            rnd.Next();
        }

        // Generate color pentagons
        _table = new SquareColor[5][];
        for (int i = 0; i < 5; i++)
        {
            _colorCandidates.Shuffle(rnd);
            _table[i] = _colorCandidates.ToArray();
            Debug.LogFormat(@"[VaricoloredSquares #{0}] Rule Generator: {1} pentagon is: {2}", _moduleId, (SquareColor)i, string.Join("-", _table[i].Select(c => "RBGYM"[(int)c].ToString()).ToArray()));
        }

        // Random spread
        rnd.Next();
        rnd.Next();
        rnd.Next();

        // Generate directions
        _ruleOneDirection = (rnd.Next(2) * 2) - 1;
        _backupDirection  = (rnd.Next(2) * 2) - 1;
        Debug.LogFormat(@"[VaricoloredSquares #{0}] Rule Generator: rule one direction is: {1}", _moduleId, _ruleOneDirection == -1 ? "counter-clockwise" : "clockwise");
        Debug.LogFormat(@"[VaricoloredSquares #{0}] Rule Generator: backup rule direction is: {1}", _moduleId, _backupDirection == -1 ? "counter-clockwise" : "clockwise");
    }
Ejemplo n.º 10
0
    void Start()
    {
        _moduleId   = _moduleIdCounter++;
        _colorblind = ColorblindMode.ColorblindModeActive;

        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat("[Uncolored Squares #{0}] Using rule seed: {1}", _moduleId, rnd.Seed);

        var shapes      = new List <bool[, ]>();
        var extraShapes = rnd.ShuffleFisherYates(_sometimesShapes.ToArray());

        for (var i = 0; i < 18; i++)
        {
            shapes.Add(extraShapes[i]);
        }

        // Sneaky! Put the two “alwaysShapes” in the right place to recreate original rules under Seed #1
        shapes.Insert(8, _alwaysShapes[0]);
        shapes.Insert(8, _alwaysShapes[1]);
        rnd.ShuffleFisherYates(shapes);

        _table = newArray(
            new bool[][, ] {
            null, shapes[0], shapes[1], shapes[2], shapes[3]
        },
            new bool[][, ] {
            shapes[4], null, shapes[5], shapes[6], shapes[7]
        },
            new bool[][, ] {
            shapes[8], shapes[9], null, shapes[10], shapes[11]
        },
            new bool[][, ] {
            shapes[12], shapes[13], shapes[14], null, shapes[15]
        },
            new bool[][, ] {
            shapes[16], shapes[17], shapes[18], shapes[19], null
        });

        float scalar = transform.lossyScale.x;

        _lights = new Light[16];
        _colors = new SquareColor[16];

        for (int i = 0; i < 16; i++)
        {
            var j = i;
            Buttons[i].OnInteract += delegate { Pushed(j); return(false); };
            Buttons[i].GetComponent <MeshRenderer>().material = BlackMaterial;
            var light = _lights[i] = (i == 0 ? LightTemplate : Instantiate(LightTemplate));
            light.name                    = "Light" + (i + 1);
            light.transform.parent        = Buttons[i].transform;
            light.transform.localPosition = new Vector3(0, 0.08f, 0);
            light.transform.localScale    = new Vector3(1, 1, 1);
            light.gameObject.SetActive(false);
            light.range = .1f * scalar;
        }

        SetStage(true);
    }
 void Awake()
 {
     NumberText.text = RuleSeed.GetRNG().Seed.ToString();
     foreach (var t in Screws)
     {
         t.localEulerAngles = new Vector3(0, Random.Range(0F, 360F), 0);
     }
     //GetComponent<KMWidget>().OnWidgetActivate += Activate;
 }
Ejemplo n.º 12
0
    void Start()
    {
        _moduleId = _moduleIdCounter++;
        _isSolved = false;

        var rnd = RuleSeedable.GetRNG();

        Log("Using rule seed: {0}", rnd.Seed);
        DoStart(rnd);
    }
Ejemplo n.º 13
0
    private void GenerateManual()
    {
        // Generate manual
        var rnd = ruleSeedable.GetRNG();

        // Colors
        if (rnd.Seed != 1)
        {
            var shuffledColors = rnd.ShuffleFisherYates(Enumerable.Range(0, COLOR_NAMES.Length).ToList());
            var res            = DEFAULT_COLORS.Select(row => row.Select(val => val == -1 ? -1 : shuffledColors[val]).ToList());
            if (rnd.NextDouble() > 0.5)
            {
                res = res.MirrorHorizontal();
            }

            if (rnd.NextDouble() > 0.5)
            {
                res = res.MirrorVertical();
            }

            var rotCount = rnd.Next(0, 4);
            _colorGrid = res.Select(l => l.ToArray()).ToArray().Rotate(rotCount).Select(l => l.ToArray())
                         .ToArray();
        }
        else
        {
            _colorGrid = DEFAULT_COLORS;
        }

        // Symbols
        var symbols = Enumerable.Range(0, symbolTextures.Length).ToList();

        if (rnd.Seed != 1)
        {
            symbols = rnd.ShuffleFisherYates(symbols);
        }

        _symbolGrid = DEFAULT_SYMBOLS.Select(row => row.Select(val => symbols[val]).ToArray()).ToArray();

        // Logging helper
        for (var i = 0; i < _symbolGrid.Length; i++)
        {
            for (var j = 0; j < _symbolGrid[i].Length; j++)
            {
                _symbolPositions[_symbolGrid[i][j]] = "" + "ABCDE"[j] + (i + 1);
            }
        }

        // Log manual
        // Debug.LogFormat("[{0} #{1}] Manual for rule seed {2}:", MODULE_NAME, _moduleId, rnd.Seed);
        // _symbolGrid.Peek(row => Debug.LogFormat("[{0} #{1}]     {2}", MODULE_NAME, _moduleId, row.Join("    ")));
        // Debug.LogFormat("[{0} #{1}] Colors in reading order:", MODULE_NAME, _moduleId);
        // _colorGrid.Peek(row => Debug.LogFormat("[{0} #{1}]     {2}", MODULE_NAME, _moduleId,
        //     row.Select(c => c != -1 ? COLOR_NAMES[c][0] : '.').Join("")));
    }
Ejemplo n.º 14
0
    void Start()
    {
        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat("[Color Numbers #{0}] Using rule seed: {1}", moduleId, rnd.Seed);
        if (rnd.Seed != 1)
        {
            ledValues = rnd.ShuffleFisherYates(ledValues);
        }
        if (colorPicked == false)
        {
            PickLEDColor();
            colorPicked = true;
        }
    }
Ejemplo n.º 15
0
    void Start()
    {
        _moduleId   = _moduleIdCounter++;
        _colorblind = ColorblindMode.ColorblindModeActive;

        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat("[Discolored Squares #{0}] Using rule seed: {1}", _moduleId, rnd.Seed);

        var skip = rnd.Next(0, 6);

        for (var i = 0; i < skip; i++)
        {
            rnd.NextDouble();
        }
        _instructions = rnd.ShuffleFisherYates((Instruction[])Enum.GetValues(typeof(Instruction)));

        var numbers = Enumerable.Range(0, 16).ToArray();

        _ordersByStage = new int[5][];
        for (var stage = 0; stage < 4; stage++)
        {
            rnd.ShuffleFisherYates(numbers);
            _ordersByStage[stage] = numbers.ToArray();
        }

        float scalar = transform.lossyScale.x;

        _lights = new Light[16];
        _colors = new SquareColor[16];

        for (int i = 0; i < 16; i++)
        {
            var j = i;
            Buttons[i].OnInteract += delegate { pressed(j); return(false); };
            Buttons[i].GetComponent <MeshRenderer>().material = BlackMaterial;
            var light = _lights[i] = (i == 0 ? LightTemplate : Instantiate(LightTemplate));
            light.name                    = "Light" + (i + 1);
            light.transform.parent        = Buttons[i].transform;
            light.transform.localPosition = new Vector3(0, 0.08f, 0);
            light.transform.localScale    = new Vector3(1, 1, 1);
            light.gameObject.SetActive(false);
            light.range = .1f * scalar;
        }

        SetInitialState();
    }
Ejemplo n.º 16
0
    // Use this for initialization
    private void Start()
    {
        MorseAMazeRuleGenerator.GenerateRules(RuleSeed.GetRNG());
        StartCoroutine(TwitchPlays.Refresh());
        _modSettings = new ModSettings(BombModule);
        _modSettings.ReadSettings();
        BombModule.GenerateLogFriendlyName();

        Locations.Shuffle();
        SetMaze(0); //Hide the walls now.

        BombModule.OnActivate += Activate;
        FakeStatusLight        = Instantiate(FakeStatusLight);
        FakeStatusLight.transform.SetParent(transform, false);

        if (BombModule != null)
        {
            FakeStatusLight.Module = BombModule;
        }

        EnableColorblindMode(GetComponent <KMColorblindMode>().ColorblindModeActive);


        FakeStatusLight.GetStatusLights(StatusLight);
        FakeStatusLight.SetInActive();

        _currentLocation = Locations[0];
        _destination     = Locations[1];
        StartCoroutine(MoveStatusLightToStart());

        var pass   = _forcedSolvePassword.ToList();
        var offset = 0;

        foreach (var c in BombInfo.GetSerialNumber())
        {
            if (c >= 'A' && c <= 'Z')
            {
                pass.Insert(c - 'A' + offset + 1, c);
            }
            else
            {
                pass.Insert(c - '0' + offset, c);
            }
            offset += 5;
        }
        _forcedSolvePassword = string.Join("", pass.Select(x => x.ToString()).ToArray());
    }
Ejemplo n.º 17
0
    void Start()
    {
        _moduleId = _moduleIdCounter++;

        _switches = new KMSelectable[Switches.Length];
        for (int i = 0; i < Switches.Length; i++)
        {
            _switches[i]             = Switches[i].GetComponent <KMSelectable>();
            _switches[i].OnInteract += GetToggleHandler(i);
        }

        // RULE SEED
        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat(@"[Switches #{0}] Using rule seed: {1}", _moduleId, rnd.Seed);
        _forbiddenConfigurations = rnd.Seed == 1 ? new[] { 4, 26, 30, 9, 25, 29, 3, 11, 7, 15 } : GetForbiddenConfigurations(rnd).ToArray();
        Debug.LogFormat(@"[Switches #{0}] Forbidden configurations are:", _moduleId, rnd.Seed);
        for (var i = 0; i < _forbiddenConfigurations.Length; i++)
        {
            Debug.LogFormat(@"[Switches #{0}] • {1}", _moduleId, DescribeConfiguration(_forbiddenConfigurations[i]));
        }
        // END OF RULE SEED

        var safeConfigurations = Enumerable.Range(0, 1 << _numSwitches).Except(_forbiddenConfigurations).ToList();

        // Pick an intended solution
        var goalIx = Rnd.Range(0, safeConfigurations.Count);

        _goalConfiguration = safeConfigurations[goalIx];
        safeConfigurations.RemoveAt(goalIx);
        Debug.LogFormat(@"[Switches #{0}] Intended solution: {1}", _moduleId, DescribeConfiguration(_goalConfiguration));

        // Make sure the initial switch state won’t just be one switch flip away
        foreach (var adj in GetAdjacentConfigurations(_goalConfiguration))
        {
            safeConfigurations.Remove(adj);
        }

        // Pick an initial switch state
        var initialIx            = Rnd.Range(0, safeConfigurations.Count);
        var initialConfiguration = safeConfigurations[initialIx];

        SetSwitches(initialConfiguration);
        Debug.LogFormat(@"[Switches #{0}] Initial configuration: {1}", _moduleId, DescribeConfiguration(initialConfiguration));

        GetComponent <KMBombModule>().OnActivate += SetGoalIndicators;
    }
Ejemplo n.º 18
0
    void SetupRuleSeed()
    {
        var rnd = RuleSeedable.GetRNG();

        if (rnd.Seed == 1)
        {
            stopNumber = stopNumbers[0];
            return;
        }
        else
        {
            usableNumbers.Shuffle(rnd);
            addFunc.Shuffle(rnd);
            stopNumbers.Shuffle(rnd);
            stopNumber = stopNumbers[0];
        }
    }
Ejemplo n.º 19
0
    void Start()
    {
        moduleId = moduleIdCounter++;

        for (int i = 0; i < Displays.Length; i++)
        {
            Displays[i].OnInteract += DisplayPress(i);
        }

        Displays[4].OnInteractEnded += delegate
        {
            release = true;
        };

        rnd = RuleSeedable.GetRNG();
        Debug.LogFormat(@"[Navinums #{0}] Using Ruleseed {1}", moduleId, rnd.Seed);
        gridDigits = Enumerable.Range(1, 9).ToList();
        Setup();
    }
    private void Start()
    {
        rnd = RuleSeedable.GetRNG();
        int seed = rnd.Seed;

        if (seed == 1)
        {
            YesAns = YesButton;
            NoAns  = NoButton;
            UsesVanillaRuleModifierAPI = false;
        }
        else
        {
            int yes = rnd.Next(0, 2);
            int no  = rnd.Next(0, 2);
            switch (yes)
            {
            case 0:
                YesAns = NoButton;
                break;

            default:
                YesAns = YesButton;
                break;
            }

            switch (no)
            {
            case 0:
                NoAns = YesButton;
                break;

            default:
                NoAns = NoButton;
                break;
            }

            UsesVanillaRuleModifierAPI = true;
        }
        _moduleId          = _moduleIdCounter++;
        Module.OnActivate += Activate;
    }
Ejemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        Debug.LogFormat("OK");
        _moduleId    = _moduleIdCounter++;
        _initialTime = Bomb.GetTime();

        // rule seed init
        var rnd = RuleSeedable.GetRNG();

        rnd.ShuffleFisherYates(_rules);
        rnd.ShuffleFisherYates(_columns);

        // light scaling
        float scalar = transform.lossyScale.x;

        foreach (MeshRenderer light in TopWires)
        {
            light.GetComponentInChildren <Light>().range *= scalar;
        }

        // initialize links activation
        _links = new List <Link>();
        for (int i = 0; i < 12; ++i)
        {
            _links.Add(new Link(_rules[i], _columns[i]));
        }

        for (int i = 0; i < Buttons.Length; ++i)
        {
            int j = i;
            Buttons[i].OnInteract += delegate { buttonPress(j); return(false); };
        }

        // pick the top path
        int startIndex = Rnd.Range(0, 4);

        _startingPoint = (Link.Point)startIndex;
        TopWires[startIndex].GetComponentInChildren <Light>().enabled = true;
        TopWires[startIndex].material = MatWireOn;
        Debug.LogFormat("[Ladder Lottery #{0}] Starting point {1}", _moduleId, _startingPoint.ToString());
    }
    void Start()
    {
        var colorNames = "Black,Blue,Green,Cyan,Red,Magenta,Yellow,White".Split(',');

        moduleId = moduleIdCounter++;
        StartCoroutine(HideStatusLight());
        black         = Materials[0];
        white         = Materials[7];
        materialInfos = Materials.Select((m, ix) => new MaterialInfo {
            Material = m, Color = ix
        }).ToArray();
        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat("[Ultimate Tic Tac Toe #{0}] Using rule seed: {1}", moduleId, rnd.Seed);
        if (rnd.Seed != 1)
        {
            rnd.ShuffleFisherYates(materialInfos);
        }
        Debug.LogFormat("[Ultimate Tic Tac Toe #{0}] Color values are: {1}", moduleId, materialInfos.Select((mi, ix) => string.Format("{0}: {1}", colorNames[mi.Color], ix)).Join(", "));
        Generate();
    }
Ejemplo n.º 23
0
    private void Awake()
    {
        moduleId         = moduleIdCounter++;
        colorblindActive = colorblind.ColorblindModeActive;

        for (var i = 0; i < buttonLights.Length; i++)
        {
            buttonLights[i].enabled = false;
        }

        rnd = RuleSeedable.GetRNG();
        Debug.LogFormat("[Simon Scrambles #{0}] Using rule seed: {1}", moduleId, rnd.Seed);

        if (rnd.Seed != 1)
        {
            var nowColors = rnd.ShuffleFisherYates(Enumerable.Range(0, 4).ToArray());

            for (var i = 0; i < colorTable.GetLength(0); i++)
            {
                for (var j = 0; j < colorTable.GetLength(1); j++)
                {
                    colorTable[i, j] = nowColors[j];
                }

                nowColors = rnd.ShuffleFisherYates(nowColors);
            }
        }

        foreach (KMSelectable key in buttons)
        {
            key.OnInteract += delegate() {
                KeyPressed(key);

                return(false);
            };
        }

        module.OnActivate += OnActivate;
    }
Ejemplo n.º 24
0
    void Start()
    {
        striking = true;
        foreach (Renderer stageLight in stageLights)
        {
            stageLight.material = stageLightOptions[0];
        }
        stageLights[0].material = stageLightOptions[1];

        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat("[Horrible Memory #{0}] Using rule seed: {1}", moduleId, rnd.Seed);
        if (rnd.Seed == 1)
        {
            rules = null;
        }
        else
        {
            rules = new Rule[5][];
            for (int stage = 0; stage < 5; stage++)
            {
                rules[stage] = new Rule[6];
                for (int displayNumber = 0; displayNumber < 6; displayNumber++)
                {
                    rules[stage][displayNumber] = stage == 0
                        ? new Rule {
                        Type = (RuleType)rnd.Next(3), Parameter = rnd.Next(6)
                    }
                        : new Rule {
                        Type = (RuleType)rnd.Next(12), Parameter = rnd.Next(6), EarlierStage = rnd.Next(stage)
                    };
                }
            }
        }

        colorblindModeEnabled = ColorblindMode.ColorblindModeActive;
        SetUpButtons();
    }
Ejemplo n.º 25
0
    private void setSolution()
    {
        initDicts(RuleSeed.GetRNG());
        if (lastTime != (int)Time.realtimeSinceStartup)
        {
            modules  = 0;
            lastTime = (int)Time.realtimeSinceStartup;
        }
        var encrypted = _modSettings.EnableEncryptedIndicators &&
                        modules < _modSettings.MaxEncryptedIndicators &&
                        Random.value < _modSettings.EncryptionProbability;

        if (encrypted)
        {
            modules++;
        }

        int         solutionIndex   = 0;
        List <char> selections      = chars;
        string      secondary_label = "";

        for (int i = 0; i < 3; i++)
        {
            int  index     = Random.Range(0, selections.Count);
            char selection = selections[index];
            char result    = getSymbol(selections, index);
            IndicatorText.text += result;
            selections.Remove(selection);
            solutionIndex   += answers[selection][i];
            secondary_label += secondary_answers[result][i];
        }

        _indicatorLabel = getIndicator(solutionIndex, secondary_label);
        if (!encrypted)
        {
            IndicatorText.text = _indicatorLabel;
        }
    }
Ejemplo n.º 26
0
 void HandleRuleSeed()
 {
     string[] currentQuotes = allPossibleQuotes.ToArray();
     if (ruleSeedCore != null)
     {
         var randomizer = ruleSeedCore.GetRNG();
         randomizer.ShuffleFisherYates(currentQuotes);
         RSReversePriorityLabeled   = randomizer.Next(0, 2) != 1;
         RSReversePriorityUnlabeled = randomizer.Next(0, 2) != 1;
         QuickLog(string.Format("Ruleseed successfully generated with a seed of {0}.", randomizer.Seed));
         if (randomizer.Seed == 1)
         {
             relabeledStageOrder = new[] { 0, 1, 2, 3, -1 }
         }
         ;
         else
         {
             relabeledStageOrder = new[] { 0, 2, 3, 4, -1 };
         }
     }
     else
     {
         QuickLog("Ruleseed handler does not exist. Using default instructions.");
         var randomizer = new MonoRandom(1);
         randomizer.ShuffleFisherYates(currentQuotes);
         RSReversePriorityLabeled   = randomizer.Next(0, 2) != 1;
         RSReversePriorityUnlabeled = randomizer.Next(0, 2) != 1;
         relabeledStageOrder        = new[] { 0, 1, 2, 3, -1 };
     }
     shuffledQuotes = currentQuotes.ToArray();
     Debug.LogFormat("<Labeled Priorities Plus #{0}> All phrases from top to bottom:", modID);
     for (int x = 0; x < shuffledQuotes.Length; x++)
     {
         Debug.LogFormat("<Labeled Priorities Plus #{0}> {2}: \"{1}\"", modID, shuffledQuotes[x].Replace("\n", " "), x + 1);
     }
     Debug.LogFormat("<Labeled Priorities Plus #{0}> Phrase priority when disarming Labeled Priorities: {1}", modID, RSReversePriorityLabeled ? "low to high" : "high to low");
     Debug.LogFormat("<Labeled Priorities Plus #{0}> Phrase priority when disarming Unlabeled Priorities: {1}", modID, RSReversePriorityUnlabeled ? "low to high" : "high to low");
 }
Ejemplo n.º 27
0
    void Awake()
    {
        moduleId = moduleIdCounter++;
        foreach (KMSelectable button in buttons)
        {
            button.OnInteract += delegate() { ButtonPress(button); return(false); }
        }
        ;
        module.OnActivate += delegate() { StartCoroutine(ShowWords()); };
        colorblindText.gameObject.SetActive(GetComponent <KMColorblindMode>().ColorblindModeActive);

        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat("[M&Ms #{0}] Using rule seed: {1}.", moduleId, rnd.Seed);
        grids = new bool[9][];
        var gridsAlready = new List <bool[]>();

        for (var gridIx = 0; gridIx < 9; gridIx++)
        {
            var grid = FindGrid(new bool[25], 0, gridsAlready, rnd);
            if (grid == null)
            {
                Debug.LogFormat("<M&Ms #{0}> Fatal error: no grid!", moduleId);
                throw new InvalidOperationException();
            }
            grids[gridIx] = grid;

            //var gridStr = grid.Select(b => b ? "█" : "░").Join("");
            //Debug.LogFormat("<M&Ms #{0}> Grid #{1}:\n{2}", moduleId, gridIx, gridStr.Substring(0, 5) + "\n" + gridStr.Substring(5, 5) + "\n" + gridStr.Substring(10, 5) + "\n" + gridStr.Substring(15, 5) + "\n" + gridStr.Substring(20, 5));

            for (var rot = 0; rot < 4; rot++)
            {
                gridsAlready.Add(grid);
                grid = Rotate(grid);
            }
        }
    }
Ejemplo n.º 28
0
    // Use this for initialization
    void Start()
    {
        BigCircleRuleGenerator.CreateRules(RuleSeed.GetRNG());
        _colorblindMode = GetComponent <KMColorblindMode>().ColorblindModeActive;
        colorLookup     = BigCircleRuleGenerator.Rules;
        BombModule.GenerateLogFriendlyName();
        _rotateCounterClockwise          = Rnd.value < 0.5;
        WedgeRenderers[0].material.color = Color.cyan;
        _colors.Shuffle();
        for (var i = 0; i < 8; i++)
        {
            WedgeRenderers[i].material.color = _wedgeColors[(int)_colors[i]];
            var j = _colors[i];
            var k = i;
            Wedges[i].OnInteract += delegate
            {
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Wedges[k].transform);
                _holdTime = 0;
                return(false);
            };
            Wedges[i].OnInteractEnded += delegate { HandleWedge(j); };

            //Colorblind mode
            WedgeTextMeshes[i].gameObject.SetActive(_colorblindMode);
            WedgeTextMeshes[i].text  = _colorNames[(int)_colors[i]];
            WedgeTextMeshes[i].color = _wedgeColors[(int)_colors[i]];
        }

        //BombModule.LogFormat("Colors in Clockwise order: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", _colors[0], _colors[1], _colors[2], _colors[3], _colors[4], _colors[5], _colors[6], _colors[7]);
        BombModule.OnActivate += delegate
        {
            _activated  = true;
            _spinCircle = StartCoroutine(SpinCircle());
            StartCoroutine(UpdateSolution());
        };
    }
Ejemplo n.º 29
0
    void Start()
    {
        _moduleId = _moduleIdCounter++;

        _edgesMat = Edges[0].GetComponent <MeshRenderer>().material;
        for (int i = 0; i < Edges.Length; i++)
        {
            Edges[i].GetComponent <MeshRenderer>().sharedMaterial = _edgesMat;
        }

        _verticesMat = Vertices[0].GetComponent <MeshRenderer>().material;
        for (int i = 0; i < Vertices.Length; i++)
        {
            Vertices[i].GetComponent <MeshRenderer>().sharedMaterial = _verticesMat;
        }

        _facesMat = Faces.GetComponent <MeshRenderer>().material;

        SetHypercube(GetUnrotatedVertices().Select(p => p.Project()).ToArray());

        // RULE SEED
        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat("[The Hypercube #{0}] Using rule seed: {1}", _moduleId, rnd.Seed);
        _faces = new List <bool?[]>();

        for (var i = 0; i < _shapeOrder.Length; i++)
        {
            for (var j = i + 1; j < _shapeOrder.Length; j++)
            {
                var which = rnd.Next(0, 2) != 0;
                if (rnd.Next(0, 2) == 0)
                {
                    _faces.Add(Enumerable.Range(0, 4).Select(d => d == _shapeOrder[i] ? false : d == _shapeOrder[j] ? which : (bool?)null).ToArray());
                    _faces.Add(Enumerable.Range(0, 4).Select(d => d == _shapeOrder[i] ? true : d == _shapeOrder[j] ? which : (bool?)null).ToArray());
                }
                else
                {
                    _faces.Add(Enumerable.Range(0, 4).Select(d => d == _shapeOrder[i] ? which : d == _shapeOrder[j] ? false : (bool?)null).ToArray());
                    _faces.Add(Enumerable.Range(0, 4).Select(d => d == _shapeOrder[i] ? which : d == _shapeOrder[j] ? true : (bool?)null).ToArray());
                }
            }
        }
        rnd.ShuffleFisherYates(_faces);
        _colorPermutations = rnd.ShuffleFisherYates(
            new[] { "RYGB", "RYBG", "RGYB", "RGBY", "RBYG", "RBGY", "YRGB", "YRBG", "YGRB", "YGBR", "YBRG", "YBGR", "GRYB", "GRBY", "GYRB", "GYBR", "GBRY", "GBYR", "BRYG", "BRGY", "BYRG", "BYGR", "BGRY", "BGYR" }
            .Select(str => str.Select(ch => "RYGB".IndexOf(ch)).ToArray()).ToArray()
            ).Take(12).ToArray();

        Debug.LogFormat("<The Hypercube #{0}> Rules:\n{1}", _moduleId, Enumerable.Range(0, _rotationNames.Length).Select(ix => string.Format("{0}={1}", _rotationNames[ix], StringifyShape(_faces[ix]))).Join("\n"));

        // GENERATE PUZZLE
        _rotations = new int[5];
        for (int i = 0; i < _rotations.Length; i++)
        {
            var axes = "XYZW".ToArray().Shuffle();
            _rotations[i] = Array.IndexOf(_rotationNames, string.Concat(axes[0], axes[1]));
        }

        // ## FOR CREATING THE “ALL ROTATIONS” GIF
        //if (_moduleId >= 1 && _moduleId <= 12)
        //{
        //    _rotations = new int[5] { _moduleId - 1, _moduleId - 1, _moduleId - 1, _moduleId - 1, _moduleId - 1 };
        //    RotationText.text = _rotationNames[_moduleId - 1];
        //    RotationText.gameObject.SetActive(true);
        //}
        //else
        //    RotationText.gameObject.SetActive(false);
        // ## END

        Debug.LogFormat(@"[The Hypercube #{0}] Rotations are: {1}", _moduleId, _rotations.Select(rot => _rotationNames[rot]).Join(", "));

        for (var i = 0; i < 1 << 4; i++)
        {
            Vertices[i].OnInteract      = VertexClick(i);
            Vertices[i].OnInteractEnded = VertexRelease(i);
        }

        _rotationCoroutine = StartCoroutine(RotateHypercube());
    }
Ejemplo n.º 30
0
    void Start()
    {
        moduleId            = moduleIdCounter++;
        startingTimeSeconds = (int)BombInfo.GetTime();
        day   = DateTime.Now.Day;
        month = DateTime.Now.Month;

        // ** RULE SEED ** //
        var rnd = RuleSeedable.GetRNG();

        Debug.LogFormat(@"[Mega Man 2 #{0}] Using rule seed: {1}", moduleId, rnd.Seed);
        robotMasters = rnd.Seed == 1
            ? new[] { "Air Man", "Bubble Man", "Crash Man", "Flash Man", "Heat Man", "Metal Man", "Quick Man", "Wood Man" }
            : rnd.ShuffleFisherYates(new[] { "Cold Man", "Magma Man", "Dust Man", "Sword Man", "Splash Woman", "Ice Man", "Quick Man", "Hard Man", "Pharaoh Man", "Charge Man", "Pirate Man", "Pump Man", "Galaxy Man", "Grenade Man", "Snake Man", "Burst Man", "Cut Man", "Air Man", "Magnet Man", "Toad Man", "Gyro Man", "Tomahawk Man", "Wood Man", "Strike Man", "Blade Man", "Aqua Man", "Shade Man", "Flash Man", "Flame Man", "Concrete Man", "Metal Man", "Needle Man", "Wave Man", "Knight Man", "Slash Man", "Shadow Man", "Sheep Man", "Ground Man", "Wind Man", "Fire Man", "Stone Man", "Tengu Man", "Bright Man", "Centaur Man", "Cloud Man", "Frost Man", "Dynamo Man", "Chill Man", "Turbo Man", "Napalm Man", "Jewel Man", "Drill Man", "Freeze Man", "Blizzard Man", "Gravity Man", "Junk Man", "Clown Man", "Hornet Man", "Skull Man", "Solar Man", "Commando Man", "Yamato Man", "Dive Man", "Search Man", "Gemini Man", "Bubble Man", "Guts Man", "Tornado Man", "Astro Man", "Plug Man", "Elec Man", "Crystal Man", "Nitro Man", "Burner Man", "Spark Man", "Spring Man", "Plant Man", "Star Man", "Ring Man", "Top Man", "Crash Man", "Bomb Man", "Heat Man", "Magic Man" });

        var presetCoordinates = new Dictionary <string, Coords>
        {
            { "Air Man", new Coords("B2", "E1") },
            { "Bubble Man", new Coords("D5", "D2") },
            { "Crash Man", new Coords("D4", "B1") },
            { "Flash Man", new Coords("C5", "B3") },
            { "Heat Man", new Coords("C1", "E4") },
            { "Metal Man", new Coords("B4", "E5") },
            { "Quick Man", new Coords("C3", "D3") },
            { "Wood Man", new Coords("E2", "C4") }
        };

        var availableCoordinates = new List <string>();

        for (var row = 1; row < 5; row++)
        {
            for (var col = 0; col < 5; col++)
            {
                availableCoordinates.Add((char)('A' + row) + "" + (col + 1));
            }
        }
        for (int i = 0; i < 8; i++)
        {
            if (presetCoordinates.ContainsKey(robotMasters[i]))
            {
                availableCoordinates.Remove(presetCoordinates[robotMasters[i]].DeadCoord);
                availableCoordinates.Remove(presetCoordinates[robotMasters[i]].AliveCoord);
            }
        }

        rnd.ShuffleFisherYates(availableCoordinates);

        var coordinatesIx = 0;
        var coordinates   = new Coords[8];

        for (var i = 0; i < 8; i++)
        {
            if (presetCoordinates.ContainsKey(robotMasters[i]))
            {
                coordinates[i] = presetCoordinates[robotMasters[i]];
            }
            else
            {
                coordinates[i] = new Coords(availableCoordinates[coordinatesIx], availableCoordinates[coordinatesIx + 1]);
                coordinatesIx += 2;
            }
        }

        // These must all have at least 3 because each of them can potentially occur 3 times
        var allAABatteries = BombInfo.GetBatteryCount(Battery.AA) + BombInfo.GetBatteryCount(Battery.AAx3) + BombInfo.GetBatteryCount(Battery.AAx4);
        var brules         = rnd.ShuffleFisherYates(newArray(
                                                        new EdgeworkRule("# of batteries", BombInfo.GetBatteryCount()),
                                                        new EdgeworkRule("# of D batteries", BombInfo.GetBatteryCount(Battery.D)),
                                                        new EdgeworkRule("# of AA batteries", allAABatteries),
                                                        new EdgeworkRule("# of battery holders", BombInfo.GetBatteryHolderCount())).ToList());

        var irules = rnd.ShuffleFisherYates(newArray(
                                                new EdgeworkRule("# of indicators", BombInfo.GetIndicators().Count()),
                                                new EdgeworkRule("# of lit indicators", BombInfo.GetOnIndicators().Count()),
                                                new EdgeworkRule("# of unlit indicators", BombInfo.GetOffIndicators().Count())).ToList());

        var prules = rnd.ShuffleFisherYates(newArray(
                                                new EdgeworkRule("# of ports", BombInfo.GetPortCount()),
                                                new EdgeworkRule("# of port types", BombInfo.CountUniquePorts()),
                                                new EdgeworkRule("# of port plates", BombInfo.GetPortPlates().Count())).ToList());

        var srules = rnd.ShuffleFisherYates(newArray(
                                                new EdgeworkRule("first SN digit", BombInfo.GetSerialNumberNumbers().First()),
                                                new EdgeworkRule("second SN digit", BombInfo.GetSerialNumberNumbers().Skip(1).First()),
                                                new EdgeworkRule("last SN digit", BombInfo.GetSerialNumberNumbers().Last())).ToList());

        var inds = rnd.ShuffleFisherYates(new List <string> {
            "SND", "CLR", "CAR", "IND", "FRQ", "SIG", "NSA", "MSA", "TRN", "BOB", "FRK"
        });
        var ports = rnd.ShuffleFisherYates(new List <Port> {
            Port.DVI, Port.Parallel, Port.PS2, Port.RJ45, Port.Serial, Port.StereoRCA
        });
        var operatorNames = new[] { "=", "≤", "≥", "≠" };

        var ops = new Func <int, int, int, bool>((x, y, op) =>
        {
            switch (op)
            {
            case 0: return(x == y);

            case 1: return(x <= y);

            case 2: return(x >= y);

            default: return(x != y);
            }
        });

        var possibleAliveConditions = newArray <Func <int, bool, Rule> >(
            (op, presence) => { var indicator = inds[0]; inds.RemoveAt(0); return(new Rule(string.Format("indicator labeled “{0}” {1}", indicator, presence ? "present" : "absent"), _ => !presence ^ BombInfo.IsIndicatorPresent(indicator))); },
            (op, presence) => { var indicator = inds[0]; inds.RemoveAt(0); return(new Rule(string.Format("lit indicator labeled “{0}” {1}", indicator, presence ? "present" : "absent"), _ => !presence ^ BombInfo.IsIndicatorOn(indicator))); },
            (op, presence) => { var indicator = inds[0]; inds.RemoveAt(0); return(new Rule(string.Format("unlit indicator labeled “{0}” {1}", indicator, presence ? "present" : "absent"), _ => !presence ^ BombInfo.IsIndicatorOff(indicator))); },
            (op, presence) => { var number = rnd.Next(1, 6); return(new Rule(string.Format("E-Tanks spot {0} A{1}", operatorNames[op], number), eTankNumber => ops(eTankNumber, number, op), eTanks: true)); },
            (op, presence) => { var brule = brules[0]; brules.RemoveAt(0); var number = rnd.Next(1, 11); return(new Rule(string.Format("{0} {1} {2}", brule.Name, operatorNames[op], number), _ => ops(brule.Value, number, op))); },
            (op, presence) => { var irule = irules[0]; irules.RemoveAt(0); var number = rnd.Next(2, 6); return(new Rule(string.Format("{0} {1} {2}", irule.Name, operatorNames[op], number), _ => ops(irule.Value, number, op))); },
            (op, presence) => { var prule = prules[0]; prules.RemoveAt(0); var number = rnd.Next(2, 8); return(new Rule(string.Format("{0} {1} {2}", prule.Name, operatorNames[op], number), _ => ops(prule.Value, number, op))); },
            (op, presence) => { var srule = srules[0]; srules.RemoveAt(0); var number = rnd.Next(0, 10); return(new Rule(string.Format("{0} {1} {2}", srule.Name, operatorNames[op], number), _ => ops(srule.Value, number, op))); },
            (op, presence) => { var port = ports[0]; ports.RemoveAt(0); return(new Rule(string.Format("{0} port {1}", port, presence ? "present" : "absent"), _ => !presence ^ BombInfo.IsPortPresent(port))); },
            (op, presence) => { var brule = brules[0]; brules.RemoveAt(0); var irule = irules[0]; irules.RemoveAt(0); return(new Rule(string.Format("{0} {1} {2}", brule.Name, operatorNames[op], irule.Name), _ => ops(brule.Value, irule.Value, op))); },
            (op, presence) => { var brule = brules[0]; brules.RemoveAt(0); var prule = prules[0]; prules.RemoveAt(0); return(new Rule(string.Format("{0} {1} {2}", brule.Name, operatorNames[op], prule.Name), _ => ops(brule.Value, prule.Value, op))); },
            (op, presence) => { var brule = brules[0]; brules.RemoveAt(0); var srule = srules[0]; srules.RemoveAt(0); return(new Rule(string.Format("{0} {1} {2}", brule.Name, operatorNames[op], srule.Name), _ => ops(brule.Value, srule.Value, op))); },
            (op, presence) => { var irule = irules[0]; irules.RemoveAt(0); var prule = prules[0]; prules.RemoveAt(0); return(new Rule(string.Format("{0} {1} {2}", irule.Name, operatorNames[op], prule.Name), _ => ops(irule.Value, prule.Value, op))); },
            (op, presence) => { var irule = irules[0]; irules.RemoveAt(0); var srule = srules[0]; srules.RemoveAt(0); return(new Rule(string.Format("{0} {1} {2}", irule.Name, operatorNames[op], srule.Name), _ => ops(irule.Value, srule.Value, op))); },
            (op, presence) => { var prule = prules[0]; prules.RemoveAt(0); var srule = srules[0]; srules.RemoveAt(0); return(new Rule(string.Format("{0} {1} {2}", prule.Name, operatorNames[op], srule.Name), _ => ops(prule.Value, srule.Value, op))); }
            ).ToList();

        if (rnd.Seed != 1)
        {
            possibleAliveConditions.Add((op, presence) => { var number = rnd.Next(5, 31); return(new Rule(string.Format("# of modules on the bomb {0} {1}", operatorNames[op], number), _ => ops(BombInfo.GetModuleNames().Count, number, op))); });
            possibleAliveConditions.Add((op, presence) => { var number = rnd.Next(10, 61); return(new Rule(string.Format("Starting time of the bomb {0} {1} minutes", operatorNames[op], number), _ => ops(startingTimeSeconds, number * 60, op))); });
        }
        rnd.ShuffleFisherYates(possibleAliveConditions);

        var aliveConditions     = new Rule[8];
        var anyETanksConditions = false;

        for (var i = 0; i < 8; i++)
        {
            var ruleInfo = possibleAliveConditions[i];
            var op       = rnd.Next(0, 4);
            var presence = rnd.Next(0, 2) == 0;
            aliveConditions[i] = ruleInfo(op, presence);
            if (aliveConditions[i].ETanks)
            {
                anyETanksConditions = true;
            }
        }

        var numbers             = rnd.ShuffleFisherYates(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
        var numbersObjArr       = numbers.Cast <object>().ToArray();
        var possibleETanksRules = (rnd.Seed == 1
            ? new[] { new EdgeworkRule("sum of all digits in the serial number", BombInfo.GetSerialNumberNumbers().Sum()) }
            : newArray(
                                       new EdgeworkRule("sum of all digits in the serial number", BombInfo.GetSerialNumberNumbers().Sum()),
                                       new EdgeworkRule("sum of the alphabetic positions of the letters in the serial number", BombInfo.GetSerialNumberLetters().Select(ltr => ltr - 'A' + 1).Sum()),
                                       new EdgeworkRule("sum of the alphabetic positions of the letters in all indicators", BombInfo.GetIndicators().SelectMany(i => i).Select(ltr => ltr - 'A' + 1).Sum()),
                                       new EdgeworkRule(string.Format("sum of the values of the indicators, where lit={0} and unlit={1}", numbersObjArr), BombInfo.GetOnIndicators().Count() * numbers[0] + BombInfo.GetOffIndicators().Count() * numbers[1]),
                                       new EdgeworkRule(string.Format("sum of the values of the ports, where parallel={0}, serial={1}, DVI-D={2}, Stereo RCA={3}, PS/2={4} and RJ-45={5} (other port types are 0)", numbersObjArr),
                                                        BombInfo.GetPortCount(Port.Parallel) * numbers[0] +
                                                        BombInfo.GetPortCount(Port.Serial) * numbers[1] +
                                                        BombInfo.GetPortCount(Port.DVI) * numbers[2] +
                                                        BombInfo.GetPortCount(Port.StereoRCA) * numbers[3] +
                                                        BombInfo.GetPortCount(Port.PS2) * numbers[4] +
                                                        BombInfo.GetPortCount(Port.RJ45) * numbers[5]),
                                       new EdgeworkRule(string.Format("sum of the values of the batteries, where AA={0} and D={1}", numbersObjArr), allAABatteries * numbers[0] + BombInfo.GetBatteryCount(Battery.D) * numbers[1]),
                                       new EdgeworkRule("number of modules on the bomb (including needies)", BombInfo.GetModuleNames().Count),
                                       new EdgeworkRule("number of modules on the bomb (excluding needies)", BombInfo.GetSolvableModuleNames().Count),
                                       new EdgeworkRule("number of the current month when the bomb was activated", month),
                                       new EdgeworkRule("day of the month when the bomb was activated", day),
                                       new EdgeworkRule("total number of Mega Man 2 modules on the bomb", BombInfo.GetSolvableModuleNames().Count(m => m == "Mega Man 2")))).ToList();

        if (rnd.Seed != 1 && !anyETanksConditions)
        {
            var aliveTmp = aliveConditions.Count(rule => rule.Evaluate(0));
            possibleETanksRules.Add(new EdgeworkRule("total number of robot masters that are alive", aliveTmp));
            possibleETanksRules.Add(new EdgeworkRule("total number of robot masters that are dead", 8 - aliveTmp));
        }

        var eTankRuleIx = rnd.Next(0, possibleETanksRules.Count);
        var eTank       = (possibleETanksRules[eTankRuleIx].Value + 4) % 5 + 1;

        // ** END RULE SEED GENERATION ** //


        var availableRobotMasterIxs = Enumerable.Range(0, 8).ToList();

        int ix = Random.Range(0, availableRobotMasterIxs.Count);

        selectedMaster = availableRobotMasterIxs[ix];
        availableRobotMasterIxs.RemoveAt(ix);
        selectedWeapon = availableRobotMasterIxs[Random.Range(0, availableRobotMasterIxs.Count)];

        RobotMastersDisplay.material.mainTexture = RobotMasters.First(tx => tx.name == robotMasters[selectedMaster]);
        WeaponsDisplay.material.mainTexture      = Weapons.First(tx => tx.name == robotMasters[selectedWeapon]);

        solution    = new string[9];
        solution[8] = "A" + eTank;
        Debug.LogFormat(@"[Mega Man 2 #{0}] ETanks spot is: {1}", moduleId, solution[8]);

        for (int i = 0; i < 8; i++)
        {
            var alive = i == selectedMaster ? true : i == selectedWeapon ? false : aliveConditions[i].Evaluate(eTank);
            Debug.LogFormat(@"[Mega Man 2 #{0}] {1} is {2} ({3})", moduleId, robotMasters[i], alive ? "alive" : "dead", i == selectedMaster ? "robot master shown on module" : i == selectedWeapon ? "weapon shown on module" : aliveConditions[i].Text + " = " + (aliveConditions[i].Evaluate(eTank) ? "true" : "false"));
            solution[i] = alive ? coordinates[i].AliveCoord : coordinates[i].DeadCoord;
        }

        Debug.LogFormat(@"[Mega Man 2 #{0}] Password is: {1}", moduleId, solution.Join(", "));
    }