Esempio n. 1
0
        public void ApplyTerrainOverlayTranslation()
        {
            var grMap = new Generator(10, 10)
                        .AddSteps(DefaultAlgorithms.RectangleMapSteps())
                        .Generate()
                        .Context.GetFirstOrDefault <ISettableGridView <bool> >();

            TestUtils.NotNull(grMap);

            // Create map and apply overlay with a translation function
            var map = new Map(grMap.Width, grMap.Height, 1, Distance.Chebyshev);

            map.ApplyTerrainOverlay(grMap,
                                    (pos, b) =>
                                    b ?
                                    new GameObject(pos, 0)
                        : new GameObject(pos, 0, false, false));

            foreach (var pos in grMap.Positions())
            {
                var terrain = map.GetTerrainAt(pos);
                TestUtils.NotNull(terrain);
                Assert.Equal(grMap[pos], terrain.IsWalkable);
            }
        }
Esempio n. 2
0
        public CpuComputeDevice(int id, string group, string name, int threads, ulong affinityMask, int cpuCount)
            : base(id,
                   name,
                   true,
                   DeviceGroupType.CPU,
                   DeviceType.CPU,
                   string.Format(Translations.Tr("CPU#{0}"), cpuCount),
                   0)
        {
            Threads      = threads;
            AffinityMask = affinityMask;
            var uuid = GetUuid(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType);

            Uuid = uuid;
            AlgorithmSettings = DefaultAlgorithms.GetAlgorithmsForDevice(this);
            Index             = ID; // Don't increment for CPU

            _cpuCounter = new PerformanceCounter
            {
                CategoryName = "Processor",
                CounterName  = "% Processor Time",
                InstanceName = "_Total"
            };

            // plugin device
            var bd = new BaseDevice(DeviceType.CPU, uuid, name, ID);       // TODO UUID

            PluginDevice = new CPUDevice(bd, threads, true, affinityMask); // TODO hyperthreading
        }
