- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一份 FIFA 19 两名球员之间的比赛列表,我希望根据所参加的比赛使用该数据更新我在这两名球员之间的 ELO 评分。我正在尝试使用此数据不断更新最初从 1000 开始的 ELO 评级。
我尝试使用按引用传递,但不确定我应该如何实现它,因为 2 个不同的函数调用相同的评级变量。
#include <iostream>
#include <cmath>
#include <string>
#include <fstream>
#include <vector>
#include <sstream>
using namespace std;
const int K = 20; //constant used in http://clubelo.com/Ranking
//tokenize and extract the number of goals only
vector <string> tokenize(string s){
vector <string> tokens;
stringstream check1(s);
string intermediate;
// Tokenizing w.r.t. space ' '
while(getline(check1, intermediate, ' ')){
tokens.push_back(intermediate);
}
return tokens;
}
//calculating goal difference to calculate ELO rating
int GoalDifference (int goalsA, int goalsB){
int GoalDiff = abs(goalsA - goalsB);
int G;
if (GoalDiff == 0 || GoalDiff == 1)
G = 1;
else if (GoalDiff == 2)
G = 3/2;
else
G = (11+GoalDiff)/8;
return G;
}
//determine the result of the match by looking at goals
int result (int goalsA,int goalsB){
int result;
if (goalsA == goalsB)
result = 0.5;
else if (goalsA>goalsB)
result = 1;
else
result = 0;
return result;
}
// Function to calculate the Probability
float Probability(int rating1,int rating2){
return 1.0 / (1.0 *pow(10, 1.0 * ((rating1 - rating2)) / 400)+1);
}
//calculating new ELO rating
int ELOratings (int rating, int goalsa, int goalsb, int probability){
int deltapoints = K* GoalDifference(goalsa, goalsb) * (result(goalsa, goalsb) - probability);
return rating + deltapoints;
}
int main(){
int Ratinga = 1000, Ratingb = 1000;
int goalsA, goalsB, probA, probB, ELOp1, ELOp2;
ifstream inputFile;
string input;
inputFile.open("Scores of P1 vs P2.txt");
vector <string> ScoreTokens;
while (!inputFile.eof()) {
getline(inputFile,input);
ScoreTokens = tokenize(input);
goalsA = stoi(ScoreTokens[1]);
goalsB = stoi(ScoreTokens[3]);
probA = Probability(Ratinga, Ratingb);
probB = Probability(Ratingb, Ratinga);
ELOp1 = ELOratings(Ratinga, goalsA, goalsB, probA);
ELOp2 = ELOratings(Ratingb, goalsB, goalsA, probB);
cout << "The new rating for P1 is: " << ELOp1 << endl;
cout << "The new rating for P2 is: " << ELOp2 << endl << endl;
}
return 0;
}
以下是分数以及我如何提取数据:P1 VS P2利物浦 2 曼联 2巴萨 2 皇马 3
经过计算,第一局结束后,每个人的评分应该是990。第二局结束后,P1应该是970,P2应该是990。
但是第一局之后实际输出是1000。第二场比赛后:P1: 1000P2: 1020
最佳答案
问题是您到处都在使用整数进行涉及小数的计算。例如,3/2
等于 1
(不是 1.5
),因为它是整数除法,所以结果是整数。
这是固定的功能
//calculating goal difference to calculate ELO rating
double GoalDifference (int goalsA, int goalsB){
int GoalDiff = abs(goalsA - goalsB);
double G;
if (GoalDiff == 0 || GoalDiff == 1)
G = 1.0;
else if (GoalDiff == 2)
G = 1.5;
else
G = (11+GoalDiff)/8.0;
return G;
}
请注意,返回类型也已更改为 double
,因为结果是小数。但 goalsA
和 goalsB
已保留为整数,因为它们确实是整数。
基本上,您需要检查您的代码,并在每一点都问自己这个数字是整数还是分数,然后适本地进行更改。
顺便说一句,float
和 double
都可以用于分数,但通常你应该更喜欢 double
因为它更精确而且不少于高效。
关于c++ - 玩了一定数量的游戏后如何更新 ELO 评级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56625206/
我正在尝试制作一个程序来自动更改此人的 elo 评级。我遇到了一个我似乎无法解决的问题。代码如下: Liam=1000; Stefan=1000; Dy
我正在创建一个允许人们对图像进行评分的系统。 我的想法是对每个图像使用 Elo 评级系统 ( http://en.wikipedia.org/wiki/Elo_rating_system ),然后使用
最近制作了一个锦标赛支架,玩家可以在其中注册并参与获得获胜席位的机会。如您所见,这是它的图片: 锦标赛分组结束后,我计划将这些奖金转化为排名。因此,结果是“Achilles”排名第一,因为他在锦标赛中
我想知道您将如何着手为基于 Elo 系统的游戏创建平衡系统。 我在这里阅读了几篇关于类似系统的文章。我的平衡系统基于对列表进行排序,然后将奇数玩家分配给一个团队,甚至分配给另一个团队。 我发现的问题是
我很难理解为我们平台上的大量用户进行类似 ELO 分数计算的问题。 例如。对于大量用户中的每个用户,基于可变数量的“完成的事情”的复杂公式将根据类似匹配的原则为每个用户得出分数。 就我们的情况而言,它
我有一份 FIFA 19 两名球员之间的比赛列表,我希望根据所参加的比赛使用该数据更新我在这两名球员之间的 ELO 评分。我正在尝试使用此数据不断更新最初从 1000 开始的 ELO 评级。 我尝
为什么随机人群和随机获胜者,分数慢慢漂移到 0。我知道分数可能是随机的,但为什么总是负漂移? import trueskill as ts from random import choice r =
我最近创建了一个锦标赛系统,该系统很快就会进入玩家排名。基本上,在玩家完成锦标赛后,他们会根据他们在锦标赛中的表现获得排名。因此,赢得比赛的人将获得最多的积分并排名第一,而第二名将获得第二多的积分并排
问题: 如果你去http://www.newedenfaces.com/在底部你可以看到玩家排行榜。每个人都以 1400 的基本分数开始。数据库中目前有超过 1100 名玩家,每次投票时都会随机选出两
我正在研究评级算法。我有一套练习。它们都按级别分类(1 = 最简单,5 = 最难)。 用户会看到两个练习,他们应该决定哪一个更难,或者两者是否相等。应根据用户评分调整级别。 我做了什么:我试验了 El
几天来,我一直在互联网上搜索各种查询,试图找到一种用于配对 Elo 服务的算法。我在我正在编写的游戏插件中实现了一个基本的 Elo 系统。下一个主要步骤是尝试创建一个自动配对系统,该系统拥有一群正在寻
我正在尝试为我的网站所涉及的运动实现基于 Elo 的排名系统。 有几千名参赛者,每场比赛都有 50 到 500 名参赛者争分夺秒。最快的人获胜。 我最初的想法是,一场 50 人的比赛可以视为 50*4
我实现了 elo 算法,但是当我混合结果时它以完全相反的方式工作(设置赢,输和相反..)这个小细节使我的结果失败 - 这就是为什么问题是 - 我如何才能扭转它? 我在收集统计数据时只有新的 Elo 和
我正在寻找类似于国际象棋中的 elo 评分系统的评分系统。我遇到的问题是 ELO 系统取决于玩游戏的顺序。例如。玩家 A 开始 Elo 1000玩家 B 开始 Elo 1000 如果玩家 B 赢了 A
我从 PHPClasses 网站获得了以下 ELO 类。 $S2) { $E = 120 - round(1 / (1 + pow(10, (($R2 - $R1)
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 3 年前。 Improve
我是一名优秀的程序员,十分优秀!