-
Notifications
You must be signed in to change notification settings - Fork 3
/
ExtractInfo.py
35 lines (29 loc) · 892 Bytes
/
ExtractInfo.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 6 11:23:11 2018
@author: andrea
"""
def ExtractInfo(grid):
import numpy as np
import pandas as pd
matrix = [];
for agentInfo in grid.agentList:
agentId = agentInfo[0]
x = agentInfo[1]
y = agentInfo[2]
agentType = agentInfo[3]
agent = None
#Get current agent based on id
for agents in grid.grid[x][y]:
if agents.ID == agentId:
agent = agents
break
if agentType != 2: #Predator
v = agent.weights
v = v.tolist() + [agentType]
matrix.append(v)
#Convert list of lists to np.matrix and then in pd.Dataframe
matrix = np.matrix(matrix)
matrix = pd.DataFrame(matrix)
return matrix