Esempio n. 3
0
        public void XmrStakAlgorithmsForDevice_Tests()
        {
            var cpuDevice  = new CpuComputeDevice(0, "grp", "intel i7-8700k", 16, 0, 0);
            var algorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cpuDevice);

            Assert.AreEqual(3, algorithms.Count);

            foreach (var algorithm in algorithms) //check miner base type
            {
                Assert.AreEqual(MinerBaseType.XmrStak, algorithm.MinerBaseType);
            }

            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.CryptoNightHeavy,
                AlgorithmType.CryptoNightV8,
                AlgorithmType.CryptoNightR,
            };

            foreach (var secondaryAlgorithm in secondaryList) //check to see if all algorithms from secondary list are in algorithms
            {
                var algo = new Algorithm(MinerBaseType.XmrStak, secondaryAlgorithm);
                Assert.IsTrue(algorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
        }
        private static RogueLikeMap GenerateMap()
        {
            // Generate a rectangular map for the sake of testing with GoRogue's map generation system.
            var generator = new Generator(MapWidth, MapHeight)
                            .ConfigAndGenerateSafe(gen =>
            {
                gen.AddSteps(DefaultAlgorithms.RectangleMapSteps());
            });

            var generatedMap = generator.Context.GetFirst <ISettableGridView <bool> >("WallFloor");

            // Create a RogueLikeMap structure, specifying the appropriate viewport size for the default renderer
            RogueLikeMap map = new RogueLikeMap(MapWidth, MapHeight, new DefaultRendererParams((Width, Height)), 4, Distance.Manhattan);

            // Add a component that will implement a character "memory" system, where tiles will be dimmed when they aren't seen by the player,
            // and remain visible exactly as they were when the player last saw them regardless of changes to their actual appearance,
            // until the player sees them again.
            map.AllComponents.Add(new DimmingMemoryFieldOfViewHandler(0.6f));

            // Translate the GoRogue map generation context's information on the map to appropriate RogueLikeCells.  We must use MemoryAwareRogueLikeCells
            // because we are using the integration library's "memory-based" fov visibility system.
            foreach (var location in map.Positions())
            {
                bool walkable = generatedMap[location];
                int  glyph    = walkable ? '.' : '#';
                map.SetTerrain(new MemoryAwareRogueLikeCell(location, Color.White, Color.Black, glyph, 0, walkable, walkable));
            }

            return(map);
        }
Esempio n. 5
0
        //TODO fix constructor to not include 3rd party handles + refactor inside interface device info (lookup fans speed/temps/...)
        public CudaComputeDevice(CudaDevice cudaDevice, DeviceGroupType group, int gpuCount,
                                 NvPhysicalGpuHandle nvHandle, nvmlDevice nvmlHandle)
            : base((int)cudaDevice.DeviceID,
                   cudaDevice.GetName(),
                   true,
                   group,
                   DeviceType.NVIDIA,
                   string.Format(Translations.Tr("GPU#{0}"), gpuCount),
                   cudaDevice.DeviceGlobalMemory)
        {
            BusID             = cudaDevice.pciBusID;
            SMMajor           = cudaDevice.SM_major;
            SMMinor           = cudaDevice.SM_minor;
            Uuid              = cudaDevice.UUID;
            AlgorithmSettings = DefaultAlgorithms.GetAlgorithmsForDevice(this);
            Index             = ID + AvailableDevices.AvailCpus; // increment by CPU count

            _nvHandle   = nvHandle;
            _nvmlDevice = nvmlHandle;

            ShouldRunEthlargement = cudaDevice.DeviceName.Contains("1080") || cudaDevice.DeviceName.Contains("Titan Xp");
            // plugin device
            var bd = new BaseDevice(DeviceType.NVIDIA, cudaDevice.UUID, cudaDevice.GetName(), (int)cudaDevice.DeviceID);

            PluginDevice = new CUDADevice(bd, cudaDevice.pciBusID, cudaDevice.DeviceGlobalMemory, cudaDevice.SM_major, cudaDevice.SM_minor);
        }
Esempio n. 6
0
        public void GlobalSetup()
        {
            var map = new Generator(MapSize, MapSize)
                      .ConfigAndGenerateSafe(gen => gen.AddSteps(DefaultAlgorithms.RectangleMapSteps()))
                      .Context.GetFirst <IGridView <bool> >("WallFloor");

            var goalsBase =
                new LambdaTranslationGridView <bool, GoalState>(map, val => val ? GoalState.Clear : GoalState.Obstacle);

            var singleGoalView = new ArrayView <GoalState>(map.Width, map.Height);

            singleGoalView.ApplyOverlay(goalsBase);
            singleGoalView[map.Bounds().Center] = GoalState.Goal;

            _singleGoalMap = new GoalMap(singleGoalView, DistanceCalc);
            _singleFleeMap = new FleeMap(_singleGoalMap);

            var dualGoalView = new ArrayView <GoalState>(map.Width, map.Height);

            dualGoalView.ApplyOverlay(goalsBase);
            foreach (var rect in dualGoalView.Bounds().BisectVertically())
            {
                dualGoalView[rect.Center] = GoalState.Goal;
            }

            _dualGoalMap = new GoalMap(dualGoalView, DistanceCalc);
            _dualFleeMap = new FleeMap(_dualGoalMap);
        }
        //TODO fix constructor to not include 3rd party handles + refactor inside interface device info (lookup fans speed/temps/...)
        public CudaComputeDevice(CudaDevice cudaDevice, DeviceGroupType group, int gpuCount,
                                 NvPhysicalGpuHandle nvHandle, nvmlDevice nvmlHandle)
            : base((int)cudaDevice.DeviceID,
                   cudaDevice.GetName(),
                   true,
                   group,
                   DeviceType.NVIDIA,
                   string.Format(Translations.Tr("GPU#{0}"), gpuCount),
                   cudaDevice.DeviceGlobalMemory)
        {
            BusID   = cudaDevice.pciBusID;
            SMMajor = cudaDevice.SM_major;
            SMMinor = cudaDevice.SM_minor;
            // if no nvml loaded fallback ID
            if (string.IsNullOrEmpty(cudaDevice.UUID))
            {
                Uuid = GetUuid(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType);
            }
            else
            {
                Uuid = cudaDevice.UUID;
            }
            AlgorithmSettings = DefaultAlgorithms.GetAlgorithmsForDevice(this);
            Index             = ID + AvailableDevices.AvailCpus; // increment by CPU count

            _nvHandle   = nvHandle;
            _nvmlDevice = nvmlHandle;

            ShouldRunEthlargement = cudaDevice.DeviceName.Contains("1080") || cudaDevice.DeviceName.Contains("Titan Xp");
        }
        public AmdComputeDevice(AmdGpuDevice amdDevice, int gpuCount, bool isDetectionFallback, int adl2Index)
            : base(amdDevice.DeviceID,
                   amdDevice.DeviceName,
                   true,
                   DeviceGroupType.AMD_OpenCL,
                   DeviceType.AMD,
                   string.Format(Translations.Tr("GPU#{0}"), gpuCount),
                   amdDevice.DeviceGlobalMemory)
        {
            Uuid = isDetectionFallback
                ? GetUuid(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType)
                : amdDevice.Uuid;
            BusID              = amdDevice.BusID;
            Codename           = amdDevice.Codename;
            InfSection         = amdDevice.InfSection;
            AlgorithmSettings  = DefaultAlgorithms.GetAlgorithmsForDevice(this);
            DriverDisableAlgos = amdDevice.DriverDisableAlgos;
            Index              = ID + AvailableDevices.AvailCpus + AvailableDevices.AvailNVGpus;
            _adapterIndex      = amdDevice.Adl1Index;

            ADL.ADL2_Main_Control_Create?.Invoke(ADL.ADL_Main_Memory_Alloc, 0, ref _adlContext);
            _adapterIndex2 = adl2Index;

            // plugin device
            var bd = new BaseDevice(DeviceType.AMD, Uuid, Name, ID);

            PluginDevice = new AMDDevice(bd, amdDevice.BusID, amdDevice.DeviceGlobalMemory, Codename, InfSection);
        }
        public void GlobalSetup()
        {
            var map = new Generator(MapSize, MapSize)
                      .ConfigAndGenerateSafe(gen => gen.AddSteps(DefaultAlgorithms.RectangleMapSteps()))
                      .Context.GetFirst <IGridView <bool> >("WallFloor");

            var goalView = new ArrayView <GoalState>(map.Width, map.Height);

            goalView.ApplyOverlay(pos => map[pos] ? GoalState.Clear : GoalState.Obstacle);
            goalView[map.Bounds().Center] = GoalState.Goal;

            // Create the goal maps used as the desires.  They all use the same goals and weights, which in general is not
            // realistic, but will provide a mathematically solid test base nonetheless.
            var maps = new List <GoalMap>();

            for (int i = 0; i < NumGoalMaps; i++)
            {
                var desireMap = new GoalMap(goalView, DistanceCalc);
                maps.Add(desireMap);
            }

            // Create overall weighted goal map
            _desireMap = new WeightedGoalMap(maps);

            // Pre-calculate the point we'll access
            _threeQuarters = new Point(map.Width, map.Height) * 0.75;
        }
Esempio n. 10
0
        public void NBMinerAlgorithmsForDevice_tests()
        {
            var cudaDev       = cudaComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            List <Algorithm> nbminerAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.NBMiner)
                {
                    nbminerAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.GrinCuckaroo29,
                AlgorithmType.GrinCuckatoo31,
            };

            foreach (var primaryAlgorithm in secondaryList)
            {
                var algo = new Algorithm(MinerBaseType.NBMiner, primaryAlgorithm);
                Assert.IsTrue(nbminerAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
            Assert.AreEqual(2, nbminerAlgorithms.Count);
            foreach (var algo in nbminerAlgorithms)
            {
                Assert.IsTrue(algo.Enabled);
            }

            nbminerAlgorithms.Clear(); //low major
            cudaDev       = cudaComputeDevLowMajor();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.NBMiner)
                {
                    nbminerAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, nbminerAlgorithms.Count);

            nbminerAlgorithms.Clear(); //low ram
            cudaDev       = cudaComputeDevLowRam();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.NBMiner)
                {
                    nbminerAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, nbminerAlgorithms.Count);
        }
