In [1]:
import sys
import seaborn as sns
sys.path.append("..")
%matplotlib inline
sns.set(rc={'image.cmap': 'Purples_r'})


/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))

Populations


In [2]:
import naminggamesal.ngpop as ngpop

Let's create a population. Agent creation is here dealt with automatically. Still, it is possible to manually add or remove agents (Hence the IDs of the agents), what will be seen later.


In [28]:
pop_cfg={
    'voc_cfg':{
        'voc_type':'matrix',
        'M':5,
        'W':10
        },
    'strat_cfg':{
        'strat_type':'naive',
        'vu_cfg':{'vu_type':'BLIS_epirob'}
        },
    'interact_cfg':{
        'interact_type':'speakerschoice'
        },
    'nbagent':5
    }


testpop=ngpop.Population(**pop_cfg)
testpop


Out[28]:
<naminggamesal.ngpop.population.Population at 0x7f20fb8d9a50>

In [29]:
print(testpop)
print
testpop.visual(vtype="agents")


nbagent: 5
[[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]]

Agent ID: 40d3d078-42c3-11e6-98c1-3cd92b6a6473

                          Words
        [[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
Meanings [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]]



Agent ID: 40d3d82a-42c3-11e6-98c1-3cd92b6a6473

                          Words
        [[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
Meanings [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]]



Agent ID: 40d3dc9e-42c3-11e6-98c1-3cd92b6a6473

                          Words
        [[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
Meanings [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]]



Agent ID: 40d3e0fe-42c3-11e6-98c1-3cd92b6a6473

                          Words
        [[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
Meanings [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]]



Agent ID: 40d3e55e-42c3-11e6-98c1-3cd92b6a6473

                          Words
        [[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
Meanings [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
         [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]]




In [32]:
testpop.play_game(100)

In [33]:
print(testpop)
testpop.visual()


nbagent: 5
[[ 0.  1.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  1.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  1.  0.  0.]
 [ 0.  0.  0.  1.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  1.  0.]]

In [11]:
testpop.visual(vtype="agents")


Agent ID: 783e4268-a265-11e5-9504-3cd92b6a6473

                               Words
        [[ 0.   0.   0.   0.   0.   0.   0.   0.5  0.   0. ]
         [ 0.3  0.   0.   0.   0.   0.   0.   0.   0.   0. ]
Meanings [ 0.   0.   0.   0.   0.   0.   0.3  0.   0.   0. ]
         [ 0.   0.   0.   0.   0.5  0.   0.   0.   0.6  0. ]
         [ 0.   0.   0.   0.   0.   0.   0.   0.   0.   0. ]]



Agent ID: 783f9758-a265-11e5-9504-3cd92b6a6473

                               Words
        [[ 0.   0.5  0.   0.   0.   0.   0.   0.   0.   0. ]
         [ 0.5  0.   0.   0.   0.   0.   0.   0.   0.   0. ]
Meanings [ 0.   0.   0.3  0.   0.   0.   0.6  0.   0.   0. ]
         [ 0.   0.   0.   0.   0.   0.   0.   0.   0.6  0. ]
         [ 0.   0.   0.   0.   0.   0.   0.   0.   0.   0. ]]



Agent ID: 78408b72-a265-11e5-9504-3cd92b6a6473

                               Words
        [[ 0.   0.5  0.   0.   0.   0.   0.   0.5  0.   0. ]
         [ 0.5  0.   0.   0.   0.   0.   0.   0.   0.   0. ]
Meanings [ 0.   0.   0.3  0.   0.   0.   0.6  0.   0.   0. ]
         [ 0.   0.   0.   0.   0.5  0.   0.   0.   0.   0. ]
         [ 0.   0.   0.   0.   0.   0.   0.   0.   0.   0. ]]




In [15]:
testpop._agentlist[0]._vocabulary._content


Out[15]:
matrix([[ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0.5],
        [ 0. ,  0. ,  0. ,  0. ,  0. ,  0.4,  0. ,  0. ,  0. ,  0. ],
        [ 0. ,  0. ,  0. ,  1. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ],
        [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ],
        [ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  1. ,  0. ]])

In [28]:
testpop._agentlist[0]._vocabulary.add(0,0,0.5)

In [ ]: