예제 #1
0
파일: sort.go 프로젝트: jwowillo/mancalai
// Less compares two specific agents using compare.
func (ranker *agentRanker) Less(i, j int) bool {
	agent1WinCount := 0
	agent2WinCount := 0
	result1 := compare.Run(
		ranker.constructors[i],
		ranker.constructors[j],
		ranker.gamesToPlay/2,
	)
	agent1WinCount += result1.Player1.WinCount
	agent2WinCount += result1.Player2.WinCount
	result2 := compare.Run(
		ranker.constructors[j],
		ranker.constructors[i],
		ranker.gamesToPlay/2,
	)
	agent1WinCount += result2.Player2.WinCount
	agent2WinCount += result2.Player1.WinCount
	return agent1WinCount < agent2WinCount
}
예제 #2
0
파일: main.go 프로젝트: jwowillo/mancalai
// handleCompare handles if the user chose the compare tool.
func handleCompare() {
	constructors := compare.AvailableAgentConstructors()
	if flags.agents {
		printConstructors(constructors)
		return
	}
	agent1, agent2, err := getAgents(constructors)
	if err != nil {
		fmt.Printf("%v.\n", err)
		return
	}
	result := compare.Run(agent1, agent2, flags.n)
	output, err := json.MarshalIndent(result, "", "\t")
	if err != nil {
		fmt.Println("Couldn't marshal output.")
	}
	fmt.Println(string(output))
}