-
Notifications
You must be signed in to change notification settings - Fork 29
/
objects.py
27 lines (24 loc) · 967 Bytes
/
objects.py
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
from neural_network import NeuralNetwork
class Result:
def __init__(self,
nn : NeuralNetwork,
score : int,
dist_to_next_cp : float
):
self.nn = nn
self.score = score
self.dist_to_next_cp = dist_to_next_cp
def _cmp(self, other):
if (self.score > other.score): return 1
elif (self.score < other.score): return -1
else:
if (self.dist_to_next_cp > other.dist_to_next_cp): return 1
elif (self.dist_to_next_cp < other.dist_to_next_cp): return -1
else: return 0
# Other comparators are unnecessary
def __lt__(self, other): return self._cmp(other) == -1
def __le__(self, other): return self._cmp(other) != 1
def __eq__(self, other): return self._cmp(other) == 0
def __ne__(self, other): return self._cmp(other) != 0
def __gt__(self, other): return self._cmp(other) == 1
def __ge__(self, other): return self._cmp(other) != -1