Exemplo n.º 1
0
    # 「相手の」シグナルが協調か攻撃かを(ノイズ付きで)返す
    def private_signal(actions, random_state):
        pattern = [[0, 0], [0, 1], [1, 0], [1, 1]]
        # 例えば実際の行動が(0, 1)なら、シグナルは(1, 0)である可能性が最も高い
        signal_probs = [[.9, .02, .02, .06], [.02, .06, .9, .02], [.02, .9, .06, .02], [.06, .02, .02, .9]]
        p = random_state.uniform()
        if actions[0] == 0 and actions[1] == 0:
            return [0, 0] if p < 0.9 else [0, 1] if p < 0.92 else [1, 0] if p < 0.94 else [1, 1]
        elif actions[0] == 0 and actions[1] == 1:
            return [1, 0] if p < 0.9 else [0, 0] if p < 0.92 else [1, 1] if p < 0.94 else [0, 1]
        elif actions[0] == 1 and actions[1] == 0:
            return [0, 1] if p < 0.9 else [1, 1] if p < 0.92 else [0, 0] if p < 0.94 else [1, 0]
        elif actions[0] == 1 and actions[1] == 1:
            return [1, 1] if p < 0.9 else [1, 0] if p < 0.92 else [0, 1] if p < 0.94 else [0, 0]
        else:
            raise ValueError

    strategies = [Strategy1, Strategy2, Strategy3, Strategy4, Strategy5,
                    Strategy6, Strategy7, Strategy8, Strategy9, Strategy10,
                    Strategy11, Strategy12, Strategy13, Strategy14, Strategy15,
                    Strategy16, Strategy17, Strategy18, Strategy19, Strategy20, 
                    Strategy21, Strategy22, Strategy23, Strategy24]
    
    game = pl.RepeatedMatrixGame(payoff, strategies, signal=private_signal, ts_length=ts_length, repeat=1000)
    game.play(mtype="private", random_seed=seed, record=True)



   
   
Exemplo n.º 2
0
import sys
from sample import *
import play as pl

sys.path.append('./user_strategies')
import ikegami
import tsuyoshi
import bocchan
import oyama
import ymagishi_pd
import ogawa_prison
import beelab
import kato
import oyataku

np.set_printoptions(precision=3)

if __name__ == '__main__':
    payoff = np.array([[2, 0], [3, 1]])
    seed = 1005
    discount_v = 0.9999
    playtimes = np.random.RandomState(seed).geometric(p=1 - discount_v)

    strategies = [
        ikegami.ikegami, tsuyoshi.allD, bocchan.Iida_tit, oyama.oyama,
        ymagishi_pd.yamagishi_pd, ogawa_prison.ogaway, beelab.ohno,
        kato.tit_for_tat, oyataku.random_strategy
    ]
    game = pl.RepeatedMatrixGame(payoff, strategies, playtimes)
    game.play()
Exemplo n.º 3
0
import play as pl

from Iida_perfect_monitoring import Iida_pm
from kato import KatoStrategy
from ikegami_perfect import Self_Centered_perfect
from mhanami_Public_Strategy import PubStrategy
from tsuyoshi import GrimTrigger
from gistfile1 import MyStrategy
from beeleb_Strategy import beeleb
from oyama import OyamaPerfectMonitoring
from ogawa import ogawa
from yamagishi_impd import yamagishi
np.set_printoptions(precision=3)


if __name__ == '__main__':
    payoff = np.array([[4, 0], [5, 2]])
    seed = 282
    rs = np.random.RandomState(seed)
    
    # 第1期は確率1で来るものとする
    discount_v = 0.97
    ts_length = rs.geometric(p=1-discount_v, size=1000)

    strategies = [Iida_pm, PubStrategy, KatoStrategy, Self_Centered_perfect, GrimTrigger, MyStrategy, beeleb, OyamaPerfectMonitoring, ogawa, yamagishi]
    game = pl.RepeatedMatrixGame(payoff, strategies, ts_length=ts_length, repeat=1000)
    game.play(mtype="perfect", random_seed=seed, record=True)