summaryrefslogtreecommitdiff
path: root/bayrate/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bayrate/game.cpp')
-rw-r--r--bayrate/game.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/bayrate/game.cpp b/bayrate/game.cpp
new file mode 100644
index 0000000..e320a6a
--- /dev/null
+++ b/bayrate/game.cpp
@@ -0,0 +1,82 @@
+/*************************************************************************************
+
+ Copyright 2010 Philip Waldron
+
+ This file is part of BayRate.
+
+ BayRate is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ BayRate is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with BayRate. If not, see <http://www.gnu.org/licenses/>.
+
+***************************************************************************************/
+
+#include <iostream>
+#include "game.h"
+
+using namespace std;
+
+game::game(void)
+{
+}
+
+game::~game(void)
+{
+}
+
+/****************************************************************
+
+calc_handicapeqv ()
+
+Calculates the equivalent rating difference for the handicap/komi
+conditions of this game.
+
+*****************************************************************/
+void game::calc_handicapeqv() {
+ if (handicap == 0) {
+ handicapeqv = 0.580 - 0.0757 * komi;
+ sigma_px = 1.0649 - 0.0021976 * komi + 0.00014984 * komi * komi;
+ }
+ else if (handicap == 1) {
+ handicapeqv = 0.580 - 0.0757 * (komi);
+ sigma_px = 1.0649 - 0.0021976 * (komi) + 0.00014984 * (komi) * (komi);
+ }
+ else {
+ handicapeqv = handicap - 0.0757*komi;
+ sigma_px = -0.0035169 * komi;
+ switch (handicap) {
+ case 2:
+ sigma_px += 1.13672;
+ break;
+ case 3:
+ sigma_px += 1.18795;
+ break;
+ case 4:
+ sigma_px += 1.22841;
+ break;
+ case 5:
+ sigma_px += 1.27457;
+ break;
+ case 6:
+ sigma_px += 1.31978;
+ break;
+ case 7:
+ sigma_px += 1.35881;
+ break;
+ case 8:
+ sigma_px += 1.39782;
+ break;
+ case 9:
+ sigma_px += 1.43614;
+ break;
+ }
+ }
+}