Categories
日常应用

《Stardew Valley 星露谷物语》送礼关系网

呃,前段时间入了Stardew Valley(星露谷物语)的坑,然后发现送礼是门很讲究的事情。

然后手痒痒,职业习惯使然,就顺手分析了一下送礼策略。

原始数据:Stardew Valley的官方wiki送礼页面

然后我就是想看一下怎么简单的可以携带一堆礼物然后送给不同村民。

分析办法:把官网wiki的数据抓下来,然后看一下那些东西可以同时送给多个人,又比较容易获得,这样便于有计划的生产和携带。

结果:画了一张图...v开头的是村民,其他都是礼物。前面分析在r,画图的时候还是用了gephi...便于控制。

screen-shot-2016-11-06-at-6-52-54-pm

源代码:

gift = read.csv("stardew valley gift.csv/Sheet 1-Table 1.csv", stringsAsFactors = F)

names(gift)

expand.gift = apply(gift, 1, 
      function (x) {
        gift_list = unlist(strsplit(x[2],"\n "))
        data.frame(v = x[1], g = gift_list)
        }
      )
expand.gift = do.call(rbind, expand.gift)

expand.gift$v = gsub("\n","",expand.gift$v)
expand.gift$g = gsub("[[:space:]]","",expand.gift$g)
expand.gift$v = paste0("v.",expand.gift$v)
names(expand.gift) = c("source","target")
write.csv(expand.gift, file = "expand.gift.csv", row.names = F)
expand.gift = subset(expand.gift, ! g %in% c("Prismatic Shard","Rabbit's Foot"))

expand.gift.mul = merge(expand.gift, expand.gift,
                        by.x = "v",by.y = "v")
expand.gift.mul = subset(expand.gift.mul, g.x!= g.y)

library(igraph)
gift.n = graph_from_edgelist(as.matrix(expand.gift.mul[,2:3]), T)
gift.n = as.undirected(gift.n, mode = "mutual")
V(gift.n)$size <- 1
l <- layout_with_kk(gift.n)
plot(gift.n,layout=l, vertex.label.cex	 = 0.7)

write_graph(gift.n, file = "svgift.gml",format = "gml")

原始数据:

sheet-1-table-1.csv

矢量图形:

svgift.pdf