Esempio n. 11
0
        private void CreateSenseMap()
        {
            // Create sense map of rectangular area
            var wallFloor = new Generator(MapSize, MapSize)
                            .ConfigAndGenerateSafe(gen => gen.AddSteps(DefaultAlgorithms.RectangleMapSteps()))
                            .Context.GetFirst <IGridView <bool> >("WallFloor");

            var resMap = new ArrayView <double>(wallFloor.Width, wallFloor.Height);

            resMap.ApplyOverlay(pos => wallFloor[pos] ? 0.0 : 1.0);
            _senseMap = new SenseMap(resMap);
        }
Esempio n. 12
0
        public void ClaymoreDualAlgorithmsForDevice_Tests()
        {
            var device        = cudaComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(device);
            List <Algorithm> claymoreAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.Claymore)
                {
                    claymoreAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.NONE,
                AlgorithmType.Decred,
                AlgorithmType.Blake2s,
                AlgorithmType.Keccak,
            };

            foreach (var secondaryAlgorithm in secondaryList) //check to see if all algorithms from secondary list are in algorithms (dual with dager)
            {
                var algo = new Algorithm(MinerBaseType.Claymore, secondaryAlgorithm);
                Assert.IsTrue(claymoreAlgorithms.Any(a => algo.NiceHashID == a.SecondaryNiceHashID));
            }

            foreach (var algorithm in claymoreAlgorithms)
            {
                if (algorithm.SecondaryNiceHashID == AlgorithmType.NONE) //check that all duals are disabled by default
                {
                    Assert.IsTrue(algorithm.Enabled);
                }
                else
                {
                    Assert.IsFalse(algorithm.Enabled);
                }
            }

            claymoreAlgorithms.Clear();
            device        = cudaComputeDevLowMajor();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(device);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.Claymore)
                {
                    claymoreAlgorithms.Add(algorithm);
                }
            }

            Assert.AreEqual(0, claymoreAlgorithms.Count);
        }
