除非源码出现问题,请勿回复
对于不屈的分析,帖子在这里:
https://tieba.baidu.com/p/6418940497
This code is under MIT lisence. Please cite author's name (Hedonist55) when reference the code.
不屈实验源码 (peach --> 桃的数量,trial ---> 实验次数,返回一个数组每个数表示在某次实验周泰在第几张屈死掉的)
indomitability.experiment <- function(peach, trial) {
deck <- rep(1:13, each=8)
result <- 1:trial
for (i in 1:trial) {
experiment.count <- rep(FALSE, 13)
deck.shuffle <- sample(deck)
end <- FALSE
index <- 1
peach.used <- 0
while (!end) {
point <- deck.shuffle[index]
if(!experiment.count[point]) {
experiment.count[point] <- TRUE
index <- index + 1
} else {
if(peach.used == peach) {
end <- TRUE
} else {
peach.used <- peach.used + 1
index <- index + 1
}
}
}
result[i] <- index
}
return(result)
}
对于不屈的分析,帖子在这里:
https://tieba.baidu.com/p/6418940497
This code is under MIT lisence. Please cite author's name (Hedonist55) when reference the code.
不屈实验源码 (peach --> 桃的数量,trial ---> 实验次数,返回一个数组每个数表示在某次实验周泰在第几张屈死掉的)
indomitability.experiment <- function(peach, trial) {
deck <- rep(1:13, each=8)
result <- 1:trial
for (i in 1:trial) {
experiment.count <- rep(FALSE, 13)
deck.shuffle <- sample(deck)
end <- FALSE
index <- 1
peach.used <- 0
while (!end) {
point <- deck.shuffle[index]
if(!experiment.count[point]) {
experiment.count[point] <- TRUE
index <- index + 1
} else {
if(peach.used == peach) {
end <- TRUE
} else {
peach.used <- peach.used + 1
index <- index + 1
}
}
}
result[i] <- index
}
return(result)
}