Beispiel #1
0
        static Situation OpeningSituation(uint state, Player player, bool noRare = false)
        {
            const int DECK_MAX = 5;

            var rng  = new CardRng(state);
            var deck = new List <int>();

            if (!noRare)
            {
                foreach (var rareId in player.Rares)
                {
                    var limit = deck.Count == 0 ? player.RareLimit : player.RareLimit / 2;

                    if (rng.Next() % 100 < limit)
                    {
                        deck.Add(rareId);
                    }

                    if (deck.Count >= DECK_MAX)
                    {
                        break;
                    }
                }
            }

            var pupuId = CardTable.FindIdByName("PuPu");

            while (deck.Count < DECK_MAX)
            {
                var lv     = player.Levels[rng.Next() % player.Levels.Length];
                var row    = rng.Next() % 11;
                var cardId = (lv - 1) * 11 + (int)row;

                if (cardId == pupuId || deck.Contains(cardId))
                {
                    continue;
                }

                deck.Add(cardId);
            }

            var initiative = (rng.Next() & 1) != 0;

            return(new Situation()
            {
                Deck = deck,
                Initiative = initiative,
                FirstState = state,
                LastState = rng.State,
            });
        }
Beispiel #2
0
        static (uint firstState, uint state, uint count, TSearchType searchType) ReadArgs(string[] args, bool silent = false)
        {
            var s = args[0];
            var earlyQuistisTable = EarlyQuistisStateTable.Get(_options.EarlyQuistis);
            var firstState        = 0U;
            var searchType        = TSearchType.First;
            var msg = "";

            switch (s)
            {
            case "0":     // Unused
                firstState = earlyQuistisTable.Unused;
                msg        = Translate.Get("read_argv.unused");
                break;

            case "1":     // Elastoid
                firstState = earlyQuistisTable.Elastoid;
                msg        = string.Format(Translate.Get("read_argv.pattern_fmt"), _options.EarlyQuistis.Capitalize(), Translate.Get("read_argv.elastoid"));
                break;

            case "2":     // Malboro
                firstState = earlyQuistisTable.Malboro;
                msg        = string.Format(Translate.Get("read_argv.pattern_fmt"), _options.EarlyQuistis.Capitalize(), Translate.Get("read_argv.malboro"));
                break;

            case "3":     // Wedge
                firstState = earlyQuistisTable.Wedge;
                msg        = string.Format(Translate.Get("read_argv.pattern_fmt"), _options.EarlyQuistis.Capitalize(), Translate.Get("read_argv.wedge"));
                break;

            default:     // Hex state
                firstState = Convert.ToUInt32(s, fromBase: 16) & 0xffff_ffff;
                searchType = TSearchType.Recovery;
                msg        = string.Format(Translate.Get("read_argv.direct_rng_state_fmt"), firstState);
                break;
            }

            if (searchType == TSearchType.First)
            {
                msg = string.Format(Translate.Get("read_argv.select_fmt"), msg);
                msg = string.Format("{0}: 0x{1:x8}", msg, firstState);
            }

            var state = firstState;
            var count = 0U;

            if (args.Length > 1)
            {
                count = uint.Parse(args[1]);
                var rng = new CardRng(firstState);

                for (var i = 0; i < count; i++)
                {
                    rng.Next();
                }

                msg += "\n" + string.Format(Translate.Get("read_argv.advanced_rng_fmt"), count, rng.State);

                state      = rng.State;
                searchType = TSearchType.Counting;
            }

            if (!silent)
            {
                Console.WriteLine(msg);
            }

            return(firstState, state, count, searchType);
        }
Beispiel #3
0
        static IList <TableEntry> MakeOpeningTable(uint from, uint to, uint state, Player player, TSearchType searchType, uint incr)
        {
            var          size = to + 1;
            IList <uint> rngStateArr;
            IList <int>  offsetArr;

            if (searchType == TSearchType.First)
            {
                var rng = new CardRng(state);

                rngStateArr = new uint[size].Select(_ =>
                {
                    var stateCopy = rng.State;
                    rng.Next();
                    return(stateCopy);
                }).ToList();

                var offsetArrSize = (int)(60f / _options.AutofireSpeed);

                offsetArr = new int[offsetArrSize].Select((_, i) =>
                {
                    return((int)_options.ForcedIncr + i);
                }).ToList();
            }
            else if (searchType == TSearchType.Counting)
            {
                var(firstState, _, count, _) = ReadArgs(_args, silent: true);
                var rng    = new CardRng(firstState);
                var maxIdx = count + _options.CountingWidth;

                rngStateArr = new uint[maxIdx].Select(_ =>
                {
                    var stateCopy = rng.State;
                    rng.Next();
                    return(stateCopy + incr);
                }).ToList();

                offsetArr = new int[_options.CountingFrameWidth].Select((_, i) =>
                {
                    return(i - (int)_options.CountingFrameWidth / 2);
                }).ToList();
            }
            else
            {
                rngStateArr = new uint[size].Select((_, i) =>
                {
                    return((state + (uint)i) & 0xffff_ffff);
                }).ToList();

                offsetArr = new[] { 0 };
            }

            var table = new List <TableEntry>();

            for (var idx = 0; idx <= to; idx++)
            {
                if (!(idx >= from && idx <= to))
                {
                    continue;
                }

                foreach (var offset in offsetArr)
                {
                    var rngState = (rngStateArr[idx] + offset) & 0xffff_ffff;

                    table.Add(new TableEntry()
                    {
                        Index   = idx,
                        Offset  = offset,
                        Opening = OpeningSituation((uint)rngState, player),
                    });
                }
            }

            return(table);
        }