Skip to content

Commit

Permalink
Sample from actual game data for random score differences
Browse files Browse the repository at this point in the history
  • Loading branch information
jvc56 committed Dec 5, 2024
1 parent 555f741 commit 2d2ce3a
Show file tree
Hide file tree
Showing 7 changed files with 750 additions and 89 deletions.
29 changes: 0 additions & 29 deletions pkg/pair/cop/cop.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,6 @@ type weightPolicy struct {
handler func(*policyArgs, int, int) int64
}

// Constraints and Weights:
// repeats
// - back to back
// - matchup repeats
// - total repeats
// - byes
// rank diff
// - one can cash
// - neither can cash
// pair with casher
// - can catch
// - cannot catch
// gibson - cashers
// - gibsons should not player cashers
// *** the following should be constraints:
// gibson - groups
// gibson - bye
// - gibsons should play byes first
// control loss
// koth
// prepaired

// Test logging:
// with and without bye
// with and without control loss

// FIXME: test class prizes

var constraintPolicies = []constraintPolicy{
{
// Prepaired players
Expand Down Expand Up @@ -581,7 +553,6 @@ func copMinWeightMatching(req *pb.PairRequest, copdata *copdatapkg.PrecompData,
}

if len(unpairedRankIdxes) > 0 {
// FIXME: add player names
msg := "COP pairings could not be completed because there were too many constraints. The unpaired players by rank index are:\n\n"
for idx, unpairedRankIdx := range unpairedRankIdxes {
msg += fmt.Sprintf("%d", unpairedRankIdx+1)
Expand Down
4 changes: 2 additions & 2 deletions pkg/pair/cop/cop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ func TestCOPConstraintPolicies(t *testing.T) {
req.PlayerClasses[0] = 1
req.PlayerClasses[1] = 1
req.PlayerClasses[4] = 1
req.PlayerClasses[9] = 1
req.PlayerClasses[2] = 1
req.PlayerClasses[5] = 1
req.PlayerClasses[8] = 1
resp = cop.COPPair(req)
Expand All @@ -651,7 +651,7 @@ func TestCOPConstraintPolicies(t *testing.T) {
// Control loss with player in 2nd
req = pairtestutils.CreateBellevilleCSWAfterRound12PairRequest()
req.UseControlLoss = true
req.Seed = 1
req.Seed = 2
resp = cop.COPPair(req)
is.Equal(resp.Pairings[0], int32(3))
is.Equal(resp.Pairings[3], int32(0))
Expand Down
6 changes: 3 additions & 3 deletions pkg/pair/copdata/copdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func GetPrecompData(req *pb.PairRequest, copRand *rand.Rand, logsb *strings.Buil

// Use the initial results to get a tighter bound on the maximum factor
initialFactor := int(req.Rounds) - len(req.DivisionResults)
initialSimResults := standings.SimFactorPairAll(req, copRand, int(req.DivisionSims), initialFactor, false, nil, logsb)
initialSimResults := standings.SimFactorPairAll(req, copRand, int(req.DivisionSims), initialFactor, false, nil)

writeFinalRankResultsToLog(fmt.Sprintf("Initial Sim Results (factor ceiling of %d)", initialFactor), initialSimResults.FinalRanks, standings, req, logsb)

Expand Down Expand Up @@ -80,7 +80,7 @@ func GetPrecompData(req *pb.PairRequest, copRand *rand.Rand, logsb *strings.Buil
// Only re-sim with the improved bound if it actually makes the max factor smaller
// for the highest gibson group.
if maxFactor*2 < numPlayersInhighestNongibsonGroup {
improvedFactorSimResults = standings.SimFactorPairAll(req, copRand, int(req.DivisionSims), maxFactor, false, initialSimResults.SegmentRoundFactors, logsb)
improvedFactorSimResults = standings.SimFactorPairAll(req, copRand, int(req.DivisionSims), maxFactor, false, initialSimResults.SegmentRoundFactors)
}

if improvedFactorSimResults == nil {
Expand All @@ -94,7 +94,7 @@ func GetPrecompData(req *pb.PairRequest, copRand *rand.Rand, logsb *strings.Buil
var allControlLosses map[int]int
highestControlLossRankIdx := -1
if req.UseControlLoss && !improvedFactorSimResults.GibsonizedPlayers[0] {
controlLossSimResults = standings.SimFactorPairAll(req, copRand, int(req.ControlLossSims), maxFactor, true, nil, logsb)
controlLossSimResults = standings.SimFactorPairAll(req, copRand, int(req.ControlLossSims), maxFactor, true, nil)
allControlLosses = controlLossSimResults.AllControlLosses
if controlLossSimResults.HighestControlLossRankIdx >= 0 &&
1.0-float64(controlLossSimResults.LowestFactorPairWins)/float64(req.ControlLossSims) >= req.ControlLossThreshold {
Expand Down
4 changes: 2 additions & 2 deletions pkg/pair/copdata/copdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestCOPPrecompData(t *testing.T) {
is.Equal(copdata.HighestRankHopefully[6], 3)
is.Equal(copdata.HighestRankAbsolutely[6], 3)
is.Equal(copdata.HighestRankHopefully[7], 4)
is.Equal(copdata.HighestRankAbsolutely[7], 3)
is.Equal(copdata.HighestRankAbsolutely[7], 4)
is.Equal(copdata.HighestRankHopefully[17], 9)
is.Equal(copdata.HighestRankAbsolutely[17], 7)
for _, group := range copdata.GibsonGroups {
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestCOPPrecompData(t *testing.T) {
is.Equal(copdata.HighestRankAbsolutely[rank], rank)
}
is.Equal(copdata.HighestRankHopefully[23], 16)
is.Equal(copdata.HighestRankAbsolutely[23], 14)
is.Equal(copdata.HighestRankAbsolutely[23], 15)
is.Equal(copdata.LowestRankAbsolutely[0], 0)
is.Equal(copdata.LowestRankAbsolutely[1], 1)
is.Equal(copdata.LowestRankAbsolutely[2], 9)
Expand Down
Loading

0 comments on commit 2d2ce3a

Please sign in to comment.