From d37e289741be0fa642770fc0c151f5aa552a84ff Mon Sep 17 00:00:00 2001 From: moosecrab Date: Tue, 25 Feb 2020 01:33:31 -0800 Subject: [PATCH] Added accuracy tracking of predictions over time --- PepperBet.sln | 1 - PepperBet/PepperBet.vb | 55 +++++++++++++++++++++++++++++++++++++++--- PepperBet/version.txt | 2 +- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/PepperBet.sln b/PepperBet.sln index e7a1b63..ec03147 100755 --- a/PepperBet.sln +++ b/PepperBet.sln @@ -40,7 +40,6 @@ Global {E6794089-F810-402B-A3CE-0D7EA579108A}.Debug|Any CPU.Build.0 = Debug|Any CPU {E6794089-F810-402B-A3CE-0D7EA579108A}.Debug|x86.ActiveCfg = Debug|Any CPU {E6794089-F810-402B-A3CE-0D7EA579108A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6794089-F810-402B-A3CE-0D7EA579108A}.Release|Any CPU.Build.0 = Release|Any CPU {E6794089-F810-402B-A3CE-0D7EA579108A}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution diff --git a/PepperBet/PepperBet.vb b/PepperBet/PepperBet.vb index b92f856..25b4a65 100755 --- a/PepperBet/PepperBet.vb +++ b/PepperBet/PepperBet.vb @@ -2,7 +2,7 @@ 'Seconds between updates Const updatedelay = 2 - Const version As String = "1.9.12" + Const version As String = "1.10" Const downloadurl As String = "https://long-cat.net/projects/pepperbet/pepperbet.exe?v=" & version Const versionurl As String = "https://long-cat.net/projects/pepperbet/version.txt?v=" & version Const dbfilename As String = "pepperdata.xml" @@ -12,7 +12,7 @@ Dim watching As Boolean = True Dim autoupdate As Boolean = False Dim lastupdatecheck As New DateTime(0) - Dim accuracies(10) As Double + Dim accuracies(9) As Double 'These are the time constants for the exponentially weighted falloff Dim accuracytimeconstants() As Double = {10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000} @@ -89,12 +89,12 @@ Console.ForegroundColor = ConsoleColor.White Console.WriteLine(" ╟──────────────────────────────") 'DONT FORGET TO CHANGE IT UP IN THE CONST - Console.WriteLine("──────────────────────────────╢ v" & version & " ╟──────────────────────────────") + Console.WriteLine("──────────────────────────────╢ v" & version & " ╟──────────────────────────────") 'DONT FORGET TO CHANGE IT UP IN THE CONST Console.WriteLine(" ╚════════════════╝") Console.WriteLine() Console.ForegroundColor = ConsoleColor.Gray - Console.WriteLine("(C) 2013-2018 by moose crap http://long-cat.net") + Console.WriteLine("(c) 2013-2020 by moose crap http://long-cat.net") Console.WriteLine("Thanks to Fredstonemason for help and testing") Console.WriteLine() helpstring() @@ -433,6 +433,14 @@ Console.Write("Automatic updates disabled") End If Console.CursorLeft = 0 + + ElseIf tempkey.Key = ConsoleKey.R Then + Console.ForegroundColor = ConsoleColor.Gray + Console.BackgroundColor = ConsoleColor.Black + Console.WriteLine("Prediction accuracy") + For i = 0 To accuracies.Length - 1 + Console.WriteLine("{0,5}: {1:0.000000}", accuracytimeconstants(i), accuracies(i)) + Next ElseIf tempkey.Key = ConsoleKey.C Then Console.ForegroundColor = ConsoleColor.Gray Console.BackgroundColor = ConsoleColor.Black @@ -626,6 +634,11 @@ If remaining <> "" Then titlestr &= remaining End If + + titlestr &= accuracies(0).ToString(" 0.000") + titlestr &= accuracies(3).ToString(" 0.000") + titlestr &= accuracies(6).ToString(" 0.000") + Console.Title = titlestr End Sub @@ -681,6 +694,14 @@ Dim p1rdi As Double = p1.RD Dim p2rdi As Double = p2.RD Dim result As Integer 'red, blue, draw + Dim expectedresult As Integer + If p1ki > p2ki Then + expectedresult = 1 + ElseIf p2ki > p1ki Then + expectedresult = 2 + Else + expectedresult = 3 + End If Console.ForegroundColor = ConsoleColor.Gray Console.BackgroundColor = ConsoleColor.Black If scorestr = "" Then @@ -799,6 +820,19 @@ Console.Write("{0,4:+###;-###;0}", p2.RD - p2rdi) Console.ForegroundColor = ConsoleColor.Gray Console.Write(")" + vbCrLf) + + ' Update prediction accuracies + Dim correct As Integer + If result = expectedresult Then + correct = 1 + Else + correct = 0 + End If + For i = 0 To accuracytimeconstants.Length - 1 + Dim exp As Double = Math.Exp(1 / accuracytimeconstants(i)) + accuracies(i) = accuracies(i) * (2 - exp) + correct * (exp - 1) + Next + End Sub Private Sub DoMatchup(p1 As Glicko, p2 As Glicko, invcolors As Boolean, Optional skip As Boolean = False) @@ -898,6 +932,9 @@ Next xd.Add(New XElement("watching", watching.ToString)) xd.Add(New XElement("autoupdate", autoupdate.ToString)) + For i = 0 To accuracies.Length - 1 + xd.Add(New XElement("accuracy" & accuracytimeconstants(i), CStr(accuracies(i)))) + Next xd.Save(dbfilename) End Sub @@ -912,15 +949,24 @@ For Each x In xd.. names.Add(x.Value) Next + Try watching = CBool(xd...Value) Catch End Try + Try autoupdate = CBool(xd...Value) Catch End Try + Try + For i = 0 To accuracies.Length - 1 + accuracies(i) = CDbl(xd.Root.Element("accuracy" & accuracytimeconstants(i)).Value) + Next + Catch + End Try + For Each x In xd.. Dim temp As New Glicko(x.@name, CLng(x.@lastmatch)) temp.K = CDbl(x.@k) @@ -1001,6 +1047,7 @@ Console.WriteLine("[Enter/Esc] Enter/exit manual data entry") Console.WriteLine("[Q]uery database") Console.WriteLine("[C]leanup database") + Console.WriteLine("[R]eport accuracy") Console.WriteLine("[N]ames (for bet watching)") Console.WriteLine("[W]atch display toggle") Console.WriteLine("[A]utomatic updates toggle") diff --git a/PepperBet/version.txt b/PepperBet/version.txt index 38094bd..578c71b 100755 --- a/PepperBet/version.txt +++ b/PepperBet/version.txt @@ -1 +1 @@ -1.9.12 \ No newline at end of file +1.10 \ No newline at end of file