当前位置: 首页>>代码示例>>Golang>>正文


Golang Calc.CalcNewRatings方法代码示例

本文整理汇总了Golang中github.com/ChrisHines/GoSkills/skills.Calc.CalcNewRatings方法的典型用法代码示例。如果您正苦于以下问题:Golang Calc.CalcNewRatings方法的具体用法?Golang Calc.CalcNewRatings怎么用?Golang Calc.CalcNewRatings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/ChrisHines/GoSkills/skills.Calc的用法示例。


在下文中一共展示了Calc.CalcNewRatings方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: OneOnSevenSimpleTest

func OneOnSevenSimpleTest(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, gameInfo.DefaultRating())

	team2 := skills.NewTeam()
	team2.AddPlayer(2, gameInfo.DefaultRating())
	team2.AddPlayer(3, gameInfo.DefaultRating())
	team2.AddPlayer(4, gameInfo.DefaultRating())
	team2.AddPlayer(5, gameInfo.DefaultRating())
	team2.AddPlayer(6, gameInfo.DefaultRating())
	team2.AddPlayer(7, gameInfo.DefaultRating())
	team2.AddPlayer(8, gameInfo.DefaultRating())

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 2)

	// Winners
	AssertRating(t, 40.582, 7.917, newRatings[1])

	// Losers
	AssertRating(t, 9.418, 7.917, newRatings[2])
	AssertRating(t, 9.418, 7.917, newRatings[3])
	AssertRating(t, 9.418, 7.917, newRatings[4])
	AssertRating(t, 9.418, 7.917, newRatings[5])
	AssertRating(t, 9.418, 7.917, newRatings[6])
	AssertRating(t, 9.418, 7.917, newRatings[7])
	AssertRating(t, 9.418, 7.917, newRatings[8])

	AssertMatchQuality(t, 0.000, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:33,代码来源:Calc_test.go

示例2: FourOnFourSimpleTest

func FourOnFourSimpleTest(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, gameInfo.DefaultRating())
	team1.AddPlayer(2, gameInfo.DefaultRating())
	team1.AddPlayer(3, gameInfo.DefaultRating())
	team1.AddPlayer(4, gameInfo.DefaultRating())

	team2 := skills.NewTeam()
	team2.AddPlayer(5, gameInfo.DefaultRating())
	team2.AddPlayer(6, gameInfo.DefaultRating())
	team2.AddPlayer(7, gameInfo.DefaultRating())
	team2.AddPlayer(8, gameInfo.DefaultRating())

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 2)

	// Winners
	AssertRating(t, 27.198, 8.059, newRatings[1])
	AssertRating(t, 27.198, 8.059, newRatings[2])
	AssertRating(t, 27.198, 8.059, newRatings[3])
	AssertRating(t, 27.198, 8.059, newRatings[4])

	// Losers
	AssertRating(t, 22.802, 8.059, newRatings[5])
	AssertRating(t, 22.802, 8.059, newRatings[6])
	AssertRating(t, 22.802, 8.059, newRatings[7])
	AssertRating(t, 22.802, 8.059, newRatings[8])

	AssertMatchQuality(t, 0.447, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:33,代码来源:Calc_test.go

示例3: OneOnThreeDrawTest

func OneOnThreeDrawTest(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, gameInfo.DefaultRating())

	team2 := skills.NewTeam()
	team2.AddPlayer(2, gameInfo.DefaultRating())
	team2.AddPlayer(3, gameInfo.DefaultRating())
	team2.AddPlayer(4, gameInfo.DefaultRating())

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 1)

	// Winners
	AssertRating(t, 34.990, 7.455, newRatings[1])

	// Losers
	AssertRating(t, 15.010, 7.455, newRatings[2])
	AssertRating(t, 15.010, 7.455, newRatings[3])
	AssertRating(t, 15.010, 7.455, newRatings[4])

	AssertMatchQuality(t, 0.012, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:25,代码来源:Calc_test.go

示例4: TwoOnTwoUpsetTest

func TwoOnTwoUpsetTest(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, skills.NewRating(20, 8))
	team1.AddPlayer(2, skills.NewRating(25, 6))

	team2 := skills.NewTeam()
	team2.AddPlayer(3, skills.NewRating(35, 7))
	team2.AddPlayer(4, skills.NewRating(40, 5))

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 2)

	// Winners
	AssertRating(t, 29.698, 7.008, newRatings[1])
	AssertRating(t, 30.455, 5.594, newRatings[2])

	// Losers
	AssertRating(t, 27.575, 6.346, newRatings[3])
	AssertRating(t, 36.211, 4.768, newRatings[4])

	AssertMatchQuality(t, 0.084, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:25,代码来源:Calc_test.go

示例5: TwoOnTwoUnbalancedDrawTest

func TwoOnTwoUnbalancedDrawTest(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, skills.NewRating(15, 8))
	team1.AddPlayer(2, skills.NewRating(20, 6))

	team2 := skills.NewTeam()
	team2.AddPlayer(3, skills.NewRating(25, 4))
	team2.AddPlayer(4, skills.NewRating(30, 3))

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 1)

	// Winners
	AssertRating(t, 21.570, 6.556, newRatings[1])
	AssertRating(t, 23.696, 5.418, newRatings[2])

	// Losers
	AssertRating(t, 23.357, 3.833, newRatings[3])
	AssertRating(t, 29.075, 2.931, newRatings[4])

	AssertMatchQuality(t, 0.214, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:25,代码来源:Calc_test.go

示例6: TwoOnTwoSimpleTest

func TwoOnTwoSimpleTest(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, gameInfo.DefaultRating())
	team1.AddPlayer(2, gameInfo.DefaultRating())

	team2 := skills.NewTeam()
	team2.AddPlayer(3, gameInfo.DefaultRating())
	team2.AddPlayer(4, gameInfo.DefaultRating())

	teams := []skills.Team{team2, team1}

	ranks := []int{2, 1}
	newRatings := calc.CalcNewRatings(gameInfo, teams, ranks...)
	if ranks[0] != 2 {
		t.Errorf("client ranks slice reordered")
	}

	// Winners
	AssertRating(t, 28.108, 7.774, newRatings[1])
	AssertRating(t, 28.108, 7.774, newRatings[2])

	// Losers
	AssertRating(t, 21.892, 7.774, newRatings[3])
	AssertRating(t, 21.892, 7.774, newRatings[4])

	AssertMatchQuality(t, 0.447, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:29,代码来源:Calc_test.go

示例7: TwoPlayerChessTestNotDrawn

func TwoPlayerChessTestNotDrawn(t *testing.T, calc skills.Calc) {
	// Inspired by a real bug :-)
	gameInfo := &skills.GameInfo{
		InitialMean:     1200,
		InitialStddev:   1200 / 3,
		Beta:            200,
		DynamicsFactor:  1200 / 300,
		DrawProbability: 0.03,
	}

	team1 := skills.NewTeam()
	team1.AddPlayer(1, skills.NewRating(1301.0007, 42.9232))

	team2 := skills.NewTeam()
	team2.AddPlayer(2, skills.NewRating(1188.7560, 42.5570))

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 2)

	player1NewRating := newRatings[1]
	AssertRating(t, 1304.7820836053318, 42.843513887848658, player1NewRating)

	player2NewRating := newRatings[2]
	AssertRating(t, 1185.0383099003536, 42.485604606897752, player2NewRating)
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:26,代码来源:Calc_test.go

示例8: TwoPlayerTestDrawn

func TwoPlayerTestDrawn(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, gameInfo.DefaultRating())

	team2 := skills.NewTeam()
	team2.AddPlayer(2, gameInfo.DefaultRating())

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 1)

	player1NewRating := newRatings[1]
	AssertRating(t, 25.0, 6.4575196623173081, player1NewRating)

	player2NewRating := newRatings[2]
	AssertRating(t, 25.0, 6.4575196623173081, player2NewRating)
	AssertMatchQuality(t, 0.447, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:20,代码来源:Calc_test.go

示例9: OneOnOneMassiveUpsetDrawTest

func OneOnOneMassiveUpsetDrawTest(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, gameInfo.DefaultRating())

	team2 := skills.NewTeam()
	team2.AddPlayer(2, skills.NewRating(50, 12.5))

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 1)

	player1NewRating := newRatings[1]
	AssertRating(t, 31.662, 7.137, player1NewRating)

	player2NewRating := newRatings[2]
	AssertRating(t, 35.010, 7.910, player2NewRating)
	AssertMatchQuality(t, 0.110, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:20,代码来源:Calc_test.go

示例10: ThreeOnTwoTests

func ThreeOnTwoTests(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, skills.NewRating(28, 7))
	team1.AddPlayer(2, skills.NewRating(27, 6))
	team1.AddPlayer(3, skills.NewRating(26, 5))

	team2 := skills.NewTeam()
	team2.AddPlayer(4, skills.NewRating(30, 4))
	team2.AddPlayer(5, skills.NewRating(31, 3))

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 2)

	// Winners
	AssertRating(t, 28.658, 6.770, newRatings[1])
	AssertRating(t, 27.484, 5.856, newRatings[2])
	AssertRating(t, 26.336, 4.917, newRatings[3])

	// Losers
	AssertRating(t, 29.785, 3.958, newRatings[4])
	AssertRating(t, 30.879, 2.983, newRatings[5])

	newRatings = calc.CalcNewRatings(gameInfo, teams, 2, 1)

	// Losers
	AssertRating(t, 21.840, 6.314, newRatings[1])
	AssertRating(t, 22.474, 5.575, newRatings[2])
	AssertRating(t, 22.857, 4.757, newRatings[3])

	// Winners
	AssertRating(t, 32.012, 3.877, newRatings[4])
	AssertRating(t, 32.132, 2.949, newRatings[5])

	AssertMatchQuality(t, 0.254, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:38,代码来源:Calc_test.go

示例11: OneOnTwoDrawTest

func OneOnTwoDrawTest(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, gameInfo.DefaultRating())

	team2 := skills.NewTeam()
	team2.AddPlayer(2, gameInfo.DefaultRating())
	team2.AddPlayer(3, gameInfo.DefaultRating())

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 1)

	// Winners
	AssertRating(t, 31.660, 7.138, newRatings[1])

	// Losers
	AssertRating(t, 18.340, 7.138, newRatings[2])
	AssertRating(t, 18.340, 7.138, newRatings[3])

	AssertMatchQuality(t, 0.135, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:23,代码来源:Calc_test.go

示例12: OneOnTwoSomewhatBalanced

func OneOnTwoSomewhatBalanced(t *testing.T, calc skills.Calc) {
	gameInfo := skills.DefaultGameInfo

	team1 := skills.NewTeam()
	team1.AddPlayer(1, skills.NewRating(40, 6))

	team2 := skills.NewTeam()
	team2.AddPlayer(2, skills.NewRating(20, 7))
	team2.AddPlayer(3, skills.NewRating(25, 8))

	teams := []skills.Team{team1, team2}

	newRatings := calc.CalcNewRatings(gameInfo, teams, 1, 2)

	// Winners
	AssertRating(t, 42.744, 5.602, newRatings[1])

	// Losers
	AssertRating(t, 16.266, 6.359, newRatings[2])
	AssertRating(t, 20.123, 7.028, newRatings[3])

	AssertMatchQuality(t, 0.478, calc.CalcMatchQual(gameInfo, teams))
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:23,代码来源:Calc_test.go

示例13: TwoPlayerTestNotDrawn

func TwoPlayerTestNotDrawn(t *testing.T, calc skills.Calc) {
	Convey("Using default game info", t, func() {
		gameInfo := skills.DefaultGameInfo
		Convey("Given two rookie teams of one", func() {
			teams := []skills.Team{skills.NewTeam(), skills.NewTeam()}

			teams[0].AddPlayer(2, gameInfo.DefaultRating())
			teams[1].AddPlayer(1, gameInfo.DefaultRating())

			Convey("The match quality should be 0.447", func() {
				So(calc.CalcMatchQual(gameInfo, teams), ShouldAlmostEqual, 0.447, 0.001)
			})

			Convey("Given team one wins", func() {
				ranks := []int{2, 1}

				Convey("Calculate the new ratings", func() {
					newRatings := calc.CalcNewRatings(gameInfo, teams, ranks...)

					Convey("The passed slices should not be reordered", func() {
						So(teams[0].Players()[0], ShouldEqual, 2)
						So(teams[1].Players()[0], ShouldEqual, 1)
						So(ranks, ShouldResemble, []int{2, 1})
					})

					Convey("Team one's mean should be higher and the standard deviations should have gone down.", func() {
						So(newRatings[1].Mean(), ShouldAlmostEqual, 29.39583201999924, errorTolerance)
						So(newRatings[1].Stddev(), ShouldAlmostEqual, 7.171475587326186, errorTolerance)

						So(newRatings[2].Mean(), ShouldAlmostEqual, 20.60416798000076, errorTolerance)
						So(newRatings[2].Stddev(), ShouldAlmostEqual, 7.171475587326186, errorTolerance)
					})
				})
			})
		})
	})
}
开发者ID:ChrisHines,项目名称:GoSkills,代码行数:37,代码来源:Calc_test.go


注:本文中的github.com/ChrisHines/GoSkills/skills.Calc.CalcNewRatings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。