INNER CODE UNIT · Python
__add__
ikatsov/tensor-house · supply-chain/world_of_supply/world_of_supply_environment.py:31
def __add__(self, other):
return BalanceSheet(self.profit + other.profit, self.loss + other.loss)
def __sub__(self, other):
return BalanceSheet(self.profit - other.profit, self.loss - other.loss)
def __repr__(self):
return f"{self.profit+self.loss} ({self.profit} {self.loss})"
def __radd__(self, other):
if other == 0:
return self
else:
return self.__add__(other)
# ======= Infrastructure
class TerrainCell(Cell):