summaryrefslogtreecommitdiff
path: root/bayrate/game.cpp
blob: e320a6a7d5f7de653248e8641f07f18570497e52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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;	
		}	
	}
}