knitr::opts_chunk$set(echo = TRUE) library(tidyverse) library(structtibble) library(shiny) source("R/create_enums.R", encoding = "UTF-8") source("R/simulator.R", encoding = "UTF-8")
inputPanel( numericInput( inputId = "prob_diligent", label = "Probability of Kludge when Diligent", value = "0.2", step = 0.01 ) , numericInput( inputId = "prob_kludgy", label = "Probability of Kludge when Kludgy", value = "0.8", step = 0.01 ) , numericInput( inputId = "mean_time_diligent", label = "Mean Time to Develop when Diligent", value = "5", step = "1" ) , numericInput( inputId = "mean_time_kludgy", label = "Mean Time to Develop when Kludgy", value = "3", step = "1" ) , numericInput( inputId = "sd_time", label = "Stdev of Time to develop", value = "2", step = "1" ) , numericInput( inputId = "prob_kludgy", label = "Probability of Kludge when Kludgy", value = "0.8" ) , selectInput( inputId = "action_d1", label = "Developer 1 Pure Strategy", choices = c("Diligent/Accurate", "Diligent/Innaccurate", "Kludgy/Accurate", "Kludgy/Innaccurate" ) ) , selectInput( inputId = "action_d2", label = "Developer 2 Pure Strategy", choices = c("Diligent/Accurate", "Diligent/Innaccurate", "Kludgy/Accurate", "Kludgy/Innaccurate" ) ) , selectInput( inputId = "action_r", label = "Reviewer Pure Strategy", choices = c("Careful", "Negligent") ) , numericInput( inputId = "prob_review", label = "Probability of a pull request to be reviewed", value = "0.2" ) , actionButton( inputId = "go", label = "GO!" ) ) tasks <- create_backlog() cur_time <- 0 total_time <- 1000 next_task <- NULL devs_status <- tribble( ~player, ~status, players$D1, status$Idle, players$D2, status$Idle, players$R, status$Idle ) game_results <- eventReactive(eventExpr = input$go , valueExpr = { probabilities_kludge <- tribble( ~action, ~prob, actions$Diligent, input$prob_diligent, actions$Kludgy, input$prob_kludgy ) times_to_develop <- tribble( ~action, ~mean, ~sd, actions$Diligent, input$mean_time_diligent, input$sd_time, actions$Kludgy, input$mean_time_kludgy, input$sd_time ) devs_actions <- set_devs_actions( d1 = input$action_d1, d2 = input$action_d2 ) while(cur_time < total_time){ if(!is.null(next_task)){ # switch( # next_task$ # # ) } for(dev in devs){ if (get_dev_status(devs_status, dev) == status$Idle){ browser() cur_action <- devs_actions %>% filter(player == dev) %>% pull(pull_request) cur_prob_kludge <- probabilities_kludge %>% filter(action == cur_action) %>% pull(prob) cur_mean_time <- times_to_develop %>% filter(action == cur_action) %>% pull(mean) cur_sd_time <- times_to_develop %>% filter(action == cur_action) %>% pull(sd) new_pr <- create_pull_request( developer = dev, kludge = rbinom(prob = cur_prob_kludge, n = 1, size = 1), time_to_develop = rnorm(n = 1, mean = cur_mean_time, sd = cur_sd_time ), review_status = sample( x = c( review_statuses$NotSampled, review_statuses$Waiting ), size = 1, prob = c(1 - input$prob_review, input$prob_review ) ) ) } } } })
renderText( game_results() )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.