mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-23 15:26:43 +02:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
f625b9d8a5
@ -6,6 +6,5 @@ Tackling emergent dysfunctions (EDYs) in cooperation with Fraunhofer-IKS
|
|||||||
1. Make sure to install `virtualenv` using `pip install virtualenv`
|
1. Make sure to install `virtualenv` using `pip install virtualenv`
|
||||||
2. Create a new virtual environment `virtualenv venv`
|
2. Create a new virtual environment `virtualenv venv`
|
||||||
3. Activate the virtual environment `source venv/bin/activate`
|
3. Activate the virtual environment `source venv/bin/activate`
|
||||||
4. Install the required dependencies `pip install requirements.txt`
|
4. Install the required dependencies `pip install -r requirements.txt`
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -11,7 +11,6 @@ from gym import spaces
|
|||||||
from gym.wrappers import FrameStack
|
from gym.wrappers import FrameStack
|
||||||
|
|
||||||
from environments.factory.base.shadow_casting import Map
|
from environments.factory.base.shadow_casting import Map
|
||||||
from environments.factory.renderer import Renderer, RenderEntity
|
|
||||||
from environments.helpers import Constants as c, Constants
|
from environments.helpers import Constants as c, Constants
|
||||||
from environments import helpers as h
|
from environments import helpers as h
|
||||||
from environments.factory.base.objects import Agent, Tile, Action
|
from environments.factory.base.objects import Agent, Tile, Action
|
||||||
@ -545,6 +544,8 @@ class BaseFactory(gym.Env):
|
|||||||
|
|
||||||
def render(self, mode='human'):
|
def render(self, mode='human'):
|
||||||
if not self._renderer: # lazy init
|
if not self._renderer: # lazy init
|
||||||
|
from environments.factory.renderer import Renderer, RenderEntity
|
||||||
|
global Renderer, RenderEntity
|
||||||
height, width = self._obs_cube.shape[1:]
|
height, width = self._obs_cube.shape[1:]
|
||||||
self._renderer = Renderer(width, height, view_radius=self._pomdp_r, fps=5)
|
self._renderer = Renderer(width, height, view_radius=self._pomdp_r, fps=5)
|
||||||
|
|
||||||
|
13
environments/factory/levels/shelves.txt
Normal file
13
environments/factory/levels/shelves.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
############
|
||||||
|
#----------#
|
||||||
|
#--######--#
|
||||||
|
#----------#
|
||||||
|
#--######--#
|
||||||
|
#----------#
|
||||||
|
#--######--#
|
||||||
|
#----------#
|
||||||
|
#--######--#
|
||||||
|
#----------#
|
||||||
|
#--######--#
|
||||||
|
#----------#
|
||||||
|
############
|
@ -1,32 +1,12 @@
|
|||||||
appdirs==1.4.4
|
numpy
|
||||||
click==7.1.2
|
scipy
|
||||||
cycler==0.10.0
|
tqdm
|
||||||
distlib==0.3.1
|
seaborn>=0.11.1
|
||||||
filelock==3.0.12
|
matplotlib>=3.4.1
|
||||||
kiwisolver==1.3.1
|
stable-baselines3>=1.0
|
||||||
matplotlib==3.4.1
|
pygame>=2.1.0
|
||||||
numpy==1.20.2
|
gym>=0.18.0
|
||||||
pandas~=1.2.3
|
networkx>=2.6.1
|
||||||
pygame~=2.0.1
|
simplejson>=3.17.5
|
||||||
pep517==0.10.0
|
PyYAML>=6.0
|
||||||
Pillow==8.2.0
|
git+https://github.com/facebookresearch/salina.git@main#egg=salina
|
||||||
pyparsing==2.4.7
|
|
||||||
python-dateutil==2.8.1
|
|
||||||
pytz==2021.1
|
|
||||||
scipy==1.6.3
|
|
||||||
seaborn==0.11.1
|
|
||||||
six==1.16.0
|
|
||||||
toml==0.10.2
|
|
||||||
torch==1.8.1
|
|
||||||
torchaudio==0.8.1
|
|
||||||
torchvision==0.9.1
|
|
||||||
typing-extensions==3.10.0.0
|
|
||||||
virtualenv==20.4.6
|
|
||||||
|
|
||||||
gym~=0.18.0
|
|
||||||
PyYAML~=5.3.1
|
|
||||||
pyglet~=1.5.0
|
|
||||||
optuna~=2.7.0
|
|
||||||
natsort~=7.1.1
|
|
||||||
tqdm~=4.60.0
|
|
||||||
networkx~=2.6.1
|
|
7
setup.py
7
setup.py
@ -1,7 +0,0 @@
|
|||||||
# setup.py
|
|
||||||
from setuptools import setup, find_packages
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name='F_IKS',
|
|
||||||
packages=find_packages()
|
|
||||||
)
|
|
@ -1,12 +1,29 @@
|
|||||||
from environments.factory import make
|
from environments.factory import make
|
||||||
import random
|
import salina
|
||||||
|
import torch
|
||||||
from gym.wrappers import FrameStack
|
from gym.wrappers import FrameStack
|
||||||
|
|
||||||
n_agents = 4
|
|
||||||
env = make('DirtyFactory-v0', n_agents=n_agents)
|
|
||||||
env = FrameStack(env, num_stack=3)
|
|
||||||
state, *_ = env.reset()
|
|
||||||
|
|
||||||
for i in range(1000):
|
class MyAgent(salina.TAgent):
|
||||||
|
def __init__(self):
|
||||||
|
super(MyAgent, self).__init__()
|
||||||
|
|
||||||
|
def forward(self, t, **kwargs):
|
||||||
|
self.set(('timer', t), torch.tensor([t]))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
n_agents = 1
|
||||||
|
env = make('DirtyFactory-v0', n_agents=n_agents)
|
||||||
|
env = FrameStack(env, num_stack=3)
|
||||||
|
env.reset()
|
||||||
|
agent = MyAgent()
|
||||||
|
workspace = salina.Workspace()
|
||||||
|
agent(workspace, t=0, n_steps=10)
|
||||||
|
|
||||||
|
print(workspace)
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(1000):
|
||||||
state, *_ = env.step([env.unwrapped.action_space.sample() for _ in range(n_agents)])
|
state, *_ = env.step([env.unwrapped.action_space.sample() for _ in range(n_agents)])
|
||||||
env.render()
|
#env.render()
|
Loading…
x
Reference in New Issue
Block a user