-
1:1 elo 레이팅 계산프로그래밍/코드 조각 2017. 12. 5. 15:58반응형#include <iostream>#include <cmath>int main(){constexpr float K = 32; // K-factor and basically a measure of how strong a match will impact the players’ ratings.float rating1 = 2400;float rating2 = 2000;float R1 = std::pow(10, rating1/400);float R2 = std::pow(10, rating2/400);float E1 = R1 / (R1+R2);float E2 = R2 / (R1+R2);// match result// win:1, draw:0.5, lose:0int res1 = 0;int res2 = 1;float new_rating1 = rating1 + (K * (res1 - E1));float new_rating2 = rating2 + (K * (res2 - E2));std::cout << new_rating1 << std::endl;std::cout << new_rating2 << std::endl;return 0;}
문뜩 elo 계산하는 게 궁금해서 찾아봤다. 아래의 래퍼런스대로 코드를 만들어보니 얼추 맞는 듯. 저 K팩터에 따라 비중을 조절할 수 있다. 일반적으로 많이 쓰이는 상수는 32라는 듯. 32는 어떤식으로 도출된 건지는 모르겠다만.
참고: ttps://metinmediamath.wordpress.com/2013/11/27/how-to-calculate-the-elo-rating-including-example/
반응형'프로그래밍 > 코드 조각' 카테고리의 다른 글
엑셀 테이블에서 공백 컬럼 있는지 체크하는 코드 샘플 c# (0) 2018.06.16 c++ 문자열 스플릿 (0) 2018.05.10 c++17 std::transform과 구조화된 바인딩 예제 (0) 2017.12.04 c++17 fold expression 예제 (0) 2017.12.03 c++17 constexpr if 예제 (0) 2017.12.03