Signal8 0.1__tar.gz → 0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of Signal8 might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Signal8
3
- Version: 0.1
3
+ Version: 0.4
4
4
  Summary: A multi-agent environment inspired by the Lewis Signaling Game, featuring eight unique problem configurations with both static and dynamic adversaries.
5
5
  Home-page: https://github.com/ethanmclark1/signal8
6
6
  Author: Ethan Clark
@@ -16,13 +16,13 @@ Sig8 is an adapted version of the Simple environment, originally developed by th
16
16
 
17
17
  # Signal8
18
18
 
19
- This repository contains a simple multi-agent environment with continuous observations and a discrete action space, inspired by the Lewis Signaling game. The environment incorporates basic simulated physics to create a scenario where multiple agents must communicate and collaborate effectively to achieve their goals.
19
+ This repository contains a simple multi-agent environment with continuous observations and a discrete action space, inspired by the Lewis Signaling game. The environment incorporates basic simulated physics to create a scenario where agents must communicate and collaborate effectively to navigate around both static and dynamic adversaries to reach a goal.
20
20
 
21
21
  ## Installation
22
22
 
23
23
  ```
24
- git clone https://github.com/ethanmclark1/sig8.git
25
- cd sig8
24
+ git clone https://github.com/ethanmclark1/signal8.git
25
+ cd signal8
26
26
  pip install -r requirements.txt
27
27
  pip install -e .
28
28
  ```
@@ -30,10 +30,10 @@ pip install -e .
30
30
  ## Usage
31
31
 
32
32
  ```
33
- import sig8
33
+ import signal8
34
34
 
35
- env = sig8.env()
36
- env.reset(options={'problem_type': 'vertical'})
35
+ env = signal8.env(has_dynamic_adversaries=True)
36
+ env.reset(options={"problem_name": "v_cluster"}))
37
37
  ```
38
38
 
39
39
  ## List of Problem Scenarios
@@ -4,13 +4,13 @@ Sig8 is an adapted version of the Simple environment, originally developed by th
4
4
 
5
5
  # Signal8
6
6
 
7
- This repository contains a simple multi-agent environment with continuous observations and a discrete action space, inspired by the Lewis Signaling game. The environment incorporates basic simulated physics to create a scenario where multiple agents must communicate and collaborate effectively to achieve their goals.
7
+ This repository contains a simple multi-agent environment with continuous observations and a discrete action space, inspired by the Lewis Signaling game. The environment incorporates basic simulated physics to create a scenario where agents must communicate and collaborate effectively to navigate around both static and dynamic adversaries to reach a goal.
8
8
 
9
9
  ## Installation
10
10
 
11
11
  ```
12
- git clone https://github.com/ethanmclark1/sig8.git
13
- cd sig8
12
+ git clone https://github.com/ethanmclark1/signal8.git
13
+ cd signal8
14
14
  pip install -r requirements.txt
15
15
  pip install -e .
16
16
  ```
@@ -18,10 +18,10 @@ pip install -e .
18
18
  ## Usage
19
19
 
20
20
  ```
21
- import sig8
21
+ import signal8
22
22
 
23
- env = sig8.env()
24
- env.reset(options={'problem_type': 'vertical'})
23
+ env = signal8.env(has_dynamic_adversaries=True)
24
+ env.reset(options={"problem_name": "v_cluster"}))
25
25
  ```
26
26
 
27
27
  ## List of Problem Scenarios
