mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-17 15:35:21 +02:00
add general environment and refactor environment's w/r funcs
This commit is contained in:
parent
cb9793e69b
commit
6ebe8efc63
21 changed files with 252 additions and 147 deletions
3
tests/metagpt/environment/__init__.py
Normal file
3
tests/metagpt/environment/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Desc :
|
||||
19
tests/metagpt/environment/test_gym_environment.py
Normal file
19
tests/metagpt/environment/test_gym_environment.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Desc : unittest of gym environment
|
||||
|
||||
from metagpt.environment.gym_environment import GymEnvironment
|
||||
|
||||
|
||||
def test_gym_environment():
|
||||
gym_env = GymEnvironment(name="CartPole-v1")
|
||||
gym_env.init_register_funcs()
|
||||
|
||||
observation, info = gym_env.call_func("reset", seed=42)
|
||||
for _ in range(2):
|
||||
action = gym_env.call_func("sample_action")
|
||||
observation, reward, terminated, truncated, info = gym_env.call_func("step", action=action)
|
||||
if terminated or truncated:
|
||||
observation, info = gym_env.call_func("reset")
|
||||
assert len(observation) == 4
|
||||
gym_env.call_func("close")
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions import BossRequirement
|
||||
from metagpt.environment import Environment
|
||||
from metagpt.environment.environment import Environment
|
||||
from metagpt.logs import logger
|
||||
from metagpt.manager import Manager
|
||||
from metagpt.roles import Architect, ProductManager, Role
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue