From 63d36e0f3f83d65bb49e27c8d732a9dcecdfa4e4 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Fri, 5 Apr 2024 13:20:43 +0200 Subject: Reformatted rating_add() --- FICS/ratings.c | 132 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 73 insertions(+), 59 deletions(-) (limited to 'FICS') diff --git a/FICS/ratings.c b/FICS/ratings.c index 94295e7..127085a 100644 --- a/FICS/ratings.c +++ b/FICS/ratings.c @@ -96,66 +96,80 @@ is_active(int Games) return (Games >= PROVISIONAL); } -PUBLIC void rating_add(int rating, int type) +PUBLIC void +rating_add(int rating, int type) { - int which; - - which = (rating - LOWESTHIST) / 100; - if (which < 0) - which = 0; - if (which >= MAXHIST) - which = MAXHIST - 1; - if (type == TYPE_BLITZ) { - bHist[which] += 1; - Rb_count++; - Rb_total += rating; - if (Rb_count == 1) { - Rb_M = rating; - } else { - Rb_S = Rb_S + (rating - Rb_M) * (rating - Rb_M); - Rb_M = Rb_M + (rating - Rb_M) / (Rb_count); - } - Ratings_B_StdDev = sqrt(Rb_S / Rb_count); - Ratings_B_Average = Rb_total / (double) Rb_count; - } else if (type == TYPE_WILD) { /* TYPE_WILD */ - wHist[which] += 1; - Rw_count++; - Rw_total += rating; - if (Rw_count == 1) { - Rw_M = rating; - } else { - Rw_S = Rw_S + (rating - Rw_M) * (rating - Rw_M); - Rw_M = Rw_M + (rating - Rw_M) / (Rw_count); - } - Ratings_W_StdDev = sqrt(Rw_S / Rw_count); - Ratings_W_Average = Rw_total / (double) Rw_count; - } else if (type == TYPE_LIGHT) { /* TYPE_LIGHT */ - lHist[which] += 1; - Rl_count++; - Rl_total += rating; - if (Rl_count == 1) { - Rl_M = rating; - } else { - Rl_S = Rl_S + (rating - Rl_M) * (rating - Rl_M); - Rl_M = Rl_M + (rating - Rl_M) / (Rl_count); - } - Ratings_L_StdDev = sqrt(Rl_S / Rl_count); - Ratings_L_Average = Rl_total / (double) Rl_count; - -/* Insert bughouse stuff */ - } else { /* TYPE_STAND */ - sHist[which] += 1; - Rs_count++; - Rs_total += rating; - if (Rs_count == 1) { - Rs_M = rating; - } else { - Rs_S = Rs_S + (rating - Rs_M) * (rating - Rs_M); - Rs_M = Rs_M + (rating - Rs_M) / (Rs_count); - } - Ratings_S_StdDev = sqrt(Rs_S / Rs_count); - Ratings_S_Average = Rs_total / (double) Rs_count; - } + int which; + + if ((which = (rating - LOWESTHIST) / 100) < 0) + which = 0; + + if (which >= MAXHIST) + which = MAXHIST - 1; + + if (type == TYPE_BLITZ) { + bHist[which] += 1; + + Rb_count++; + Rb_total += rating; + + if (Rb_count == 1) { + Rb_M = rating; + } else { + Rb_S = Rb_S + (rating - Rb_M) * (rating - Rb_M); + Rb_M = Rb_M + (rating - Rb_M) / (Rb_count); + } + + Ratings_B_StdDev = sqrt(Rb_S / Rb_count); + Ratings_B_Average = (Rb_total / (double)Rb_count); + } else if (type == TYPE_WILD) { // TYPE_WILD + wHist[which] += 1; + + Rw_count++; + Rw_total += rating; + + if (Rw_count == 1) { + Rw_M = rating; + } else { + Rw_S = Rw_S + (rating - Rw_M) * (rating - Rw_M); + Rw_M = Rw_M + (rating - Rw_M) / (Rw_count); + } + + Ratings_W_StdDev = sqrt(Rw_S / Rw_count); + Ratings_W_Average = (Rw_total / (double)Rw_count); + } else if (type == TYPE_LIGHT) { // TYPE_LIGHT + lHist[which] += 1; + + Rl_count++; + Rl_total += rating; + + if (Rl_count == 1) { + Rl_M = rating; + } else { + Rl_S = Rl_S + (rating - Rl_M) * (rating - Rl_M); + Rl_M = Rl_M + (rating - Rl_M) / (Rl_count); + } + + Ratings_L_StdDev = sqrt(Rl_S / Rl_count); + Ratings_L_Average = (Rl_total / (double)Rl_count); + + // Insert bughouse stuff + } else { // TYPE_STAND + sHist[which] += 1; + + Rs_count++; + Rs_total += rating; + + if (Rs_count == 1) { + Rs_M = rating; + } else { + Rs_S = Rs_S + (rating - Rs_M) * (rating - Rs_M); + Rs_M = Rs_M + (rating - Rs_M) / (Rs_count); + } + + Ratings_S_StdDev = sqrt(Rs_S / Rs_count); + Ratings_S_Average = (Rs_total / (double)Rs_count); + } } PUBLIC void -- cgit v1.2.3