@@ -0,0 +1,153 @@
1
+ import math
2
+ import numpy as np
3
+
4
+ from gymnasium.utils import EzPickle
5
+ from utils.scenario import BaseScenario
6
+ from utils.core import Agent, Landmark, World, Action
7
+ from utils.simple_env import SimpleEnv, make_env
8
+ from utils.problems import get_problem, get_problem_list
9
+
10
+ class raw_env(SimpleEnv, EzPickle):
11
+ def __init__(
12
+ self,
13
+ agent_radius=0.1,
14
+ goal_radius=0.1,
15
+ adversary_radius=0.1,
16
+ num_adversaries=4,
17
+ has_dynamic_adversaries=False,
18
+ max_cycles=500,
19
+ continuous_actions=False,
20
+ render_mode=None
21
+ ):
22
+
23
+ scenario = Scenario()
24
+ world = scenario.make_world(
25
+ agent_radius,
26
+ goal_radius,
27
+ num_adversaries,
28
+ adversary_radius,
29
+ has_dynamic_adversaries
30
+ )
31
+
32
+ super().__init__(
33
+ scenario=scenario,
34
+ world=world,
35
+ render_mode=render_mode,
36
+ max_cycles=max_cycles,
37
+ continuous_actions=continuous_actions,
38
+ )
39
+
40
+ self.metadata["agent_radius"] = agent_radius
41
+ self.metadata["goal_radius"] = goal_radius
42
+ self.metadata["num_adversaries"] = num_adversaries
43
+ self.metadata["adversary_radius"] = adversary_radius
44
+
45
+ env = make_env(raw_env)
46
+
47
+ class Scenario(BaseScenario):
48
+ def make_world(self, agent_radius, goal_radius, num_adversaries, adversary_radius, has_dynamic_adversaries):
49
+ world = World(has_dynamic_adversaries)
50
+ world.problem_scenarios = get_problem_list()
51
+
52
+ num_dynamic_adversaries = math.floor(num_adversaries / 2) if has_dynamic_adversaries else 0
53
+ num_agents = num_dynamic_adversaries + 1
54
+
55
+ world.agents = [Agent() for _ in range(num_agents)]
56
+ for i, agent in enumerate(world.agents):
57
+ agent.adversary = True if i > 0 else False
58
+ base_name = "adversary" if agent.adversary else "agent"
59
+ base_index = i - 1 if agent.adversary else 0
60
+ agent.name = f"{base_name}_{base_index}"
61
+ agent.collide = False
62
+ agent.silent = True
63
+ agent.blind = agent.adversary
64
+ agent.size = agent_radius
65
+
66
+ world.landmarks = [Landmark() for _ in range(num_adversaries - num_dynamic_adversaries + 1)]
67
+ world.landmarks[0].name = "goal_0"
68
+ world.landmarks[0].collide = False
69
+ world.landmarks[0].movable = False
70
+ world.landmarks[0].size = goal_radius
71
+
72
+ for i, landmark in enumerate(world.landmarks[1:]):
73
+ landmark.name = f"obstacle_{i}"
74
+ landmark.collide = False
75
+ landmark.size = adversary_radius
76
+
77
+ return world
78
+
79
+ def reset_world(self, world, np_random, problem_name="v_cluster"):
80
+ self.get_problem_scenario(world, problem_name)
81
+ world.problem_name = problem_name
82
+
83
+ # set state and color of both agents and landmarks
84
+ for i, agent in enumerate(world.agents):
85
+ if agent.adversary:
86
+ agent.color = np.array([0.5, 0, 0])
87
+ agent.state.p_vel = np.zeros(world.dim_p)
88
+ agent.state.p_pos = np_random.uniform(*zip(*world.dynamic_adversarial_constr[(i+1) % len(world.dynamic_adversarial_constr)]))
89
+ agent.action_callback = self.get_scripted_action
90
+ else:
91
+ agent.color = np.array([0, 0.8, 0])
92
+ agent.state.p_vel = np.zeros(world.dim_p)
93
+ agent.state.p_pos = np_random.uniform(*zip(*world.start_constr))
94
+ agent.goal = world.landmarks[0]
95
+ agent.goal.color = np.array([0, 0, 0.8])
96
+ agent.goal.state.p_vel = np.zeros(world.dim_p)
97
+ agent.goal.state.p_pos = np_random.uniform(*zip(*world.goal_constr))
98
+
99
+ for landmark in world.landmarks[1:]:
100
+ landmark.color = np.array([0.2, 0.2, 0.2])
101
+ landmark.state.p_vel = np.zeros(world.dim_p)
102
+ landmark.state.p_pos = np_random.uniform(*zip(*world.static_adversarial_constr))
103
+
104
+ # Do not need to implement this function
105
+ def reward(self, agent, world):
106
+ return 0
107
+
108
+ def observation(self, agent, world):
109
+ return np.concatenate((agent.state.p_pos, agent.state.p_vel))
110
+
111
+ # Get constraints on entities given the problem name
112
+ def get_problem_scenario(self, world, problem_name):
113
+ problem = get_problem(problem_name, world.has_dynamic_adversaries)
114
+ world.start_constr = problem['start']
115
+ world.goal_constr = problem['goal']
116
+ world.static_adversarial_constr = problem['static_adversary']
117
+
118
+ if world.has_dynamic_adversaries:
119
+ world.dynamic_adversarial_constr = problem['dynamic_adversary']
120
+
121
+ # Get scripted action for adversarial agents s.t. they move in a straight line along their constraint
122
+ def get_scripted_action(self, agent, world):
123
+ action = Action()
124
+ action.u = np.zeros(world.dim_p)
125
+ action.c = np.zeros(world.dim_c)
126
+
127
+ constr = world.dynamic_adversarial_constr[int(agent.name[-1])]
128
+ constr_size = [(abs(point[0]) + abs(point[1])) for point in constr]
129
+ dimension = 'horizontal' if constr_size[0] > constr_size[1] else 'vertical'
130
+
131
+ # Always start off moving in the positive direction
132
+ if dimension == 'horizontal':
133
+ if (agent.state.p_vel == 0).all():
134
+ action.u[0] = +1.0
135
+ else: # If moving, continue in the direction of velocity
136
+ if agent.state.p_pos[0] <= constr[0][0]: # If at left constraint, move right
137
+ action.u[0] = +1.0
138
+ elif agent.state.p_pos[0] >= constr[1][0]: # If at right constraint, move left
139
+ action.u[0] = -1.0
140
+ else: # Otherwise, follow the direction of velocity
141
+ action.u[0] = np.sign(agent.state.p_vel[0])
142
+ else:
143
+ if (agent.state.p_vel == 0).all():
144
+ action.u[1] = +1.0
145
+ else: # If moving, continue in the direction of velocity
146
+ if agent.state.p_pos[1] <= constr[0][1]: # If at bottom constraint, move up
147
+ action.u[1] = +1.0
148
+ elif agent.state.p_pos[1] >= constr[1][1]: # If at top constraint, move down
149
+ action.u[1] = -1.0
150
+ else: # Otherwise, follow the direction of velocity
151
+ action.u[1] = np.sign(agent.state.p_vel[1])
152
+
153
+ return action
File without changes
@@ -0,0 +1,4 @@
1
+ import Signal8
2
+
3
+ env = Signal8.env(has_dynamic_adversaries=True)
4
+ env.reset(options={"problem_name": "v_cluster"})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Signal8
3
- Version: 0.1
3
+ Version: 0.4
4
4
  Summary: A multi-agent environment inspired by the Lewis Signaling Game, featuring eight unique problem configurations with both static and dynamic adversaries.
