1

我的计划是创造一种方法来挑选最好的口袋妖怪团队。我不确定如何从 16 个防御向量与 12 个向量的点积创建一个包含 12 个向量的所有可能组合的列表,然后对 atk 向量执行相同的操作。我的另一个问题是找到一种方法来计算每个团队中口袋妖怪的总价值。我希望我的结果看起来像这个矩阵:

团队............总统计............攻击得分............ ...................... 定义分数

(6 pokemon) (6 pokemon 的统计总和) (每个 atk 向量的点积) (每个 def 向量的点积)

这些向量代表每种口袋妖怪类型之间的攻击和防御交互

Normal.def=c(1,2,1,1,1,1,1,0,1,1,1,1,1,1,1)
Fire.def=c(1,1,1,1,2,2,.5,1,.5,2,.5,1,1,1,1)
Water.def=c(1,1,1,1,1,1,1,1,.5,.5,2,2,1,.5,1)
Electric.def=c(1,1,.5,1,2,1,1,1,1,1,1,.5,1,1,1)
Grass.def=c(1,1,2,2,.5,1,2,1,2,.5,.5,.5,1,2,1)
Ice.def=c(1,2,1,1,1,2,1,1,2,1,1,1,1,.5,1)
Fighting.def=c(1,1,2,1,1,.5,.5,1,1,1,1,1,2,1,1)
Poison.def=c(1,.5,1,.5,2,1,2,1,1,1,.5,1,2,1,1)
Ground.def=c(1,1,1,.5,1,.5,1,1,1,2,2,0,1,2,1)
Flying.def=c(1,.5,1,1,0,2,.5,1,1,1,.5,2,1,2,1)
Pyschic.def=c(1,.5,1,1,1,1,2,0,1,1,1,1,.5,1,1)
Bug.def=c(1,.5,2,2,.5,2,1,1,2,1,.5,1,1,1,1)
Rock.def=c(.5,2,.5,.5,2,1,1,1,.5,2,2,1,1,1,1)
Ghost.def=c(0,0,1,.5,1,1,.5,2,1,1,1,1,1,1,1)
Dragon.def=c(1,1,1,1,1,1,1,1,.5,.5,.5,.5,1,2,2)
Null.def=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)

Normal.atk=c(1,1,1,1,1,.5,1,0,1,1,1,1,1,1,1)
Fire.atk=c(1,1,1,1,1,.5,2,1,.5,.5,2,1,1,2,.5)
Water.atk=c(1,1,1,1,2,2,1,1,2,.5,.5,1,1,1,.5)
Electric.atk=c(1,1,2,1,0,1,1,1,1,2,.5,.5,1,1,.5)
Grass.atk=c(1,1,.5,.5,2,2,.5,1,.5,2,.5,1,1,1,.5)
Ice.atk=c(1,1,2,1,2,1,1,1,1,.5,2,1,1,.5,2)
Fighting.atk=c(2,1,.5,.5,1,2,.5,0,1,1,1,1,.5,2,1)
Poison.atk=c(1,1,1,.5,.5,.5,2,.5,1,1,2,1,1,1,1)
Ground.atk=c(1,1,0,2,1,2,.5,1,2,1,.5,2,1,1,1)
Flying.atk=c(1,2,1,1,1,.5,2,1,1,1,2,.5,1,1,1)
Pyschic.atk=c(1,2,1,2,1,1,1,1,1,1,1,1,.5,1,1)
Bug.atk=c(1,.5,.5,2,1,1,1,.5,.5,1,2,1,2,1,1)
Rock.atk=c(1,.5,2,1,.5,1,2,1,2,1,1,1,1,2,1)
Ghost.atk=c(0,1,1,1,1,1,1,2,1,1,1,1,0,1,1)
Dragon.atk=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,2)
Null.atk=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)

测试数据:

Number  Pokemon     Type_1   Type_2   Total
3       Venusaur    Grass    Poison   425
6       Charizard   Fire     Flying   425
9       Blastoise   Water    Null     425
12      Butterfree  Bug      Flying   305
15      Beedrill    Bug      Poison   305
18      Pidgeot     Normal   Flying   399
20      Raticate    Normal   Null     343
22      Fearow      Normal   Flying   381
4

1 回答 1

0

也许这个?通过使用将你的防御向量变成一个矩阵defmat<-cbind(all_your_vectors)

library(pracma)

defcomb <- combs(1:16,12) # there are 1820 such combinations

defdot <- vector()
for (j in 1:1820) defdot[j]<- defmat[,c(defcomb[j,])] %*%  defmat[,c(defcomb[j,])]

因为不清楚你想做什么,所以我用它自己点缀了子集。

于 2014-04-18T18:27:07.133 回答