<commit_before>/* bzflag
 * Copyright (c) 1993 - 2008 <NAME>
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named LICENSE that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

/* interface header */
#include "Score.h"

/* system implementation headers */
#include <iostream>

/* common implementation headers */
#include "Pack.h"


float Score::tkKickRatio = 3.0;
int   Score::score       = 999;
bool  Score::randomRanking = false;

Score::Score(): wins(0), losses(0), tks(0) {
}

void Score::dump() const {
  std::cout << wins << '-' << losses;
}

float Score::ranking() const {
  if (randomRanking)
    return (float)bzfrand();

  // otherwise do score-based ranking
  int sum = wins + losses;
  if (sum == 0)
    return 0.5;
  float average = (float)wins/(float)sum;
  // IIRC that is how wide is the gaussian
  float penalty = (1.0f - 0.5f / sqrt((float)sum));
  return average * penalty;
}

bool Score::isTK() const {
  // arbitrary 3
  return (tks >= 3) && (tkKickRatio > 0)
    && ((wins == 0) || (tks * 100 / wins > tkKickRatio));
}

void Score::tK() {
  tks++;
}

void Score::killedBy() {
  losses++;
}

void Score::kill() {
  wins++;
}
<commit_msg>Change default (0 kills, 0 deaths) to 0% A player who hasn't played doesn't deserve a ranking, and this has been abused in Rabbit Hunt games where rabbit can be chosen by the ranking.<commit_after>/* bzflag
 * Copyright (c) 1993 - 2008 <NAME>
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named LICENSE that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

/* interface header */
#include "Score.h"

/* system implementation headers */
#include <iostream>

/* common implementation headers */
#include "Pack.h"


float Score::tkKickRatio = 3.0;
int   Score::score       = 999;
bool  Score::randomRanking = false;

Score::Score(): wins(0), losses(0), tks(0) {
}

void Score::dump() const {
  std::cout << wins << '-' << losses;
}

float Score::ranking() const {
  if (randomRanking)
    return (float)bzfrand();

  // otherwise do score-based ranking
  int sum = wins + losses;
  if (sum == 0)
    return 0.0;
  float average = (float)wins/(float)sum;
  // IIRC that is how wide is the gaussian
  float penalty = (1.0f - 0.5f / sqrt((float)sum));
  return average * penalty;
}

bool Score::isTK() const {
  // arbitrary 3
  return (tks >= 3) && (tkKickRatio > 0)
    && ((wins == 0) || (tks * 100 / wins > tkKickRatio));
}

void Score::tK() {
  tks++;
}

void Score::killedBy() {
  losses++;
}

void Score::kill() {
  wins++;
}

{'fraction_non_alphanumeric': 0.13958060288335516, 'fraction_numerical': 0.020642201834862386, 'mean_word_length': 3.496318114874816, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3665248', 'n_tokens_mistral': 1028, 'n_tokens_neox': 972, 'n_words': 355}