5
5
  Home-page: https://github.com/ethanmclark1/signal8
6
6
  Author: Ethan Clark
@@ -16,13 +16,13 @@ Sig8 is an adapted version of the Simple environment, originally developed by th
16
16
 
17
17
  # Signal8
18
18
 
19
- This repository contains a simple multi-agent environment with continuous observations and a discrete action space, inspired by the Lewis Signaling game. The environment incorporates basic simulated physics to create a scenario where multiple agents must communicate and collaborate effectively to achieve their goals.
19
+ This repository contains a simple multi-agent environment with continuous observations and a discrete action space, inspired by the Lewis Signaling game. The environment incorporates basic simulated physics to create a scenario where agents must communicate and collaborate effectively to navigate around both static and dynamic adversaries to reach a goal.
20
20
 
21
21
  ## Installation
22
22
 
23
23
  ```
24
- git clone https://github.com/ethanmclark1/sig8.git
25
- cd sig8
24
+ git clone https://github.com/ethanmclark1/signal8.git
25
+ cd signal8
26
26
  pip install -r requirements.txt
27
27
  pip install -e .
28
28
  ```
@@ -30,10 +30,10 @@ pip install -e .
30
30
  ## Usage
31
31
 
32
32
  ```
33
- import sig8
33
+ import signal8
34
34
 
35
- env = sig8.env()
36
- env.reset(options={'problem_type': 'vertical'})
35
+ env = signal8.env(has_dynamic_adversaries=True)
36
+ env.reset(options={"problem_name": "v_cluster"}))
37
37
  ```
38
38
 
39
39
  ## List of Problem Scenarios
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ Signal8/Signal8.py
5
+ Signal8/__init__.py
6
+ Signal8/main.py
7
+ Signal8.egg-info/PKG-INFO
8
+ Signal8.egg-info/SOURCES.txt
9
+ Signal8.egg-info/dependency_links.txt
10
+ Signal8.egg-info/top_level.txt
11
+ signal8.egg-info/PKG-INFO
12
+ signal8.egg-info/SOURCES.txt
13
+ signal8.egg-info/dependency_links.txt
14
+ signal8.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ Signal8
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="Signal8",
5
- version="0.1",
5
+ version="0.4",
6
6
  packages=find_packages(),
7
7
  author="Ethan Clark",
8
8
  author_email="eclark715@gmail.com.com",
@@ -1,7 +0,0 @@
1
- LICENSE
2
- README.md
3
- setup.py
4
- Signal8.egg-info/PKG-INFO
5
- Signal8.egg-info/SOURCES.txt
6
- Signal8.egg-info/dependency_links.txt
7
- Signal8.egg-info/top_level.txt
@@ -1 +0,0 @@
1
-
File without changes
File without changes