How to create two mutual producers / consumers with internal state in Haskell?

I have an agent that accepts states and returns actions, while preserving the internal representation of the usefulness of state / action pairs. I also have an environment that takes action and returns status / reward pairs.

I need to configure the agent with the initial state, and then continuously switch from the agent - (action) β†’ environment - (state, reward) β†’ agent - (action) β†’ ... However, the internal states (which need to be updated at each iteration) must remain closed (i.e. inside the agent or environment). This means that I cannot just call the environment as a function inside the agent, using state and action as arguments.

I'm kind of like a Haskell noobie, so I'm not even sure if this is possible.

+3
source share
2 answers

Two questions:

  • If an agent should use state to compute an action, then how do you expect to keep state representation from the agent?

  • If the environment expects to receive a state (and reward) for the action, how do you expect to keep the state of the state secret from the environment?

Both are possible, but each should include some kind of abstraction for querying states or creating states. I have no good idea about this design.

This will help clarify the issue.

  • Providing type signatures for functions of interest

  • , , .

P.S. Haskell ( , ).

+2

, "" - , , , , .

- - .

module Agent (AgentState, other_stuff) where

module Agent (AgentState(..), other_stuff) where

( , , ), , - , , .

, , , , , , Haskell, , . ( , - , , , .)

+2

Source: https://habr.com/ru/post/1708022/


All Articles