library(StratTourn)
library(xtable)
library(ggplot2)
library(reshape2)
library(googleVis)
library(StratTourn)
library(xtable)
library(Shiny)
setwd("D:/libraries/StratTourn")

setwd("D:/libraries/StratTourn/studies")

tourn.name = "Tourn_Noisy_PD_20141110_054429"
tourn = load.tournament(paste0(tourn.name,".tou"))
# Data for each match
md = tourn$dt
md = add.other.var(md,c("strat","u"))
md$delta.u = md$u - md$other.u
# Names of all strategies
strats = unique(md$strat)

# Data for each round
file = tourn$rs.file
rd = fread(file)
rd = as.tbl(as.data.frame(rd))
rd = add.other.var(rd,c("strat","u"))

rank.dt = strat.rank.from.matches(md)

# Names of all strategies
strats = unique(rd$strat)

# Perhaps select a subset of strategies
used.strats = strats
used.strats = c("mystrategy.knallhart",  "coop1_duoinfernale",  "noisesafe.tit.for.tat", "paranoid" ,             "prof.strat", "erstertest1")
ard = rd

if (!identical(used.strats,strats)) {
  rows = rd$strat %in% used.strats & rd$other.strat %in% used.strats
  rd = ard[rows,]
}
end.t = 5
start.t = 1
rd = add.other.var(rd,c("x","cost","type"))
rd$cost.pair = paste0(rd$type,"_",rd$other.type)
cumd = mutate(group_by(rd,strat,other.strat, cost.pair), sum.single.x=x+other.x)
td = summarise(group_by(cumd,strat,other.strat,t,cost.pair), sum.x=mean(sum.single.x), num.obs = length(t))

t.seq = 1:min(max(td$t),end.t)
tsd = do(group_by(td, strat, other.strat, cost.pair),
         get.smoothed.vals(.,xout=t.seq, xvar="t",yvar="sum.x", wvar="num.obs", spar=0.2))

# Order strategies according to their rank
rank.strats = rank.dt$strat
tsd$strat = factor(tsd$strat, rank.strats, ordered=TRUE)
tsd$other.strat = factor(tsd$other.strat, rank.strats, ordered=TRUE)

Sum of bargaining offers (average)

tsd.big <- summarise(group_by(tsd,strat,other.strat,t), sum.x=mean(sum.x))
ggplot(data=tsd.big, aes(x=t, y =sum.x, colour = strat)) + geom_line(size=I(1)) + facet_grid(other.strat~strat)+ geom_hline(yintercept=100, size=0.5, col="black",alpha=0.5)

Sum of bargaining offers (by cost.pair)

ggplot(data=tsd, aes(x=t, y =sum.x, colour = cost.pair, group = cost.pair)) + geom_line() + facet_grid(other.strat~strat)
cat("\n")

The plots show the sum of the offers of both strategies given the cost.pair.



skranz/StratTourn documentation built on May 30, 2019, 2:02 a.m.