Esempio n. 13
0
        public void ethminerAlgorithmsForDevice_tests()
        {
            var cudaDev       = cudaComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            List <Algorithm> ethminerAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.ethminer)
                {
                    ethminerAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.DaggerHashimoto,
            };

            foreach (var primaryAlgorithm in secondaryList)
            {
                var algo = new Algorithm(MinerBaseType.ethminer, primaryAlgorithm);
                Assert.IsTrue(ethminerAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
            Assert.AreEqual(1, ethminerAlgorithms.Count);
            Assert.IsFalse(ethminerAlgorithms[0].Enabled);

            ethminerAlgorithms.Clear(); //low major
            cudaDev       = cudaComputeDevLowMajor();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.ethminer)
                {
                    ethminerAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, ethminerAlgorithms.Count);

            ethminerAlgorithms.Clear(); //750 ti
            cudaDev       = cudaComputeDev750Ti();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.ethminer)
                {
                    ethminerAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, ethminerAlgorithms.Count);
        }
Esempio n. 14
0
        public void ApplyTerrainOverlayPositions()
        {
            var grMap = new Generator(10, 10)
                        .AddSteps(DefaultAlgorithms.RectangleMapSteps())
                        .Generate()
                        .Context.GetFirstOrDefault <ISettableGridView <bool> >();

            TestUtils.NotNull(grMap);

            // Create map and apply overlay with a translation function
            var map = new Map(grMap.Width, grMap.Height, 1, Distance.Chebyshev);

            map.ApplyTerrainOverlay(grMap,
                                    (pos, b) =>
                                    b ?
                                    new GameObject(pos, 0)
                        : new GameObject(pos, 0, true, false));

            // Assert all objects are at right position to start with
            foreach (var pos in grMap.Positions())
            {
                var terrain = map.GetTerrainAt(pos);
                TestUtils.NotNull(terrain);

                Assert.Equal(pos, terrain.Position);
            }

            // Rearrange positions by mirror-imaging in X/Y
            var terrainMap2 = new ArrayView <IGameObject>(map.Width, map.Height);

            foreach (var(x, y) in map.Positions())
            {
                var terrain = map.GetTerrainAt(x, y);
                TestUtils.NotNull(terrain);
                terrainMap2[map.Width - 1 - x, map.Height - 1 - y] = terrain;
            }

            // Apply overlay, hopefully adapting positions properly
            map.ApplyTerrainOverlay(terrainMap2);

            foreach (var pos in grMap.Positions())
            {
                var terrain = map.GetTerrainAt(pos);
                TestUtils.NotNull(terrain);

                Assert.Equal(pos, terrain.Position);
            }
        }
