-
Notifications
You must be signed in to change notification settings - Fork 0
/
reward.py
36 lines (30 loc) · 992 Bytes
/
reward.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
28
29
30
31
32
33
34
35
36
class Reward:
value: float
def __init__(self, value: float) -> None:
self.value = value
def __float__(self) -> float:
return self.value
def __str__(self) -> str:
return str(self.value)
def __add__(self, __o: object) -> object:
if hasattr(__o, "value"):
return Reward(self.value + __o.value)
else:
return Reward(self.value + __o)
def __iadd__(self, __o: object) -> object:
if hasattr(__o, "value"):
self.value += __o.value
else:
self.value += __o
return self
def __mul__(self, __o: object) -> object:
if hasattr(__o, "value"):
return Reward(self.value * __o.value)
else:
return Reward(self.value * __o)
def __imul__(self, __o: object) -> object:
if hasattr(__o, "value"):
self.value *= __o.value
else:
self.value *= __o
return self