2
我實現ELO算法但它是在完全相反的方式工作,我混合的結果(贏設置在哪裏失去的,相反的。)這小小的細節辜負我的結果 - 爲什麼問題是,這就是 - 我怎樣才能扭轉?反向的Elo算法
我只有新的Elo老ELO因爲我是garhering統計..
我的算法是完全一樣的wiki: https://en.wikipedia.org/wiki/Elo_rating_system#Theory
是:
public class EloAlgorithm {
public static Integer calculateRating(Integer myRating, Integer opponentRating, EloGameResultValue result) {
myRating += calculateEloDelta(myRating, opponentRating, result);
if (myRating<0){
return 0;
}
return myRating;
}
private static Integer calculateEloDelta(Integer myRating, Integer opponentRating, EloGameResultValue result){
Double myChanceToWin = 1/(1 + Math.pow(10, (opponentRating - myRating)/400));
Long eloDelta = Math.round(getKFactor(myRating) * (result.getValue() - myChanceToWin));
return eloDelta.intValue();
}
private static double getKFactor(Integer myRating) {
if(myRating < 2100) return 32.0;
else if(myRating >= 2100 && myRating < 2400) return 24;
else return 16;
}
}
我試着扭轉它,但可能我沒有在我的計算錯誤:
public static Integer fetchOponentRatingFromDifference(int myOldRating, int myNewRating, EloGameResultValue result){
double delta = myNewRating - myOldRating;
double k = getKFactor(myOldRating);
double myChanceToWin = (k* result.getValue() - difference)/k ;
double log = Math.log10(1/myChanceToWin - 1);
Double resultToReturn = 400*log + myOldRating;
return (int)Math.round(resultToReturn);
}
你能幫我找到一個錯誤或推薦更好的解決方案嗎?
編輯:由於被請求:
我經由的JUnit
public class EloValueBinaryFinderTest {
@Test
public void eloValueFinderTest(){
System.out.println(
EloValueBinaryFinder.fetchOponentRatingFromDifference(952,968)
);
}
}
與此然而主要方法將是測試:
public class EloValueBinaryFinderTest {
public static void main(String... args){
System.out.println(
EloValueBinaryFinder.fetchOponentRatingFromDifference(952,968)
);
}
}
EloGameResultValue作爲必要只是一個枚舉:
public enum EloGameResultValue {
WIN(1),
DRAW(0.5),
LOSE(0);
Double value;
EloGameResultValue(double value) {
this.value = value;
}
public Double getValue() {
return value;
}
public Boolean isWin() {
if(value.equals(1.0)){
return true;
}
if(value.equals(0.0)){
return false;
}
return null;
}
}
的UE'int'而不是'Integer'和'double'而不是'double'當你不強制,更容易,您能不能給測試主要方法? – azro
請來到這裏https://chat.stackoverflow.com/rooms/info/150213/elo-algo?tab=general更好說話 – azro
和謹慎與整數除法:例如'380/400 = 0',同時'(雙)380/400 = 380.0/400 = 380/400.0 = 0.95' –