Esempio n. 15
0
        public void GlobalSetup()
        {
            // Center FOV in middle of open map
            _center = (MapWidth / 2, MapHeight / 2);

            // Generate rectangular map
            var gen = new Generator(MapWidth, MapHeight);

            gen.ConfigAndGenerateSafe(g => g.AddSteps(DefaultAlgorithms.RectangleMapSteps()));

            // Extract wall-floor map which we can use as transparency view
            var transparencyView = gen.Context.GetFirst <IGridView <bool> >("WallFloor");

            // Create FOV structure to use
            _fov = new RecursiveShadowcastingFOV(transparencyView);
        }
Esempio n. 16
0
        public void GlobalSetup()
        {
            var map = new Generator(PathDistance + 5, PathDistance + 5)
                      .ConfigAndGenerateSafe(gen => gen.AddSteps(DefaultAlgorithms.RectangleMapSteps()))
                      .Context.GetFirst <IGridView <bool> >("WallFloor");

            // A couple points exactly PathDistance apart.  We keep the paths on the same y-line so that they are
            // PathDistance apart regardless of the DistanceCalc.
            // Path performance checks will independently path both from p1 to p2 and from p2 to p1, in order to
            // account for one direction likely being faster (first direction checked in the neighbors loop)
            _p1 = (1, 5);
            _p2 = (PathDistance + 1, 5);

            // An AStar instance to use for pathing
            _aStar = new GoRogue.Pathing.AStar(map, DistanceCalc);

            // Equivalent FastAStar instance
            _fastAStar = new FastAStar(map, DistanceCalc);
        }
Esempio n. 17
0
        public void GlobalSetup()
        {
            // Use GoRogue map generation to generate terrain data
            var wallFloor = new Generator(Size, Size)
                            .ConfigAndGenerateSafe(gen => gen.AddSteps(DefaultAlgorithms.RectangleMapSteps()))
                            .Context.GetFirst <IGridView <bool> >("WallFloor");

            // Create real map and apply terrain
            _map = new Map(Size, Size, NumEntityLayers, Distance.Chebyshev);
            _map.ApplyTerrainOverlay(wallFloor, (pos, val) => new GameObject(pos, 0, val, val));

            // Spawn correct number of entities
            float spawnRegion = (float)Size - 2; // Range (1, width - 1)
            float increment   = spawnRegion / NumEntitySpawnLocations;

            int spawns = 0;

            for (float i = increment; i < Size - 1; i += increment)
            {
                int val      = (int)i;
                var position = new Point(val, val);
                for (int j = 0; j < NumEntitiesPerLocation; j++)
                {
                    var entity = new GameObject(position, j % NumEntityLayers + 1, j != 0);
                    _map.AddEntity(entity);
                }

                // Record two positions (with and without entities) we can test against
                _positionWithEntities    = position;
                _positionWithoutEntities = position - 1;

                // Sanity check
                spawns++;
            }

            if (spawns != NumEntitySpawnLocations)
            {
                throw new Exception($"Incorrect number of entity spawn locations.  Got: {spawns}, but wanted: {NumEntitySpawnLocations}");
            }

            // Record center for caching purposes
            _center = _map.Bounds().Center;
        }
Esempio n. 18
0
        public void TTMinerAlgorithmsForDevice_tests()
        {
            var cudaDev       = cudaComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            List <Algorithm> ttminerAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.TTMiner)
                {
                    ttminerAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.MTP,
                AlgorithmType.Lyra2REv3,
            };

            foreach (var primaryAlgorithm in secondaryList)
            {
                var algo = new Algorithm(MinerBaseType.TTMiner, primaryAlgorithm);
                Assert.IsTrue(ttminerAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
            Assert.AreEqual(2, ttminerAlgorithms.Count);
            foreach (var algo in ttminerAlgorithms)
            {
                Assert.IsFalse(algo.Enabled);
            }

            ttminerAlgorithms.Clear(); //low major
            cudaDev       = cudaComputeDevLowMajor();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.TTMiner)
                {
                    ttminerAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, ttminerAlgorithms.Count);
        }
