Closed Samasaur1 closed 5 years ago
The changelog still needs the date of this upcoming release — which hasn't been determined yet!
One of the Travis tests failed:
Test Case '-[DiceKitTests.DiceKitTests testRollable]' started.
/Users/travis/build/Samasaur1/DiceKit/Tests/DiceKitTests/DiceKitTests.swift:46: error: -[DiceKitTests.DiceKitTests testRollable] : XCTAssertGreaterThan failed: ("0.0") is not greater than ("0.0") -
Test Case '-[DiceKitTests.DiceKitTests testRollable]' failed (9.866 seconds).
Test Suite 'DiceKitTests' failed at 2019-07-03 16:05:58.532.
Executed 7 tests, with 1 failure (0 unexpected) in 9.894 (9.902) seconds
I don't know what type of Rollable it was that failed, but the probabilities
of the roll that was rolled was 0.0
— which should be impossible
Note that a much too large number of Travis build cases are stalling on testRollable()
. This clearly needs to be reworked — it can't be removed, because it has also failed, and I need to know how.
I'm having to restart basically every 1 out of 3 builds because of Travis thinking it stalled or it failing with Signal code 4
As of right now (I believe), any Travis build that says it has failed has actually failed because of testRollable()
, saying 0.0 is not greater than 0.0
, on the same line. It's happened across different versions of Swift and Xcode, on both macOS and Linux.
The next step obviously needs to be to find the problem causing this.
The PR and branch builds (a total of 12) errored 5 times. Five times — and they were all on testDiceRollable
. However, that's because of stalling, not the same failing error.
The (read: a) problem is in the getPartitions(ofSize:forTarget:)
function, which isn't returning (in this example) [25, 25, 4]
for getPartitions(ofSize: 3, forTarget: 54)
. There are other ones that should be returned and are not. This is just one example.
The Chance.+(_:_:)
function, here, can overflow on either the lnum
or rnum
multiplication operations. This occurs when the n
and/or d
properties are very large because of the double approximation initializer. Dividing before multiplying by lcm
does not work, as n/d
then becomes 0
.
static func + (lhs: Chance, rhs: Chance) -> Chance {
let lcm = Chance.lcm(lhs.d, rhs.d)
let lnum = lhs.n * lcm / lhs.d
let rnum = rhs.n * lcm / rhs.d
return (try? .init(lnum + rnum, outOf: lcm)) ?? .one
}
I'm not sure how to move forward on this.
This errored when calculating probabilities by running out of time, so that problem wasn't fixed...
I just added these memoize
functions, but we're basically doing that already
I think that last commit (7d4a172259167286603bbb7da9a00862549c5807) fixes all the Dice
timing out errors
Apparently 7fb5a024686c7b0fcac6ec496c13b0d6ec6ef2a6 broke Linux
Also, we're still getting the Chance.+(_:_:)
overflow problem, which may be causing the Signal code 4
error
That Double.random
call was something that no sane person (looks around guiltily) would blame me for — and it was in a test, so I feel fine in taking it out
I had stopped using the getRollable(die:)
method, but updated that instead of the actual way that the test generated a WeightedDie
There are 6 more tests that need to be implemented:
WeightedDieTests.testDoubleAverageResultProperty
WeightedDieTests.testAverageResultProperty
WeightedDieTests.testRollingMultipleTimes
DiceTests.testRolling
DiceTests.testRollingMultipleTimes
DiceTests.testChanceInRange
Notice that 5/6 of them should have been written before this version, because they don't test new features
The sixth one has been implemented, which leaves the 5 that already should have been. I'm going to leave those as stubs because they weren't introduced in this version
Here's what's new:
chance(of:_:)
function toRollable
and thechance(of:)
function toCustomDie
(closes #4, closes #60)probabilities
property toRollable
(closes #59)Rollable
to determine the chance of rolling in a range (closes #58)gcd(_:_:)
andlcm(_:_:)
functions toChance
+
,-
, and+=
operators toChance
normalized
property toChances
that proportionally scales everyChance
until the sum is 1 (closes #61)Here's what has to happen:
Since:
fields in the documentationgit checkout master
git pull
git tag -s v0.17.0 -m "Version 0.17.0: Chance and Probabilities"
git push --tags
git checkout development
git pull
git rebase master
git push