wngmv

Untitled

Apr 20th, 2018
2,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. #regular mode
  2. chassis.p <- 0.0833
  3. neuro.p <- 0.0769
  4. system.p <- 0.0564
  5. bp.p <- 0.0564
  6.  
  7.  
  8. n <- 10000
  9. runs <- rep(NA,n)
  10. for (i in 1:n){
  11. parts <- rep(NA,4)
  12. t <- 1
  13. while (sum(is.na(parts))>0) {
  14. x1 <- replicate(2,sample(2,1,prob=c(chassis.p,(1-chassis.p))))
  15. if (sum(x1==1)>0) parts[1] = 1
  16. x2 <- sample(2,1,prob=c(neuro.p,(1-neuro.p)))
  17. if (x2==1) parts[2] =1
  18.  
  19. x3 <- sample(3,1,prob=c(system.p,bp.p,(1-system.p-bp.p)))
  20.  
  21. if (x3==1){
  22. parts[3] <- 1
  23. } else if (x3== 2)
  24. parts[4] <- 1
  25. t <- t+1
  26. }
  27. runs[i] <- t
  28. }
  29.  
  30. #elite mode
  31. #rotation A
  32. #khora chassis, lato receiver
  33. rot.A.prob <- c(0.0316, 0.0201, 1- (0.0316+0.0201))
  34.  
  35. #Khora Neurop, Braton Barrel, Braton Receiver, Lato BP
  36. rot.B.prob <- c(0.0369, 0.0369, 0.0369, 0.0201, 1- (0.0369+ 0.0369+ 0.0369+ 0.0201))
  37.  
  38. #khora system,khora bp, braton stock, braton bp, lato barrel,
  39. rot.C.prob<-c(0.0316,0.0316,0.0316,0.0201,0.0316)
  40. rot.C.prob <- c(rot.C.prob, 1-sum(rot.C.prob))
  41.  
  42.  
  43. n <- 10000
  44. runs.khora <- runs.braton <- runs.lato <- rep(NA,n)
  45. for (i in 1:n){
  46. khora <- braton <- rep(NA,4)
  47. lato <- rep(NA,3)
  48. t <- 1
  49. condition = rep(0,3)
  50. while ( prod(condition) ==0 ) {
  51. x1 <- replicate(2,sample(length(rot.a.prob),1,prob=rot.A.prob))
  52. if (sum(x1==1)>0) {
  53. khora[1] <- 1
  54. } else if (sum(x1==2) >0) {
  55. lato[1] <- 1
  56. }
  57.  
  58. x2 <- sample(length(rot.b.prob),1,prob=rot.B.prob)
  59. if (x2==1) {
  60. khora[2] <- 1
  61. } else if (x2==2){
  62. braton[1] <- 1
  63. } else if (x2==3){
  64. braton[2] <- 1
  65. } else if (x2==4){
  66. lato[2] <- 1
  67. }
  68.  
  69. x3 <- sample(length(rot.C.prob),1,prob=rot.C.prob)
  70.  
  71. if (x3==1) {
  72. khora[3] <- 1
  73. } else if (x3==2){
  74. khora[4] <- 1
  75. } else if (x3==3){
  76. braton[3] <- 1
  77. } else if (x3==4){
  78. braton[4] <- 1
  79. } else if (x3==5) {
  80. lato[3] <- 1
  81. }
  82.  
  83.  
  84. if (condition[1] ==0 & sum(is.na(khora))==0) {
  85. condition[1]=1
  86. runs.khora[i] <- t
  87. }
  88.  
  89. if (condition[2] ==0 & sum(is.na(braton)) == 0) {
  90. condition[2]=1
  91. runs.braton[i] <- t
  92. }
  93.  
  94. if (condition[3] ==0 & sum(is.na(lato)) == 0) {
  95. condition[3]=1
  96. runs.lato[i] <- t
  97. }
  98.  
  99. t <- t+1
  100. }
  101. }
  102.  
  103.  
  104. #nidus
  105. p <- 0.1429
  106.  
  107. prob <- c(p,p,p,1-3*p)
  108.  
  109. N <- 10000
  110. run.nidus <- rep(NA,N)
  111. for (i in 1:N) {
  112. condition <- 0
  113. full.set <- 1:3
  114. t <- 1
  115. while (condition == 0){
  116. new <- sample(4,1,prob=prob)
  117. if (new %in% full.set) {
  118. full.set <- setdiff(full.set, new)
  119. }
  120.  
  121. if (length(full.set)==0)
  122. condition <- 1
  123. t <- t +1
  124. }
  125. run.nidus[i]<- t-1
  126. }
Advertisement
Add Comment
Please, Sign In to add comment