Esempio n. 19
0
        public void ProspectorAlgorithmsForDevice_tests()
        {
            var openCLDevice  = amdComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(openCLDevice);
            List <Algorithm> prospectorAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.Prospector)
                {
                    prospectorAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.Skunk,
            };

            foreach (var primaryAlgorithm in secondaryList)
            {
                var algo = new Algorithm(MinerBaseType.Prospector, primaryAlgorithm);
                Assert.IsTrue(prospectorAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
            Assert.AreEqual(1, prospectorAlgorithms.Count);
            Assert.IsFalse(prospectorAlgorithms[0].Enabled);

            prospectorAlgorithms.Clear(); //cuda device
            var cudaDevice = cudaComputeDev();

            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDevice);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.Prospector)
                {
                    prospectorAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, prospectorAlgorithms.Count);
        }
        public static MyGameMap GenerateDungeonMap(int width, int height)
        {
            // Generate a rectangular map for the sake of testing with GoRogue's map generation system.
            //
            // CUSTOMIZATION: Use a different set steps in AddSteps to generate a different type of map.
            var generator = new Generator(width, height)
                            .ConfigAndGenerateSafe(gen =>
            {
                gen.AddSteps(DefaultAlgorithms.RectangleMapSteps());
            });

            var generatedMap = generator.Context.GetFirst <ISettableGridView <bool> >("WallFloor");

            // Create actual integration library map.
            var map = new MyGameMap(generator.Context.Width, generator.Context.Height, null);

            // Add a component that will implement a character "memory" system, where tiles will be dimmed when they aren't seen by the player,
            // and remain visible exactly as they were when the player last saw them regardless of changes to their actual appearance,
            // until the player sees them again.
            //
            // CUSTOMIZATION: If you want to handle FOV visibility differently, you can create an instance of one of the
            // other classes in the FieldOfView namespace, or create your own by inheriting from FieldOfViewHandlerBase
            map.AllComponents.Add(new DimmingMemoryFieldOfViewHandler(0.6f));

            // Translate GoRogue's terrain data into actual integration library objects.  Our terrain must be of type
            // MemoryAwareRogueLikeCells because we are using the integration library's "memory-based" fov visibility
            // system.
            map.ApplyTerrainOverlay(generatedMap, (pos, val) => val ? MapObjectFactory.Floor(pos) : MapObjectFactory.Wall(pos));

            // Generate 10 enemies, placing them in random walkable locations for demo purposes.
            for (int i = 0; i < 10; i++)
            {
                var enemy = MapObjectFactory.Enemy();
                enemy.Position = map.WalkabilityView.RandomPosition(true);
                map.AddEntity(enemy);
            }

            return(map);
        }
Esempio n. 21
0
        public void EWBFAlgorithmsForDevice_tests()
        {
            var cudaDev       = cudaComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            List <Algorithm> ewbfAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.EWBF)
                {
                    ewbfAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.ZHash,
            };

            foreach (var primaryAlgorithm in secondaryList)
            {
                var algo = new Algorithm(MinerBaseType.EWBF, primaryAlgorithm);
                Assert.IsTrue(ewbfAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
            Assert.AreEqual(1, ewbfAlgorithms.Count);
            Assert.IsTrue(ewbfAlgorithms[0].Enabled);

            ewbfAlgorithms.Clear(); //low major
            cudaDev       = cudaComputeDevLowMajor();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.EWBF)
                {
                    ewbfAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, ewbfAlgorithms.Count);
        }
Esempio n. 22
0
        public void trexAlgorithmsForDevice_tests()
        {
            var cudaDev       = cudaComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            List <Algorithm> trexAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.trex)
                {
                    trexAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.Skunk,
                AlgorithmType.X16R,
            };

            foreach (var primaryAlgorithm in secondaryList)
            {
                var algo = new Algorithm(MinerBaseType.trex, primaryAlgorithm);
                Assert.IsTrue(trexAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
            Assert.AreEqual(2, trexAlgorithms.Count);

            trexAlgorithms.Clear(); //low major
            cudaDev       = cudaComputeDevLowMajor();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.trex)
                {
                    trexAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, trexAlgorithms.Count);
        }
