2023-09-21 10:13:01 +01:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
from typing import Any, Dict, List
|
|
|
|
|
|
2023-10-02 17:21:43 +01:00
|
|
|
class AbstractReward():
|
|
|
|
|
def __init__(self):
|
|
|
|
|
...
|
2023-09-21 10:13:01 +01:00
|
|
|
|
2023-10-02 17:21:43 +01:00
|
|
|
def calculate(self, state:Dict) -> float:
|
|
|
|
|
return 0.3
|
2023-09-21 10:13:01 +01:00
|
|
|
|
|
|
|
|
|
2023-10-02 17:21:43 +01:00
|
|
|
class RewardFunction():
|
|
|
|
|
def __init__(self, reward_function:AbstractReward):
|
|
|
|
|
self.reward: AbstractReward = reward_function
|
2023-09-21 10:13:01 +01:00
|
|
|
|
2023-10-02 17:21:43 +01:00
|
|
|
def calculate(self, state:Dict) -> float:
|
|
|
|
|
return self.reward.calculate(state)
|