Beispiel #1
0
        static LookupDictionary <Seed, GenerationResult> ReadKnownSeeds()
        {
            var seeds = new LookupDictionary <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);
        }
Beispiel #2
0
 MidPriorityBinaryOperatorLookup(LookupDictionary <MidPriorityBinaryOperator> lookup)
     : base(lookup)
 {
     lookup.Add("*", new MidPriorityBinaryOperator("*", (x, y) => x * y));
     lookup.Add("/", new MidPriorityBinaryOperator("/", (x, y) => x / y));
     lookup.Add("%", new MidPriorityBinaryOperator("%", (x, y) => x % y));
 }
Beispiel #3
0
 private void FetchParameterModels()
 {
     if (_parameterModels == null)
     {
         FetchParameterList();
         _parameterModels = new LookupDictionary <BaseParameter, BaseParameter, BaseValueViewModel>(_parameterList, k => k, v =>
         {
             var result = BaseValueViewModel.Fetch(ViewModelFactory, DataContext, this, v, v.GetValueModel(v.IsNullable));
             return(result);
         });
     }
 }
 FunctionLookup(LookupDictionary <Function> lookup)
     : base(lookup)
 {
     lookup.Add("abs", new Function("abs", x => Math.Abs(x)));
     lookup.Add("ceiling", new Function("ceiling", x => Math.Ceiling(x)));
     lookup.Add("cos", new Function("cos", x => Math.Cos(x)));
     lookup.Add("exp", new Function("exp", x => Math.Exp(x)));
     lookup.Add("floor", new Function("floor", x => Math.Floor(x)));
     lookup.Add("log", new Function("log", x => Math.Log10(x)));
     lookup.Add("sin", new Function("sin", x => Math.Sin(x)));
     lookup.Add("sqrt", new Function("sqrt", x => Math.Sqrt(x)));
     lookup.Add("tan", new Function("tan", x => Math.Tan(x)));
     lookup.Add("truncate", new Function("truncate", x => Math.Truncate(x)));
 }
Beispiel #5
0
 /// <summary>
 /// Loads the file from the Assembly
 /// </summary>
 /// <param name="filename">The filename.</param>
 /// <param name="fileSource">The file source.</param>
 private void LoadFile(string filename, Assembly fileSource, string language)
 {
     using (var stream = fileSource.GetManifestResourceStream(filename))
     {
         using (var streamReader = new StreamReader(stream))
         {
             using (var jsonReader = new JsonTextReader(streamReader))
             {
                 LookupDictionary dictionary = Serializer.Deserialize <LookupDictionary>(jsonReader);
                 Translate.MergeDictionaries(language, dictionary);
             }
         }
     }
 }
Beispiel #6
0
        void ResetMinimap()
        {
            if (preservedRoomStates == null)
            {
                return;
            }

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

            preservedRoomStates = null;
        }
        public ItemUnlockingMap(Seed seed)
        {
            var random = new Random((int)seed.Id);

            unlockingSpecifications = new LookupDictionary <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.GasMask),
                new UnlockingSpecification(new ItemIdentifier(EInventoryRelicType.Tablet), R.Tablet),
                new UnlockingSpecification(new ItemIdentifier(EInventoryOrbType.Eye, EOrbSlot.Passive), R.OculusRift),
                new UnlockingSpecification(new ItemIdentifier(EInventoryFamiliarType.Kobo), R.Kobo),
                new UnlockingSpecification(new ItemIdentifier(EInventoryFamiliarType.MerchantCrow), R.MerchantCrow),
            };

            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);
        }
Beispiel #8
0
 private void FetchPropertyModels()
 {
     if (_propertyModels == null)
     {
         FetchPropertyList();
         _propertyModels = new LookupDictionary <Property, Property, BaseValueViewModel>(
             _propertyList,
             k => k,
             v =>
         {
             var result        = BaseValueViewModel.Fetch(ViewModelFactory, DataContext, this, v, v.GetPropertyValueModel(Object));
             result.IsReadOnly = IsReadOnly;
             return(result);
         });
     }
 }
        public void Should_generate_a_hundert_beatable_seeds()
        {
            var seeds = new LookupDictionary <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);
        }
Beispiel #10
0
        void MarkAvailableItemLocations()
        {
            preservedRoomStates = new LookupDictionary <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;
                    }
                }
            }
        }
 LowPriorityBinaryOperatorLookup(LookupDictionary <LowPriorityBinaryOperator> lookup)
     : base(lookup)
 {
     lookup.Add("+", new LowPriorityBinaryOperator("+", (x, y) => x + y));
     lookup.Add("-", new LowPriorityBinaryOperator("-", (x, y) => x - y));
 }
 private void FetchParameterModels()
 {
     if (_parameterModels == null)
     {
         FetchParameterList();
         _parameterModels = new LookupDictionary<BaseParameter, BaseParameter, BaseValueViewModel>(_parameterList, k => k, v =>
         {
             var result = BaseValueViewModel.Fetch(ViewModelFactory, DataContext, this, v, v.GetValueModel(DataContext, v.IsNullable));
             return result;
         });
     }
 }
 HighPriorityBinaryOperatorLookup(LookupDictionary <HighPriorityBinaryOperator> lookup)
     : base(lookup)
 {
     lookup.Add("^", new HighPriorityBinaryOperator("^", (x, y) => Math.Pow(x, y)));
 }
 protected Lookup(LookupDictionary <T> lookup)
 {
     _lookup = lookup;
 }
Beispiel #15
0
 private void FetchPropertyModels()
 {
     if (_propertyModels == null)
     {
         FetchPropertyList();
         _propertyModels = new LookupDictionary<Property, Property, BaseValueViewModel>(
             _propertyList,
             k => k,
             v =>
             {
                 var result = BaseValueViewModel.Fetch(ViewModelFactory, DataContext, this, v, v.GetPropertyValueModel(Object));
                 result.IsReadOnly = IsReadOnly;
                 return result;
             });
     }
 }
Beispiel #16
0
 private void Awake()
 {
     instance = this;
 }