Less demanding test cases in TestUniformDistribution

Also a bug fix in the evaluation.
This commit is contained in:
Mike Spreitzer 2021-01-25 01:44:08 -05:00
parent 3433f099fb
commit 1f1e8e21d8

View File

@ -206,8 +206,7 @@ func TestUniformDistribution(t *testing.T) {
}{ }{
{64, 3, 1 << uint(math.Ceil(math.Log2(float64(ff(64, 3))))+spare)}, {64, 3, 1 << uint(math.Ceil(math.Log2(float64(ff(64, 3))))+spare)},
{128, 3, ff(128, 3)}, {128, 3, ff(128, 3)},
{128, 3, 3 * ff(128, 3)}, {50, 4, ff(50, 4)},
{70, 4, ff(70, 4)},
} }
for _, test := range tests { for _, test := range tests {
dealer, err := NewDealer(test.deckSize, test.handSize) dealer, err := NewDealer(test.deckSize, test.handSize)
@ -233,8 +232,9 @@ func TestUniformDistribution(t *testing.T) {
} }
handCoordinateMap[handCoordinate]++ handCoordinateMap[handCoordinate]++
} }
numHandsSeen := len(handCoordinateMap)
t.Logf("Deck size = %v, hand size = %v, number of possible hands = %d, number of hands seen = %d, number of deals = %d, expected count range = [%v, %v]", test.deckSize, test.handSize, allCoordinateCount, len(handCoordinateMap), test.hashMax, minCount, maxCount) t.Logf("Deck size = %v, hand size = %v, number of possible hands = %d, number of hands seen = %d, number of deals = %d, expected count range = [%v, %v]", test.deckSize, test.handSize, allCoordinateCount, numHandsSeen, test.hashMax, minCount, maxCount)
// histogram maps (count of times a hand is seen) to (number of hands having that count) // histogram maps (count of times a hand is seen) to (number of hands having that count)
histogram := make(map[int]int) histogram := make(map[int]int)
@ -247,10 +247,10 @@ func TestUniformDistribution(t *testing.T) {
goodSum += histogram[count] goodSum += histogram[count]
} }
goodPct := 100 * float64(goodSum) / float64(allCoordinateCount) goodPct := 100 * float64(goodSum) / float64(numHandsSeen)
t.Logf("good percentage = %v, histogram = %v", goodPct, histogram) t.Logf("good percentage = %v, histogram = %v", goodPct, histogram)
if goodSum != allCoordinateCount { if goodSum != numHandsSeen {
t.Errorf("Only %v percent of the hands got a central count", goodPct) t.Errorf("Only %v percent of the hands got a central count", goodPct)
} }
} }