diff --git a/pubeval.py b/pubeval.py index 01ef715..b3d2c95 100644 --- a/pubeval.py +++ b/pubeval.py @@ -42,40 +42,38 @@ class Pubeval: 0.00000, 3.42040 ] - def pubeval(race, pos): + + def pubeval(self, race, pos): - if pos[26] == 15: - return 99999999.0 - - setx(pos) - score = 0.0 - if race: - for i in range(122): - score = score + self.wr[i]*self.x[i] - else: - for i in range(122): - score = score + self.wc[i]*self.x[i] - return score + if pos[26] == 15: + return 99999999.0 - def setx(pos): - - for j in range(122): - self.x[j] = 0.0 + self.x = [0]*122 + + for j in range(1,25): + jm1 = j-1 + n = pos[25-j] + if n != 0: + if n == -1: + self.x[5*jm1+0] = 1.0 + if n == 1: + self.x[5*jm1+1] = 1.0 + if n >= 2: + self.x[5*jm1+2] = 1.0 + if n == 3: + self.x[5*jm1+3] = 1.0 + if n >= 4: + self.x[5*jm1+4] = (n-3)/2.0 + self.x[120] = -(pos[0]/2.0) + self.x[121] = (pos[26]/15.0) + + score = 0.0 + if race: + for i in range(122): + score = score + self.wr[i]*self.x[i] + else: + for i in range(122): + score = score + self.wc[i]*self.x[i] + return score - for j in range(1,25): - jm1 = j-1 - n = pos[25-j] - if n != 0: - if n == -1: - self.x[5*jm1+0] = 1.0 - if n == 1: - self.x[5*jm1+1] = 1.0 - if n >= 2: - self.x[5*jm1+2] = 1.0 - if n == 3: - self.x[5*jm1+3] = 1.0 - if n >= 4: - self.x[5*jm1+4] = (n-3)/2.0 - self.x[120] = -(pos[0]/2.0) - self.x[121] = (pos[26]/15.0)