Esempio n. 23
0
 public void SetAlgorithmDeviceConfig(DeviceBenchmarkConfig config)
 {
     if (config != null && config.DeviceUUID == Uuid && config.AlgorithmSettings != null)
     {
         AlgorithmSettings = DefaultAlgorithms.GetAlgorithmsForDevice(this);
         foreach (var conf in config.AlgorithmSettings)
         {
             var setAlgo = GetAlgorithm(conf.MinerBaseType, conf.NiceHashID, conf.SecondaryNiceHashID);
             if (setAlgo != null)
             {
                 setAlgo.BenchmarkSpeed        = conf.BenchmarkSpeed;
                 setAlgo.ExtraLaunchParameters = conf.ExtraLaunchParameters;
                 setAlgo.Enabled     = conf.Enabled;
                 setAlgo.LessThreads = conf.LessThreads;
                 setAlgo.PowerUsage  = conf.PowerUsage;
                 if (setAlgo is DualAlgorithm dualSA)
                 {
                     dualSA.SecondaryBenchmarkSpeed = conf.SecondaryBenchmarkSpeed;
                     var dualConf = config.DualAlgorithmSettings?.Find(a =>
                                                                       a.SecondaryNiceHashID == dualSA.SecondaryNiceHashID);
                     if (dualConf != null)
                     {
                         dualConf.FixSettingsBounds();
                         dualSA.IntensitySpeeds          = dualConf.IntensitySpeeds;
                         dualSA.SecondaryIntensitySpeeds = dualConf.SecondaryIntensitySpeeds;
                         dualSA.TuningEnabled            = dualConf.TuningEnabled;
                         dualSA.TuningStart        = dualConf.TuningStart;
                         dualSA.TuningEnd          = dualConf.TuningEnd;
                         dualSA.TuningInterval     = dualConf.TuningInterval;
                         dualSA.IntensityPowers    = dualConf.IntensityPowers;
                         dualSA.UseIntensityPowers = dualConf.UseIntensityPowers;
                     }
                 }
             }
         }
     }
 }
Esempio n. 24
0
        public void ApplyTerrainOverlay()
        {
            var grMap = new Generator(10, 10)
                        .AddSteps(DefaultAlgorithms.RectangleMapSteps())
                        .Generate()
                        .Context.GetFirstOrDefault <ISettableGridView <bool> >();

            TestUtils.NotNull(grMap);

            // Normally, in this situation, you would just use the ApplyTerrainOverlay function overload that takes
            // a translation function, instead of creating tempMap and translationMap.  But we want to test the other
            // overload so we do it this way only for testing
            var translationMap = new LambdaTranslationGridView <bool, IGameObject>(grMap,
                                                                                   (pos, val) =>
                                                                                   val ?
                                                                                   new GameObject(pos, 0)
                        : new GameObject(pos, 0, true, false));

            // Create map
            var map = new Map(grMap.Width, grMap.Height, 1, Distance.Chebyshev);

            // Create temporary map to record what values are supposed to be
            var tempMap = new ArrayView <IGameObject>(grMap.Width, grMap.Height);

            tempMap.ApplyOverlay(translationMap);

            // Apply overlay
            map.ApplyTerrainOverlay(tempMap);

            // Verify tiles match
            Assert.Equal(grMap.Width, map.Width);
            Assert.Equal(grMap.Height, map.Height);
            foreach (var pos in map.Positions())
            {
                Assert.Equal(tempMap[pos], map.GetTerrainAt(pos));
            }
        }
Esempio n. 25
0
        public void PhoenixAlgorithmsForDevice_Tests()
        {
            var device        = cudaComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(device);
            List <Algorithm> phoenixAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.Phoenix)
                {
                    phoenixAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.DaggerHashimoto,
            };

            foreach (var secondaryAlgorithm in secondaryList) //check to see if all algorithms from secondary list are in algorithms (dual with dager)
            {
                var algo = new Algorithm(MinerBaseType.Phoenix, secondaryAlgorithm);
                Assert.IsTrue(phoenixAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }

            phoenixAlgorithms.Clear();
            device        = cudaComputeDevLowMajor();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(device);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.Phoenix)
                {
                    phoenixAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, phoenixAlgorithms.Count);
        }
