for rl-style policies, for the concurrent programming course at mimuw (2025/26 winter semester)
submitted solution lives in solution/, the rest was provided
the environment and a policy are black-box programs communicating through stdin/stdout. the environemnt provides the state to the policy, the policy gives an action to the environment etc.etc. until env ends. here the solution coordinates this concurrently, enforces "hardware limits" (simulated), and prints the results in the input order.
posix threads and poll/select were forbidden
general logic:
evaluator
-> env interface - one per env, borrows a policy for each step
-> policy dispatcher - on demand spawns/retires policies
-> policy interface - one per policy, served through its pair of fifos
idle policies wait for work in a non-blocking mqueue, if none available - ask for a new one, if full queue - retire those that don't fit. tee() is used to peek for the final state, for an ordered output, tests pass a token down a chain of fifos, finished results are parked in unlinked temp files waiting for their turn
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
make -C build evaluator demo_policy demo_env
printf 'AAAA\nQQQQ\n' | ./build/solution/evaluator ./build/demo/demo_policy ./build/demo/demo_env 1 1 1
# AAAA TZZZ
# QQQQ TZZZ
Arguments: policyPath envPath maxConcurrentPolicyCalls maxConcurrentCalls maxActiveEnvironments [extraArgs…]