modified md

This commit is contained in:
pg 2015-10-01 06:17:29 +02:00
parent b59051ee3a
commit da03ba7c4a
1 changed files with 25 additions and 18 deletions

View File

@ -1,26 +1,29 @@
```
```python
import random
import numpy as np
import pandas as pd
```
```
```python
random.seed(40)
```
```
```python
#simple payoff matrix
payoff_a = [(1,-1),(-2,2)]
payoff_b = [(-1, 1),(2,-2)]
```
```
```python
class Agent:
def __init__(O, payoff, name="agent"):
O.payoff = payoff
@ -41,15 +44,18 @@ class Agent:
```
```
```python
def at_random():
if random.random()>0.5: a=1
else: a=0
return a
```
```python
```
```python
def weight_random():
if random.random()>0.6666666666666666 : a=1
else: a=0
@ -57,7 +63,8 @@ def weight_random():
```
```
```python
a=Agent([(1,-1),(-2,2)], "A")
b=Agent([(-1, 1),(2,-2)],"B")
a.set_move(at_random)
@ -78,7 +85,8 @@ _=plot(np.cumsum(b.allmove))
```
```python
a=Agent([(1,-1),(-2,2)], "A")
b=Agent([(-1, 1),(2,-2)],"B")
a.set_move( lambda : 0)
@ -93,14 +101,16 @@ for i in range(0,30000):
_=plot(np.cumsum(a.allmove),color="b")
_=plot(np.cumsum(b.allmove),color="r")
```
```python
![png](output_7_0.png)
```
```python
a=Agent([(1,-1),(-2,2)], "A")
b=Agent([(-1, 1),(2,-2)],"B")
a.set_move( weight_random)
@ -129,7 +139,8 @@ _=plot(np.cumsum(b.allmove),color="r")
```
```python
figsize(16,9)
for i in range(300):
@ -154,7 +165,8 @@ for i in range(300):
```
```python
figsize(16,9)
for i in range(300):
a=Agent([(1,-1),(-2,2)], "A")
@ -176,8 +188,3 @@ for i in range(300):
![png](output_10_0.png)
```
```