Guest User

Untitled

a guest
May 8th, 2021
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. scenario1 <- function(){
  2.   ## simulate great vs good player a la Hip's probabilities
  3.   if (runif(1,0,1) <= .6 ){
  4.     great_vs_good = 'great'
  5.   } else{
  6.     great_vs_good = 'good'
  7.   }
  8.   ## simulate great vs bad player a la Hip's probabilities
  9.   if (runif(1,0,1) <= .9){
  10.     great_vs_bad = 'great'
  11.   } else{
  12.     great_vs_bad = 'bad'
  13.   }
  14.   ## simulate great vs good player a la Hip's probabilities
  15.   if (runif(1,0,1) <= .6){
  16.     good_vs_bad = 'good'
  17.   } else{
  18.     good_vs_bad = 'bad'
  19.   }
  20.   ## concatenate results
  21.   check_winner = c(great_vs_good, great_vs_bad, good_vs_bad)
  22.  
  23.   ## check for round robin re-do
  24.   if (length(unique(check_winner)) == 3){
  25.     winner = 'none'
  26.   } else{
  27.     winner = names(table(check_winner))[which.max(table(check_winner))]
  28.   }
  29.   return(winner)
  30. }
  31.  
  32. scenario2 <- function(){
  33.   ## great vs good scenario 2
  34.   if (runif(1,0,1) <= .62 ){
  35.     great_vs_good = 'great'
  36.   } else{
  37.     great_vs_good = 'good'
  38.   }
  39.   ## great vs bad scenario 2
  40.   if (runif(1,0,1) <= .95){
  41.     great_vs_bad = 'great'
  42.   } else{
  43.     great_vs_bad = 'bad'
  44.   }
  45.   ## good vs bad scenario 2
  46.   if (runif(1,0,1) <= .8){
  47.     good_vs_bad = 'good'
  48.   } else{
  49.     good_vs_bad = 'bad'
  50.   }
  51.   check_winner = c(great_vs_good, great_vs_bad, good_vs_bad)
  52.   ## check for round robin
  53.   if (length(unique(check_winner)) == 3){
  54.     winner = 'none'
  55.   } else{
  56.     winner = names(table(check_winner))[which.max(table(check_winner))]
  57.   }
  58.   return(winner)
  59. }
RAW Paste Data