title: Expanding one player 'Snakes&Ladders' game to a multiplayer
body: <p>Here is a code that simulates a game of Snakes and Ladders for one player:   </p>
  
  <pre><code>    ladder.df &lt;- data.frame(start=c(1,4,9,21,28,36,51,71,80), end=c(38,14,31,42,84,44,67,91,100))
  slide.df &lt;- data.frame(start=c(98,95,93,87,64,62,56,49,47,16), end=c(78,75,73,24,60,19,53,11,26,6))
  
  curLoc &lt;- 0 # Current location
  nroll &lt;- 0 # Number of rolls
  slides &lt;- 0 # Number of slides encountered
  ladders &lt;- 0 # Number of ladders encountered
  # Keep rolling dice and moving until reach 100 or greater ending the game
  while(curLoc &lt; 100) {
    roll &lt;- sample(6,1) # generate random number between [1 to 6]
    curLoc &lt;- curLoc + roll # increase position
    nroll &lt;- nroll + 1 # increase number of rolls
    # Need to check if we landed on a ladder or slide and move forward or back
    if (any(ladder.df$s %in% curLoc)) {
      curLoc &lt;- ladder.df$e[ladder.df$s %in% curLoc]
      ladders &lt;- ladders + 1
    }
    if (any(slide.df$s %in% curLoc)) {
      curLoc &lt;- slide.df$e[slide.df$s %in% curLoc]
      slides &lt;- slides + 1
    }
  }
  </code></pre>
  
  <p>Now, I would like to expand it to a number of players where the user will specify this number. I have attempted to create a function and use a 'for' loop, however, failed to come up with the piece of code that updates global variables. Many thanks in advance!  </p>