Пример #1
0
        static LookupDictionairy <Seed, GenerationResult> ReadKnownSeeds()
        {
            var seeds = new LookupDictionairy <Seed, GenerationResult>(r => r.Seed);

            if (!File.Exists(GeneratedSeedsFileName))
            {
                return(seeds);
            }

            var lines = File.ReadAllLines(GeneratedSeedsFileName);

            foreach (var line in lines)
            {
                var segments = line.Split(',');

                if (!Seed.TryParse(segments[0], out var seed) ||
                    !int.TryParse(segments[1], out var itterations) ||
                    !TimeSpan.TryParse(segments[1], out var time))
                {
                    continue;
                }

                var result = new GenerationResult
                {
                    Seed        = seed,
                    Itterations = itterations,
                    Elapsed     = time
                };

                seeds.Add(result);
            }

            return(seeds);
        }
Пример #2
0
        void ResetMinimap()
        {
            if (preservedRoomStates == null)
            {
                return;
            }

            foreach (var roomState in preservedRoomStates)
            {
                roomState.ApplyTo(GetRoom(roomState.RoomKey));
            }

            preservedRoomStates = null;
        }
Пример #3
0
        public ItemUnlockingMap(Seed seed)
        {
            var random = new Random((int)seed.Id);

            unlockingSpecifications = new LookupDictionairy <ItemIdentifier, UnlockingSpecification>(26, s => s.Item)
            {
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.TimespinnerWheel), R.TimespinnerWheel, R.TimeStop),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.DoubleJump), R.DoubleJump, R.TimeStop),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.Dash), R.ForwardDash),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Flame, EOrbSlot.Passive), R.AntiWeed),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Flame, EOrbSlot.Melee), R.AntiWeed),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Flame, EOrbSlot.Spell), R.AntiWeed),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Book, EOrbSlot.Spell), R.AntiWeed),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.ScienceKeycardA), R.CardA, R.CardB | R.CardC | R.CardD),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.ScienceKeycardB), R.CardB, R.CardC | R.CardD),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.ScienceKeycardC), R.CardC, R.CardD),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.ScienceKeycardD), R.CardD),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.ElevatorKeycard), R.CardE),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.ScienceKeycardV), R.CardV),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.WaterMask), R.Swimming),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.TimespinnerSpindle), R.TimespinnerSpindle),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.TimespinnerGear1), R.TimespinnerPiece1),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.TimespinnerGear2), R.TimespinnerPiece2),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.TimespinnerGear3), R.TimespinnerPiece3),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.EssenceOfSpace), R.UpwardDash, R.DoubleJump | R.TimeStop),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Barrier, EOrbSlot.Spell), R.UpwardDash, R.DoubleJump | R.TimeStop),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Pink, EOrbSlot.Melee), R.PinkOrb),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Pink, EOrbSlot.Spell), R.PinkOrb),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Pink, EOrbSlot.Passive), R.PinkOrb),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.AirMask), R.GassMask),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.Tablet), R.Tablet),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Eye, EOrbSlot.Passive), R.OculusRift),
            };

            if (seed.Options.SpecificKeys)
            {
                MakeKeyCardUnlocksCardSpecific();
            }

            var pyramidUnlockingSpecification =
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.PyramidsKey), R.None, R.Teleport);

            SetTeleporterPickupAction(random, pyramidUnlockingSpecification, seed.Options);

            unlockingSpecifications.Add(pyramidUnlockingSpecification);
        }
Пример #4
0
        public void Should_generate_a_hundert_beatable_seeds()
        {
            var seeds = new LookupDictionairy <Seed, GenerationResult>(r => r.Seed);

            while (seeds.Count != 100)
            {
                var result = Randomizer.Generate(FillingMethod.Random, SeedOptions.None);

                if (!seeds.Contains(result.Seed))
                {
                    seeds.Add(result);
                }
            }

            var longestGeneration = seeds.OrderByDescending(s => s.Elapsed).First();
            var validSeeds        = string.Join("\n", seeds.Select(s => s.Seed));

            Assert.That(seeds, Is.Not.Empty);
        }
Пример #5
0
        void MarkAvailableItemLocations()
        {
            preservedRoomStates = new LookupDictionairy <Roomkey, MinimapRoomState>(r => r.RoomKey);

            var visableAreas = (List <EMinimapEraType>)Dynamic._availableEras;

            foreach (var itemLocation in GetAvailableItemLocations())
            {
                var roomKey = new Roomkey(itemLocation.Key.LevelId, itemLocation.Key.RoomId);                 //somehow they keys dont match if we use itemLocation.Key directly
                if (preservedRoomStates.Contains(roomKey))
                {
                    continue;
                }

                var room = GetRoom(roomKey);

                MakeSureEraIsVisable(visableAreas, room);
                preservedRoomStates.Add(new MinimapRoomState(roomKey, room));

                foreach (var block in room.Blocks.Values)
                {
                    if (block.IsSolidWall)
                    {
                        continue;
                    }

                    block.IsKnown   = true;
                    block.IsVisited = true;

                    if (block.IsTransition || block.IsCheckpoint || block.IsBoss)
                    {
                        block.IsTransition = false;
                        block.IsCheckpoint = false;
                        block.RoomColor    = EMinimapRoomColor.Yellow;
                    }
                    else
                    {
                        block.RoomColor = EMinimapRoomColor.Orange;
                    }
                }
            }
        }