simulating the winner of a game when the chance of them winning is given I have this problem where there are two teams: a and b. They play a series of 5 games that are each independent of the other. The winner of each game is given a certain number of points. Whichever team has the most points at the end wins the series. Each game is played and there are no ties, either a or b wins. I am given the chances for each team to win for each game and the number of points each game is worth.
DATA
GAME  A      B     PTS
1     33.5  65.8     1
2     76.2  23.0     2
3     46.8  53.2     3
4     12.2  75.4     4
5     65.3  8.40     5
I am trying to simulate a winner for each game, then based on who wins add up their scores for each game to give a winner of the series. This would be simulated for 100 5-game series. The part I am not sure about is how to simulate a winner for an individual game based on their chance of winning. I found this link on stat.exchange about simulating head to data. This post pointed to using BradleyTerry2 R package. I read through the article and example 3.3 looks similar to what I am trying to do though I am not really sure how to implement it or how it predicts a winner. If this is not the approach to take I am open for pointers.
Here is my code so far
    install.packages("BradleyTerry2")
    library("BradleyTerry2")

    a <- c(33.5,76.2,46.8,12.2,65.3)
    b <- c(65.8,23,53.2,75.4,8.4)
    pts <- c(1,2,3,4,5)

    # simulate 100 5-game series
    for (x in 1:100)
    {
      a_pts <- 0
      b_pts <- 0

      # loop through each game to predict winner
      for (g in 1:5)
      {
        # predict winner of game
          # this is where i need help

        # give winning team pts
        if(a[g]==1)
        {
          a_pts <- a_pts + pts[g]
        }
        if(b[g]==1)
        {
          b_pts <- b_pts + pts[g]
        }
      }

      # tally up series won by a
      if(a_pts > b_pts)
      {
        a_games[x] <- 1
      }
      if(a_pts < b_pts)
      {
        a_games[x] <- 0
      }
    }

    # probability of a winning series
    sum(a_games==1)/100

At this point I am just trying to figure out how to simulate the winner of an individual game based on their chance of winning. I will fix the checks to add points to the winner based on code/variables for predicting a winner. I am fairly new to both stats and R so any suggestions for generating a simulation either in R (preferable) or using statics equations I am open to hear.
 A: Here is the code solution I came up with based on @Wes suggestion of using rbinom. I modified and cleaned up my code. This will loop through each game using rbinom to generate a 0 or 1 for N number of simulations using the probability P of winning the game. It will then loop through each game and assign the corresponding points for the games in the 5 game series if the value is 1
    a <- c(33.5,76.2,46.8,12.2,65.3)
    b <- c(65.8,23,53.2,75.4,8.4)
    pts <- c(1,2,3,4,5)
    N <- 100
    a_pts <- rep(0,N)

    # loop through each game to predict winner
    for (g in 1:5)
    {
      # predict winner of game
      P <- a[g]/100
      a_games <- rbinom(N,1,P)

      # loop through each game and assign corresponding points
      for (x in 1:N)
      {
        if(a_games[x]==1)
        {
          a_pts[x] <- a_pts[x] + pts[g]
        }
      }
    }

    # probability of a winning series
    sum(a_pts>=8)/N

A: I don't know R but i would solve the problem like this :
While (!stop)
{
  If (Rnd ()<=a [g]/100) a wins stop=true;
  If (Rnd ()<=b [g]/100) b wins stop=true;
}
Rnd () is the random generator giving a real number between 0 and 1
However i don't understand your check for winner :
If (a [g]==1) 
You should use another variable to store who won a particular game if you want to reuse the lists a [] and b []
