re class="r">#' @export
BasicBernoulliBandit &lt;- R6::R6Class(
  inherit = Bandit,
  class = FALSE,
  public = list(
    weights = NULL,
    class_name = "BasicBernoulliBandit",
    initialize = function(weights) {
      self$weights     &lt;- weights
      self$k           &lt;- length(self$weights)
    },
    get_context = function(t) {
      context &lt;- list(
        k = self$k
      )
    },
    get_reward = function(t, context, action) {
      rewards        &lt;- as.double(runif(self$k) &lt; self$w