File size: 1,601 Bytes
1349781
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
tags:
- ML-Agents-SnowballTarget
- ppo
- deep-reinforcement-learning
- reinforcement-learning
- ml-agents
model-index:
- name: PPO
  results:
  - task:
      type: reinforcement-learning
      name: reinforcement-learning
    dataset:
      name: ML-Agents-SnowballTarget
      type: ML-Agents-SnowballTarget
    metrics:
    - type: mean_reward
      value: 26.02 +/- 2.14
      name: mean_reward
      verified: false
---

# **PPO** Agent playing **ML-Agents-SnowballTarget**

This is a trained model of a **PPO** agent playing **ML-Agents-SnowballTarget** using Unity ML-Agents.

## Usage

Download model and play it:

```python
from mlagents_envs.environment import UnityEnvironment
from mlagents_envs.base_env import ActionTuple
import numpy as np

# Load the environment
env = UnityEnvironment(file_name="path/to/SnowballTarget")

# Reset the environment
env.reset()
behavior_names = list(env.behavior_specs)
spec = env.behavior_specs[behavior_names[0]]

# Load your trained model
# (You'll need to implement model loading based on your training framework)

# Run the environment
decision_steps, terminal_steps = env.get_steps(behavior_names[0])

while True:
    # Get observations
    obs = decision_steps.obs[0]
    
    # Get action from your model
    # action = your_model.predict(obs)
    
    # Step the environment
    action_tuple = ActionTuple(discrete=np.array([[action]]))
    env.set_actions(behavior_names[0], action_tuple)
    env.step()
    
    decision_steps, terminal_steps = env.get_steps(behavior_names[0])
    
    if len(terminal_steps) > 0:
        break

env.close()