當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Calc.CalcMatchQual方法代碼示例

本文整理匯總了Golang中github.com/ChrisHines/GoSkills/skills.Calc.CalcMatchQual方法的典型用法代碼示例。如果您正苦於以下問題:Golang Calc.CalcMatchQual方法的具體用法?Golang Calc.CalcMatchQual怎麽用?Golang Calc.CalcMatchQual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ChrisHines/GoSkills/skills.Calc的用法示例。


在下文中一共展示了Calc.CalcMatchQual方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例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: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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.CalcMatchQual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。