-
Notifications
You must be signed in to change notification settings - Fork 2
/
Agent_factory.py
130 lines (98 loc) · 4.19 KB
/
Agent_factory.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# -*- coding: utf-8 -*-
import pandas as pd
import random
import uuid
import matplotlib.pyplot as plt
import numpy as np
from cadCAD.configuration import Configuration
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor
from cadCAD.configuration.utils import config_sim
from cadCAD.configuration import append_configs
from dask.distributed import Client
import Personality_permutations as Pp
class Create_agents():
def __init__(self, number):
self.initial_number = 1
self.initial_agents = []
personality = Pp.Create_personas()
personality_mix = personality.Get_personas()
general_atributes_A = { 'uuid': uuid.uuid4(),
'type': 'A',
'name': number,
'token_wallet': {"reputation": 0},
'activity': 0,
'own_PATs': 0}
general_atributes_A.update(personality_mix)
#general_atributes_B = {'uuid': uuid.uuid4(),
# 'type': 'B',
# 'money': 20,
# 'own_PATs': 0,
# 'token_wallet': {"reputation": 0}}
#general_atributes_B.update(personality_mix)
permutation = [general_atributes_A]
for atribute in permutation:
for i in range(self.initial_number):
agent = atribute
self.initial_agents.append(agent)
def Get_initial_agents(self):
return self.initial_agents
class Create_custom_agents():
def __init__(self, nr, claimer_intention, compliance, voter, creator_intention, creator_design):
self.agents = []
#print("I am here")
general_atr_A = {'uuid': uuid.uuid4(),
'type': 'A',
'name': nr,
'token_wallet': {"reputation": 0},
'activity': 0,
'own_PATs': 0}
self.create_custom_personality_mix(claimer_intention, compliance, voter, creator_intention, creator_design)
pers_mix = self.getCustomPersona()
#print(general_atr_A)
#print("---------------------------")
#print(pers_mix)
self.custom_agent = (lambda d: d.update(pers_mix) or d)(general_atr_A)
#general_atr_A.update(pers_mix)
#print(general_atr_A)
def getCustomAgent(self):
return self.custom_agent
def create_custom_personality_mix(self, claimer_intention, compliance, voter, creator_intention, creator_design):
#print("I am here")
self.custom_persona = {}
self.custom_persona.update({'claimer': compliance,
'claimer_PAT_intention': claimer_intention,
'voter': voter,
'creator_intention': creator_intention,
'creator_design': creator_design})
#print(self.custom_persona)
def getCustomPersona(self):
return self.custom_persona
class Initial_PAT_agents():
def __init__(self, number):
self.PAT_nr = number
self.initial_PAT_agents = []
for i in range(self.PAT_nr):
init_PAT = {'uuid': uuid.uuid4(),
'type': 'PAT',
'name': i,
'creator_ID': None,
'purpose': 'noble', #'opportunistic', #'noble',
'design': 'careful',
'activity': 0}
self.initial_PAT_agents.append(init_PAT)
def Get_initial_PAT_agents(self):
return self.initial_PAT_agents
class Create_custom_PAT_agents():
def __init__(self, name, number, intention, design, cr_id):
self.PAT_agents = []
for i in range(number):
PAT = { 'uuid': uuid.uuid4(),
'type': 'PAT',
'name': name + i,
'creator_ID': cr_id,
'purpose': intention,
'design': design,
'activity': 0}
self.PAT_agents.append(PAT)
def Get_created_PAT_agents(self):
return self.PAT_agents