Esempio n. 26
0
        private static RogueLikeMap GenerateMap()
        {
            // Generate a rectangular map for the sake of testing.
            var generator = new Generator(MapWidth, MapHeight)
                            .ConfigAndGenerateSafe(gen =>
            {
                gen.AddSteps(DefaultAlgorithms.RectangleMapSteps());
            });

            var generatedMap = generator.Context.GetFirst <ISettableGridView <bool> >("WallFloor");

            RogueLikeMap map = new RogueLikeMap(MapWidth, MapHeight, new DefaultRendererParams((Width, Height)), 4, Distance.Manhattan);

            map.AllComponents.Add(new DimmingMemoryFieldOfViewHandler(0.6f));

            foreach (var location in map.Positions())
            {
                bool walkable = generatedMap[location];
                int  glyph    = walkable ? '.' : '#';
                map.SetTerrain(new MemoryAwareRogueLikeCell(location, Color.White, Color.Black, glyph, 0, walkable, walkable));
            }

            return(map);
        }
 /// <inheritdoc />
 protected override IEnumerable <GenerationStep> GenerationSteps()
 => DefaultAlgorithms.CellularAutomataGenerationSteps();
Esempio n. 28
0
 /// <inheritdoc />
 protected override IEnumerable <GenerationStep> GenerationSteps()
 => DefaultAlgorithms.BasicRandomRoomsMapSteps();
Esempio n. 29
0
        public void BMinerAlgorithmsForDevice_tests()
        {
            var cudaDev       = cudaComputeDev();
            var allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            List <Algorithm> bminerAlgorithms = new List <Algorithm>();

            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.BMiner)
                {
                    bminerAlgorithms.Add(algorithm);
                }
            }
            var secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.ZHash,
                AlgorithmType.DaggerHashimoto,
                AlgorithmType.Beam,
                AlgorithmType.GrinCuckaroo29,
            };

            foreach (var primaryAlgorithm in secondaryList)
            {
                var algo = new Algorithm(MinerBaseType.BMiner, primaryAlgorithm);
                Assert.IsTrue(bminerAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
            Assert.AreEqual(4, bminerAlgorithms.Count);
            foreach (var algo in bminerAlgorithms)
            {
                Assert.IsFalse(algo.Enabled);
            }

            bminerAlgorithms.Clear(); //low ram
            cudaDev       = cudaComputeDevLowRam();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.BMiner)
                {
                    bminerAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(1, bminerAlgorithms.Count);
            Assert.AreEqual(AlgorithmType.ZHash, bminerAlgorithms[0].NiceHashID);

            bminerAlgorithms.Clear(); //low major
            cudaDev       = cudaComputeDevLowMajor();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(cudaDev);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.BMiner)
                {
                    bminerAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, bminerAlgorithms.Count);

            bminerAlgorithms.Clear(); //amd device
            var openCLDevice = amdComputeDev();

            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(openCLDevice);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.BMiner)
                {
                    bminerAlgorithms.Add(algorithm);
                }
            }
            secondaryList = new List <AlgorithmType>
            {
                AlgorithmType.Beam,
            };
            foreach (var primaryAlgorithm in secondaryList)
            {
                var algo = new Algorithm(MinerBaseType.BMiner, primaryAlgorithm);
                Assert.IsTrue(bminerAlgorithms.Any(a => algo.NiceHashID == a.NiceHashID));
            }
            Assert.AreEqual(1, bminerAlgorithms.Count);
            Assert.AreEqual(AlgorithmType.Beam, bminerAlgorithms[0].NiceHashID);

            bminerAlgorithms.Clear(); //amd low gcn
            openCLDevice  = amdComputeDevLowGCN();
            allAlgorithms = DefaultAlgorithms.GetAlgorithmsForDevice(openCLDevice);
            foreach (var algorithm in allAlgorithms)
            {
                if (algorithm.MinerBaseType == MinerBaseType.BMiner)
                {
                    bminerAlgorithms.Add(algorithm);
                }
            }
            Assert.AreEqual(0, bminerAlgorithms.Count);
        }
 /// <inheritdoc />
 protected override IEnumerable <GenerationStep> GenerationSteps()
 => DefaultAlgorithms.DungeonMazeMapSteps();