private void CalculateDifficultyAndExpectValue(int height, string expectedValue, List <Block> blocks) { uint secondsPerBlockGoal = 15; int difficultyUpdateCycle = 10; var blockchain = blocks == null ? new Blockchain(_netId) : new Blockchain(blocks, _netId); var sut = new DifficultyCalculator(); var result = sut.CalculateDifficulty(blockchain, height, _protocol, secondsPerBlockGoal, difficultyUpdateCycle); Assert.AreEqual(expectedValue, result.ToString()); }
private void ProcessBeatmap() { // In a lazer implementation, DifficultyPoints would be a property of HitObjects so // there would be no need to recalculate the difficulty or do this messy sorting DifficultyCalculator calculator = new DifficultyCalculator(); calculator.SetBeatmap(_beatmap); calculator.SetMods(_mods); calculator.CalculateDifficulty(); foreach (DifficultyPoint diffPoint in calculator.Aiming.CalculatedPoints) { if (_remainingScoreObjects.Find(s => s.BaseObject == diffPoint.BaseObject) == null) { _remainingScoreObjects.Add(new ScoreObject(diffPoint.BaseObject)); } _remainingScoreObjects.Find(s => s.BaseObject == diffPoint.BaseObject).DifficultyPoints.Add(diffPoint); } foreach (DifficultyPoint diffPoint in calculator.Clicking.CalculatedPoints) { if (_remainingScoreObjects.Find(s => s.BaseObject == diffPoint.BaseObject) == null) { _remainingScoreObjects.Add(new ScoreObject(diffPoint.BaseObject)); } _remainingScoreObjects.Find(s => s.BaseObject == diffPoint.BaseObject).DifficultyPoints.Add(diffPoint); } foreach (DifficultyPoint diffPoint in calculator.Reading.CalculatedPoints) { if (_remainingScoreObjects.Find(s => s.BaseObject == diffPoint.BaseObject) == null) { _remainingScoreObjects.Add(new ScoreObject(diffPoint.BaseObject)); } _remainingScoreObjects.Find(s => s.BaseObject == diffPoint.BaseObject).DifficultyPoints.Add(diffPoint); } _remainingScoreObjects.OrderBy(s => s.BaseObject.Time); }