[Question]
  [
Your task is to sum up and output one player's score in a game of 10-pin bowling after *up to* 21 **rolls**.
The rolls are represented as a sequence of integers in your [preferred method of input](https://codegolf.meta.stackexchange.com/q/2447/4372).
Each integer corresponds to the number of pins that were knocked down in that roll.
## Scoring
After each **round** the number of pins knocked down in that round is counted into the final score.
If a player knocks down all ten pins in the first roll of a round, this is a **strike**, and the round is over.
Otherwise, the round lasts for one more roll. If the second roll of a round knocks down all the remaining pins, this is a **spare**.
For each strike there is a **bonus** equal to the sum of pins knocked down in the two next rolls.
For each spare there is a bonus equal to the number of pins knocked down in the next roll.
The 10th and final round, the player may be granted extra rolls:
In case of a strike, the player gets two more rolls to make up his strike bonus.
In case of a spare, the player gets one more roll.
## Examples
```
Input: 4 3 8 2 7 1 10 7 3 0 10 2 2 10 10 5 4
Output: 131
Input: 10 10 9 1 7 3 2 7 10 1 9 10 7 1 10 10 10
Output: 183
```
## Rules
* You may assumed that the input is valid.
* As per Mego's comment I have loosened the requirements for the input/output methods to meet our [current standard](https://codegolf.meta.stackexchange.com/q/2447/4372).
* Answers in **languages that are newer than the challenge are allowed**
* Shortest code wins!
  
[Answer]
### GolfScript, 50 41 characters
```
~0]-1%~0{\.9>{+1$3$}{@+.9>3$*}if++}10*p];
```
Another attempt in GolfScript ([run it online](http://golfscript.apphb.com/?c=Oyc0IDMgOCAyIDcgMSAxMCA3IDMgMCAxMCAyIDIgMTAgMTAgNSA0JwoKfjBdLTElfjB7XC45PnsrMSQzJH17QCsuOT4zJCp9aWYrK30xMCpwXTsKCjsnMTAgMTAgOSAxIDcgMyAyIDcgMTAgMSA5IDEwIDcgMSAxMCAxMCAxMCcKCn4wXS0xJX4we1wuOT57KzEkMyR9e0ArLjk%2BMyQqfWlmKyt9MTAqcF07)).
An explanation of the code follows. The solution utilises the stack nature of the problem (consume rolls one after another) but therefore the input has to be reversed.
```
~0          # Take the input and evaluate to single numbers on the stack. Add zero.
]-1%~       # Reverse the stack (make array, reverse array, dump array)
0           # Start with a sum of zero
{           # Perform this block 10 times (once for each round)
  \         #   Take the next roll
  .9>{      #   If it is a strike
    +       #     Add the value of the roll to the sum
    1$3$    #     and duplicate top two members of the stack (i.e. next two rolls).
  }{        #   ... else ...
    @+      #     Take the next roll and add with first roll in round.
    .9>     #     Does this sum show a spare?
    3$*     #     Get next roll (potential bonus) and multiply with yes/no.
            #     Since we pushed an additional 0 in the beginning 
            #     there is a spare roll even for the last round.
  }if       #   endif
  ++        #   Add top three stack entries together
            #   (i.e. sum+2 bonus rolls for strike, sum+rolls+bonus else)
}10*        # Loop ten times
p];         # Sum is top of stack. Print sum and discard any leftover rolls.
```
Previous version:
```
~].1>.1>]zip{((.10<{@(0=@+@1>1$9><}*@}10*;]{+}.@**
```
[Answer]
## Python, 116 110 105 103 100 99 characters
```
z=map(int,raw_input().split())
s=0
exec('s+=sum(z[:2+(z[0]+z[1]>9)]);z=z[2-(z[0]>9):];'*10)
```
Spending 30 characters on input is irksome. Suggestions welcome.
Much thanks to Howard for improvements.
[Answer]
# R, 101 bytes
I am not sure why this challenge was bumped, but I like it, so I'll late answer anyways.
```
f=function(x,s=0,c=10)`if`(c&length(x),f(x[-(0:(x[1]!=10)+1)],sum(x[1:(2+(sum(x[1:2])>9))])+s,c-1),s)
```
[Try it online!](https://tio.run/##PYvvCgIhEMS/9xT2JXZxD9QuqgN7kRAOJOugDPIOfHtT7w/ssMPMb34pOe0mb8fh6yFS0IKslgL7wfVgD@@Hf44viEgO4r0B0eUnzb4gXKKhMH1K0oHisHpl8FYANMgD2UYiBUwOLEhBrOiaH7EzsSMxVU1t5kLMwZJVIe7KvK2Dy7bZ4JwurKq3Lk/EWsT0Bw "R – Try It Online")
Ungolfed:
```
f <- function(throws, score = 0, count = 10){
  if(count != 0 & length(throws) != 0){
    IsStrike <- throws[1] == 10
    IsStrikeOrSpare <- sum(throws[1:2]) >= 10
    f(throws[-c(1, 2 * !IsStrike)],
      score + sum(throws[c(1:(2 + IsStrikeOrSpare))]),
      count - 1)
  } else {
    return(score)
  }
}
```
Recursive function. Takes `x` as input, which holds the scores. Initialises the `s`cores and `c`ounts the amount of rounds thrown. 
The if statement checks if 10 rounds are thrown, or if `x` is empty. If that is the case, the score is returned. Else the function will call itself as follows:
It removes the throws from `x`, by checking if it is a strike or not. If so, the first entry is removed, else the first two. `(S=x[1]!=10)` checks for strikes. We remove (`-`) index `0:S`, where `S` is 1 if it is a strike, and 0 if not. And then we add one: `-(0:(x[1]!=10)+1)`. We pass the shortened `x` to the next call.
As for the score, this is found by taking `x[1:2]` if it is a regular turn, and `x[1:3]` if it is a strike or a spare. We check if `sum(x[1:2])` is bigger or equal than 10. If it is a strike, obviously this is the case. If it is a spare, then this works as well. So if this is TRUE, we add `x[3]` to the sum. This is then added to `s`.
[Answer]
## CoffeeScript (234 215 170)
```
z=(a)->b=(Number i for i in a.split(' ').reverse());t=0;(r=b.pop();l=b.length;if(9<r)then(t+=r;t+=b[l-1]+b[l-2];)else(f=r+b.pop();t+=f;(t+=b[l-2])if 9<f))for i in[0..9];t
```
**EDIT**: A hefty re-write, shamelessly plagiarising Howard's great stack-based approach. I'm confident more can be stripped out for accessing the last element of an array without destroying it...
[Answer]
# Ruby, 252 bytes
Accepts input into an array add all elements first, then searches for spare and strike bonus
```
s,p,t,r=0,0,1,1
o=ARGV
o.each_with_index do |m,n|
y=m.to_i
s+=y
if r<10
p+=y
if p==10&&t==1
r,p=(r+1),0
s+=o[n+1].to_i+o[n+2].to_i
elsif p<10&&t==1
t=2
elsif p<10&&t==2
t,p,r=1,0,(r+1)
elsif p==10&&t==2
t,p,r=1,0,(r+1)
s+=o[n+1].to_i
end end end
puts s
```
[Answer]
# PHP, 82 bytes
```
for($a=$argv;$r++<10;$i+=$p<10)$s+=(9<$q=$a[++$i+1]+$p=$a[$i])*$a[$i+2]+$q;echo$s;
```
takes input from command line arguments; run with `-nr` or [test it online](http://sandbox.onlinephpfunctions.com/code/5bc3e94901bd2af400521cbb42c90cfca4355121).
**breakdown**
```
for($a=$argv;       # import arguments
    $r++<10;        # loop through rounds
    $i+=$p<10)          # 6. if no strike, increment throw count again
    $s+=(9<
        $q=$a[++$i+1]+  # 1. increment throw count  2. $q=second throw plus
        $p=$a[$i]       # 3. $p=first throw
        )*$a[$i+2]      # 4. if $q>9 (strike or spare), add third throw to sum
    +$q;                # 5. add first and second throw to sum
echo$s;             # print sum
```
[Answer]
# [Perl 5](https://www.perl.org/), 65 + 2 = 67 bytes
Requires `-ap` flags
```
$\+=(($"=shift@F)<10?$"+=shift@F:10+$F[1])+$F[0]*(9<$")for 0..9}{
```
[Try it online!](https://tio.run/##K0gtyjH9/18lRttWQ0NFybY4IzOtxMFN08bQwF5FSRvGtzI00FZxizaM1QRRBrFaGpY2KkqaaflFCgZ6epa11f//GxooAJGlgqGCuYKxghGQBImABAxAbAWIvKHBv/yCksz8vOL/ur6megaGBv91EwsA "Perl 5 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~36~~ 35 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
+\µi©⁵+Ị$ḂḤị;®×Ị¤¡-
;0Ç3ƤFṣ-m€2Fḣ⁵S
```
A monadic link accepting a list of integers and returning an integer.
**[Try it online!](https://tio.run/##y0rNyan8/1875tDWzEMrHzVu1X64u0vl4Y6mhzuWPNzdbX1o3eHpQJFDSw4t1OWyNjjcbnxsidvDnYt1cx81rTFye7hjMVBP8P///6NNdBSMdRQsdBSMdBTMdRQMgcgAzAKKGkA4RmBkCOWZ6iiYxAIA "Jelly – Try It Online")**
### How?
Calculates the score of each overlapping run of three bowls as if it were one that started at the beginning of a frame and optionally appends a strike identifier (`-1`), flattens this resulting list, splits it at the strike identifiers, then discards every second result from each chunk (removing the scores of those runs that did not really start with the start of a frame).
To cater for the final frame a zero is first appended to the input (to allow the 3-wise slicing to allow a frame to start on what was the penultimate bowl) and the resulting scores are truncated to the first ten (to remove the now possible bogus 11th frame) prior to summing them up.
```
+\µi©⁵+Ị$ḂḤị;®×Ị¤¡- - Link 1, threeBowlEvaluate: list, bowlScores
                    -               e.g. [0,4,6]   [9,1,10]   [0,4,4]  [10,7,9]
 \                  - cumulative reduce with:
+                   -   addition         [0,4,10]  [9,10,20]  [0,4,8]  [10,17,26]
  µ                 - monadic chain separation, call that "left"
     ⁵              - literal ten        10        10         10       10
   i                - first index in left 3         2 (spare)  0        1 (strike)
    ©               - (copy to register for later reuse)
        $           - last two links as a monad (f(x)):
       Ị            -   abs(x) <= 1       0         0          1        1
      +             -   add x             3         2          1        2
         Ḃ          - modulo by 2         1         0          1        0
          Ḥ         - double              2         0          2        0
           ị        - index into left (both 1-indexed and modular)
                    -            ...      4        20          4       26
                  - - literal -1         -1        -1         -1       -1
                 ¡  - repeat:
            ;       - ...action: concatenate
                ¤   - ...number of times: nilad followed by link(s) as a nilad:
             ®      -   z from register   3         2          0        1
               Ị    -   abs(z) <= 1       0         0          1        1
              ×     -   multiply          0         0          0        1 (strike)
                    - ...yielding:        4         20         4        [26,-1]
;0Ç3ƤFṣ-m€2Fḣ⁵S - Main link: list bowlValues
                -                    e.g. [4,3,8,2,7,1,10,7,3,0,10,2,2,10,10,5,4]
 0              - literal zero            0
;               - concatenate             [4,3,8,2,7,1,10,7,3,0,10,2,2,10,10,5,4,0]
   3Ƥ           - for infixes of length 3:
  Ç             -   last link (1) as a monad
                -                         [7,11,17,9,8,11,[20,-1],10,3,12,[14,-1],4,12,[25,-1],[19,-1],9]
     F          - flatten                 [7,11,17,9,8,11,20,-1,10,3,12,14,-1,4,12,25,-1,19,-1,9]
       -        - literal -1              -1
      ṣ         - split at                [[7,11,17,9,8,11,20],[10,3,12,14],[4,12,25],[19],[9]]
          2     - literal two             2
        m€      - modulo slice for €ach   [[7,17,8,20],[10,12],[4,25],[19],[9]]
           F    - flatten                 [7,17,8,20,10,12,4,25,19,9]
             ⁵  - literal ten             10
            ḣ   - head to index           [7,17,8,20,10,12,4,25,19,9] (no effect this time)
              S - sum                     131
```
[Answer]
# JavaScript (ES6), ~~79 78 72 69~~ 68 bytes
```
f=([x,y,...r],n=9)=>x+y+~~r[!n|x+y>9?0:f]+(n&&f(x>9?[y,...r]:r,n-1))
```
[Try it online!](https://tio.run/##XYxRC4IwFIXf@xX2Mja8zs0ZuUD7IcMHMZVCtpgRCuFfX5vVS/deOIfDud@teTZTa6/3R6LNpXOuL7GaYQFKqa1Bl5KU1RwvMd7rl9dKIrSuVrGaxFgj1OO5kmf17Z8s6IQT4lqjJzN2dDQD7rHKQUABGRyBA2deBLBgMr98cwfIa0IiP2kaccF3f4RPS/r/8LyRfBIC9qNuFyCBUAj3Bg "JavaScript (Node.js) – Try It Online")
### Commented
```
f = (               // f is a recursive function taking:
  [x,               //   x = result of the current roll
      y,            //   y = result of the next roll
         ...r],     //   r[] = remaining results
  n = 9             //   n = remaining number of rounds
) =>                //
  x + y +           // add x + y to the score
  ~~r[              //
    !n |            // if this is the last round
    x + y > 9 ?     // or this is either a spare or a strike:
      0             //   add the result of the next roll to the score
    :               // else:
      f             //   use a dummy index so that nothing is added
  ] + (             //
    n &&            // if n is not equal to 0:
      f(            //   add the result of a recursive call:
        x > 9 ?     //     if this is a strike:
          [y, ...r] //       re-insert y into r[]
        :           //     else:
          r,        //       pass r[] unchanged
        n - 1       //     decrement n
      )             //   end of recursive call
  )                 //
```
[Answer]
## Perl, 140?
First attempt:
```
#!/usr/bin/perl
# usage: ./bowling.pl [list of scores]
@A=@ARGV;{last if(9<$n++);$a=shift@A;$S+=$a;($S+=$A[0]+$A[1])&redo if($a==10);$b=shift@A;$S+=$b;($S+=$A[0])&redo if(10==$a+$b);redo}print$S
```
Sadly, there are certain cases where it fails. I will come and redo it later.
]