Skip to content

Commit

Permalink
Update README, multi agent example docs and code
Browse files Browse the repository at this point in the history
  • Loading branch information
vinhowe committed Mar 18, 2020
1 parent 413e6f3 commit 445f47e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ If you want to access the data of a specific sensor, import sensors and
retrieving the correct value from the state dictionary:

```python
from holodeck.sensors import Sensors

print(state[Sensors.LOCATION_SENSOR])
print(state["LocationSensor"])
```

## Multi Agent-Environments
Expand All @@ -77,7 +75,10 @@ Calls to [`step`](https://holodeck.readthedocs.io/en/latest/holodeck/environment
action has been provided, [`tick`](https://holodeck.readthedocs.io/en/latest/holodeck/environments.html#holodeck.environments.HolodeckEnvironment.tick) will advance the simulation forward. The action is persisted until another call to `act` provides a different action.

```python
env = holodeck.make('CyberPunkCity-Follow')
import holodeck
import numpy as np

env = holodeck.make("CyberPunkCity-Follow")
env.reset()

# Provide an action for each agent
Expand All @@ -86,16 +87,18 @@ env.act('nav0', np.array([0, 0, 0]))

# Advance the simulation
for i in range(300):
# The action provided above is repeated
s = env.tick()
# The action provided above is repeated
states = env.tick()
```

You can access the reward, terminal and location for a multi agent environment as follows:

``` python
s['uav0'][Sensors.REWARD]
s['uav0'][Sensors.TERMINAL]
s['uav0'][Sensors.LOCATION_SENSOR]
```python
task = states["uav0"]["FollowTask"]

reward = task[0]
terminal = task[1]
location = states["uav0"]["LocationSensor"]
```

(`uav0` comes from the [scenario configuration file](https://holodeck.readthedocs.io/en/latest/packages/docs/scenarios.html))
Expand Down
12 changes: 6 additions & 6 deletions docs/usage/examples/multi-agent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ Code

import holodeck
import numpy as np
from holodeck.sensors import Sensors

env = holodeck.make('CyberPunkCity-Follow')
env.reset()

env.act('uav0', np.array([0, 0, 0, 100]))
env.act('nav0', np.array([0, 0, 0]))
for i in range(300):
s = env.tick()
states = env.tick()

# s is a dictionary now
s['uav0'][Sensors.REWARD]
s['uav0'][Sensors.TERMINAL]
s['uav0'][Sensors.LOCATION_SENSOR]
# states is a dictionary
task = states["uav0"]["FollowTask"]

reward = task[0]
terminal = task[1]
location = states["uav0"]["LocationSensor"]
8 changes: 7 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def android_example():

def multi_agent_example():
"""A basic example of using multiple agents"""
env = holodeck.make("CyberPunkCity-FollowSight")
env = holodeck.make("CyberPunkCity-Follow")

cmd0 = np.array([0, 0, -2, 10])
cmd1 = np.array([0, 0, 0])
Expand All @@ -83,7 +83,13 @@ def multi_agent_example():
env.act("nav0", cmd1)
for _ in range(1000):
states = env.tick()

pixels = states["uav0"]["RGBCamera"]
location = states["uav0"]["LocationSensor"]

task = states["uav0"]["FollowTask"]
reward = task[0]
terminal = task[1]


def world_command_examples():
Expand Down

0 comments on commit 445f47e

Please sign in to comment.