1
0
mirror of https://github.com/gsi-upm/soil synced 2025-08-24 03:52:20 +00:00
This commit is contained in:
J. Fernando Sánchez
2022-10-06 15:49:10 +02:00
parent 0a9c6d8b19
commit f811ee18c5
53 changed files with 856 additions and 774 deletions

View File

@@ -1,6 +1,5 @@
from soil.agents import FSM, NetworkAgent, state, default_state
from soil import Environment
from random import random, shuffle
from itertools import islice
import logging
@@ -128,7 +127,7 @@ class Patron(FSM, NetworkAgent):
Try to become friends with another agent. The chances of
success depend on both agents' openness.
'''
if force or self['openness'] > random():
if force or self['openness'] > self.random.random():
self.env.add_edge(self, other_agent)
self.info('Made some friend {}'.format(other_agent))
return True
@@ -138,7 +137,7 @@ class Patron(FSM, NetworkAgent):
''' Look for random agents around me and try to befriend them'''
befriended = False
k = int(10*self['openness'])
shuffle(others)
self.random.shuffle(others)
for friend in islice(others, k): # random.choice >= 3.7
if friend == self:
continue

View File

@@ -8,18 +8,18 @@ network_params:
generator: empty_graph
n: 30
network_agents:
- agent_type: pubcrawl.Patron
- agent_class: pubcrawl.Patron
description: Extroverted patron
state:
openness: 1.0
weight: 9
- agent_type: pubcrawl.Patron
- agent_class: pubcrawl.Patron
description: Introverted patron
state:
openness: 0.1
weight: 1
environment_agents:
- agent_type: pubcrawl.Police
- agent_class: pubcrawl.Police
environment_class: pubcrawl.CityPubs
environment_params:
altercations: 0