Spoiler - Handsome bowling scoreMaster code

I can’t understand why ten-pin bowling has such a bizarre scoring system.

Here’s the code, for reference:

//return a list of individual frame scores
public static List<int> ScoreFrames (List<int> rolls) {

	List<int> frameList = new List<int> ();
	int currentRoll = 1;
	int firstBowlOfFrameScore = 0;
	int arrayPos = 0;

	foreach (int roll in rolls) {
		if (currentRoll % 2 == 0) {
			//SECOND BOWL
			if (firstBowlOfFrameScore + roll == 10) {
				//spare
				//LOOK AHEAD AND SCORE IT STRAIGHTAWAY IF POSSIBLE
				if (arrayPos < rolls.Count - 1) {
					frameList.Add (rolls [arrayPos + 1] + 10);
				}
				currentRoll += 1;
			} else {
				//non-spare
				frameList.Add (firstBowlOfFrameScore + roll);
				currentRoll += 1;
			}
		} else if (currentRoll % 2 == 1) {
			//FIRST BOWL
			if (roll == 10) {
				//strike
				//LOOK AHEAD AND SCORE IT STRAIGHTAWAY IF POSSIBLE
				if (currentRoll == 19 && rolls.Count == arrayPos + 3) {//stike in final frame exception
					frameList.Add (rolls[arrayPos + 1] + rolls[arrayPos + 2] + 10);
					return frameList;
				} else if (arrayPos < rolls.Count - 2) {
					frameList.Add (rolls[arrayPos + 1] + rolls[arrayPos + 2] + 10);
				}
				currentRoll += 2;
			} else {
				//non-strike
				firstBowlOfFrameScore = roll;
				currentRoll += 1;
			}
		}
		arrayPos++;
	}
	return frameList;
}

Privacy & Terms