public EloResult CalcElo(int WhiteELO, int BlackELO, ChessELO.EloScore.Winner WhoWon) { // A2 = A1 + 32 (G-(1/(1+10 ** ((B1-A1)/400)))) float G = 0; float A1 = System.Convert.ToSingle(WhiteELO); float B1 = System.Convert.ToSingle(BlackELO); if (WhoWon == Winner.Black) { G = 0; } if (WhoWon == Winner.White) { G = 1; } if (WhoWon == Winner.Draw) { G = 1 / 2; } double addsub = factor * (G - (1 / (1 + System.Math.Pow(10, ((B1 - A1) / divisor))))); int addsubint = System.Convert.ToInt32(addsub); EloResult result = new EloResult(); if (WhoWon == Winner.Draw) { result.Black = BlackELO; result.White = WhiteELO; } if (WhoWon == Winner.White) { result.White = WhiteELO + addsubint; result.Black = BlackELO - addsubint; } if (WhoWon == Winner.Black) { result.White = WhiteELO + addsubint; result.Black = BlackELO - addsubint; } result.updown = addsubint; return(result); }
private void button1_Click(object sender, EventArgs e) { ChessELO.EloScore.Winner w = new ChessELO.EloScore.Winner(); if (radioButton1.Checked) { w = ChessELO.EloScore.Winner.White; } if (radioButton2.Checked) { w = ChessELO.EloScore.Winner.Black; } if (radioButton3.Checked) { w = ChessELO.EloScore.Winner.Draw; } ChessELO.EloScore a = new ChessELO.EloScore(); ChessELO.EloResult b = a.CalcElo(System.Convert.ToInt32(textBox1.Text), System.Convert.ToInt32(textBox2.Text), w); // MessageBox.Show("White Score: " + b.White.ToString() + " - Black Score: " + b.Black.ToString()); textBox3.Text = b.White.ToString(); textBox4.Text = b.Black.ToString(); textBox5.Text = b.updown.ToString(); }