datadrivenmodel/policies.py

26 строки
600 B
Python

"""
Fixed policies to test our sim integration with. These are intended to take
Brain states and return Brain actions.
"""
import random
from typing import Dict
import requests
def random_policy(state, action_keys):
"""
Ignore the state, move randomly.
"""
action = {k: random.random() for k in action_keys}
return action
def brain_policy(
state: Dict[str, float], exported_brain_url: str = "http://localhost:5000"
):
prediction_endpoint = f"{exported_brain_url}/v1/prediction"
response = requests.get(prediction_endpoint, json=state)
return response.json()