Example #1
0
listofagents = []

# Desired configuration
desired_configuration = [(0, 0), (100, 0), (0, 100), (100, 100)]
undirected_edges = [(0, 1), (1, 2), (2, 3), (0, 3)]
listofedges_and_distances = []

for edge in undirected_edges:
    pi = np.asarray(desired_configuration[edge[0]])
    pj = np.asarray(desired_configuration[edge[1]])
    d = np.linalg.norm(pi - pj)
    listofedges_and_distances.append((edge[0], edge[1], d))

for i in range(numagents):
    listofagents.append(
        ag.AgentDI(WHITE, i, 1000 * np.random.rand(2, 1),
                   50 - 100 * np.random.rand(2, 1)))

for agent in listofagents:
    agent.traj_draw = False

# Incidence matrix
B = np.zeros((numagents, len(listofedges_and_distances)))

for idx, edge in enumerate(listofedges_and_distances):
    B[edge[0], idx] = 1
    B[edge[1], idx] = -1

# run simulation
pygame.init()
clock = pygame.time.Clock()
fps = 50
HEIGHT = 1000

CENTERX = WIDTH / 2
CENTERY = WIDTH / 2

BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

size = [WIDTH, HEIGHT]
screen = pygame.display.set_mode(size)

agentsi = ag.AgentSI(WHITE, 1, np.array([500.0, 500.0]))
agentdi = ag.AgentDI(RED, 2, np.array([240.0, 250.0]), np.array([0.0, 6.0]))
agentuni = ag.AgentUnicycle(GREEN, 3, np.array([600.0, 600.0]),
                            np.array([5.0, 0.0]))

# run simulation
pygame.init()
clock = pygame.time.Clock()
fps = 50
dt = 1.0 / fps
time = 0

runsim = True
while (runsim):
    screen.fill(BLACK)
    agentsi.draw(screen)
    agentdi.draw(screen)
Example #3
0
CENTERY = WIDTH/2

BLACK = (  0,   0,   0)
WHITE = (255, 255, 255)
BLUE =  (  0,   0, 255)
GREEN = (  0, 255,   0)
RED =   (255,   0,   0)

size = [WIDTH, HEIGHT]
screen = pygame.display.set_mode(size)

numagents = 4
listofagents = []

for i in range(numagents):
    listofagents.append(ag.AgentDI(WHITE, i, 1000*np.random.rand(2,1), 50-100*np.random.rand(2,1)))

for agent in listofagents:
    agent.traj_draw = False

listofedges = [(0,1), (1,2), (2,3), (0,3)]

# Incidence matrix
B = np.zeros((numagents, len(listofedges)))

for idx,edge in enumerate(listofedges):
    B[edge[0],idx] =  1
    B[edge[1],idx] = -1

# run simulation
pygame.init()
HEIGHT = 1000

CENTERX = WIDTH / 2
CENTERY = WIDTH / 2

BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

size = [WIDTH, HEIGHT]
screen = pygame.display.set_mode(size)

agentsi = ag.AgentSI(WHITE, 1, np.array([[500.0], [500.0]]))
agentdi = ag.AgentDI(RED, 2, np.array([[240.0], [250.0]]),
                     np.array([[0.0], [6.0]]))
agentuni = ag.AgentUnicycle(GREEN, 3, np.array([[600.0], [600.0]]),
                            np.array([[5.0], [0.0]]))

# run simulation
pygame.init()
clock = pygame.time.Clock()
fps = 50
dt = 1.0 / fps
time = 0

runsim = True
while (runsim):
    screen.fill(BLACK)
    agentsi.draw(screen)
    agentdi.draw(screen)