Project 3: Bowling

NC State - Fall ‘25 - CSC 236

Table of Contents

Changelog

Any relevant changes to this page after it’s released will be listed here.

  • None so far.

Due date

This project is due on Monday, November 3rd, 2025, 4:30pm ET.

You have a 15-minute buffer for any technical issues, after that you can use your project late days if needed. Please see syllabus for late days policy.

Problem

Overview

Your program will calculate the scores for two bowling players and decide the winner. See bowling scoring for the process of score calculation.

Details

You will create a file called bowling.S.

In this file, you will define a label _bowling which will be called as a subroutine. Your subroutine will receive 3 arguments:

  1. an address pointing to the input buffer (sample games)
  2. an address pointing to a two-byte variable to store player 1’s score
  3. an address pointing to a two-byte variable to store player 2’s score

Then, it should process each throw from the input buffer and calculate scores for both players. It will write P1’s score to the address given as the 2nd argument, and P2’s score to the address given as the 3rd argument.

Lastly, your subroutine should return a value of 1 if player 1 beats player 2, or a value of 2 otherwise.

Important: your subroutine must preserve:

  • the values inside the input buffer (i.e., it’s fine to move the pointer, but not to store things where it’s pointing to)
  • all non-volatile registers
  • the stack and frame pointers

Sample Games

The input buffer you receive will values similar to the STDIN values below – an ASCII string of throws for Player 1, followed immediately by throws for Player 2. There are no spaces or delimiters between throws or players. It contains 0 ~ 9 to indicate the number of pins knocked down, X to indicate a strike, and / to indicate a spare.

You can assume a wellformed input, containing only 0-9/X and with exactly the number of bytes you need for a full game.

  1. Game where only player 1 has a score:
  • Player 1 throws: 45 31 24 51 62 13 42 34 25 10
  • Player 2 throws: 00 00 00 00 00 00 00 00 00 00
  • STDIN: 4531245162134234251000000000000000000000
  • Expected P1 score: 58
  • Expected P2 score: 0
  • Expected return: 1
  1. Game where both players have a score:
  • Player 1 throws: 45 31 24 51 62 13 42 34 25 10
  • Player 2 throws: 45 31 24 51 62 13 42 34 25 10
  • STDIN: 4531245162134234251045312451621342342510
  • Expected P1 score: 58
  • Expected P2 score: 58
  • Expected return: 2
  1. Game containing spares:
  • Player 1 throws: 4/ 31 24 51 6/ 13 42 34 25 10
  • Player 2 throws: 45 31 24 51 62 13 42 34 2/ 01
  • STDIN: 4/3124516/134234251045312451621342342/01
  • Expected P1 score: 65
  • Expected P2 score: 61
  • Expected return: 1
  1. Game containing strikes:
  • Player 1 throws: 45 31 24 51 X 13 42 34 25 10
  • Player 2 throws: 45 31 24 51 62 X X 34 25 01
  • STDIN: 45312451X13423425104531245162XX342501
  • Expected P1 score: 64
  • Expected P2 score: 88
  • Expected return: 2
  1. Game containing both spares and strikes:
  • Player 1 throws: 45 31 24 51 X 1/ 42 34 25 10
  • Player 2 throws: 45 31 24 51 6/ X X 34 25 01
  • STDIN: 45312451X1/42342510453124516/XX342501
  • Expected P1 score: 80
  • Expected P2 score: 100
  • Expected return: 2
  1. Game containing spares, strikes, and extra throws on 10th frame:
  • Player 1 throws: 8/ 54 90 X X 5/ 53 63 9/ XXX
  • Player 2 throws: 8/ 54 90 X X 5/ 53 63 9/ 9/X
  • STDIN: 8/5490XX5/53639/XXX8/5490XX5/53639/9/X
  • Expected P1 score: 160
  • Expected P2 score: 149
  • Expected return: 1

Sample Workspace

You only need to write the _bowling subroutine. You do *not* need to create a _start label, nor use read/write syscalls. We have created a driver program that will do those for you.

You can either download only the driver (click here) or a webassembliss workspace, which includes the driver and skeleton for the bowling.S file (click here). Both options should allow you to complete the project.

When you submit your code for grading, you will only select the bowling.S file, as the project config will include a copy of the driver available above.

Important: You can upload the workspace by clicking on the dropdown next to Upload on webassembliss. Note that this *will delete* any code/files you currently have open in your editor, like the pop-up message will warn you.

Project Grading

Your code will be graded on documentation (20%) and accuracy (80%).

Documentation

The documentation score is calculated based on the ratio of comments and lines of code in your file. It is calculated in two equally-weighted parts:

(1) ratio of comment-only lines to all instruction lines

Say x is the ratio of your comment-only lines to all the instruction lines you have. The grade for this section follows the table below:

Cutoff Score
x >= 40% 100%
x >= 35% 75%
x >= 30% 50%
x < 30% 0%

(2) ratio of instructions with inline-comments to all instructions

Say y is the ratio of your instruction lines that have inline comments to all the instruction lines you have. The grade for this section follows the table below:

Cutoff Score
y >= 80% 100%
y >= 70% 75%
y >= 65% 50%
y < 60% 0%

Accuracy

Your code will be tested with multiple test cases. Each test case for this project is worth 1 point each, so they’re all equally weighted. All test cases for this proejct are open, so you should be able to see which ones you passed and which ones you failed when grading your code.

Submission

Grading your code

You will use webassembliss to grade your code:

On the grader page, you will enter your full name and UnityID, and upload your bowling.S solution and the bowling.pb2 project configuration file.
Click here to download the project configuration file.

Important: make sure your file is called bowling.S!

After filling in the page and clicking on submit, the page should take you to the grader results.

It might take a minute or so for your submission to be graded if there’s many people submitting, please do *not* refresh right away. If you get a timeout grading your code on the public instance (web.assembliss.app), try using the NCSU-restricted one as that one allows for a longer wait time for the request.

The grader results page shows you the total score your solution received, and has a button at the top that says Download file for submission. This button should let you download a file called Bowling_UnityID_results.json. Here’s an example of the top of the grader results page:

Figure 1: Grader results example.

The Bowling_UnityID_results.json file contains your name, ID, source code, all information about the tests you passed, and your overall score. This is the file you will submit to Moodle.

If you scroll down on the grader results, it will also show you which tests you passed, with diffs for all of them. You can also see the documentation score you received.

You can resubmit your updated code as many times as you wish to the server, so you’re able to fix any bugs you have compared to the expected test cases. Whenever you’re satisfied with the grade you received, you can submit the appropriate json file to Moodle.

There are no efficienty targets for this project, you’re fine to ignore the Source Efficiency and Execution Efficiency sections of the results.

Submitting to Moodle

You will submit your Bowling_UnityID_results.json to Moodle. The last json file you upload to Moodle will be the one considered for grading, and the timestamp of the last moodle submission will be considered the time you submitted your code for early/late submission policies.

Only files submitted through Moodle will be graded. The teaching staff will not accept submissions received through other channels (email, EdStem, etc.).

The teaching staff will only grade this project after no more submissions can be made (i.e., after the late submission window is closed).

Getting help

Please use EdStem and office hours! For EdStem, make sure to set your posts to private if you’re sharing code. We also have a planned project workday before this project is due, check the course schedule.

Hints

Bowling Scoring

A bowling game consists of 10 frames, where in each frame you’re trying to knock down 10 pins. To find the total score of a game, you simply add the score of all 10 frames together.

For frames 1 ~ 9, you can throw up to 2 balls. The 10th frame is weird, so we’ll talk about it in a second.

For frames 1 ~ 9 there are 3 cases:

  1. If you do *not* knock down all 10 pins, the score for your frame would be the number of pins you actually knocked down.

For example, say you knock down 3 pins with your first throw and 1 pin with your second, you would see 31 in the score board and the score of this frame would be 4 (3 + 1).

  1. If you knock down all 10 pins using 2 throws, the score of your frame would be 10 + your very next throw. This is called a spare.

For example, say in frame #2 you knock down 3 pins with your first throw and 7 pins with your second, you would see 3/ in the score board. Then, say you throw a 14 on frame #3. Your score for frame #2 would be 11 (10 + 1).

  1. If you knock down all 10 pins with your first throw, the score of your frame would be 10 + your two next throws. This is called a strike.

For example, say in frame #2 you knock down 10 pins with your first throw, you would see X in the score board. Then, say you throw a 14 on frame #3. Your score for frame #2 would be 15 (10 + 1 + 4).

Important: Note that 0 are treated just like any other number. So:

  1. if you miss all pins on the first throw and knocks all pins with your second one, that is a spare (0/)!
  2. if your throw after a spare is a 0, you get a bonus of 0 points. E.g., 4/01 would score 10 for the first frame and 1 on the second;
  3. if your throw(s) after a strike is a 0, you get a bonus of 0 points. E.g., X01 would score 11 for the first frame and 1 on the second.

The 10th frame

The 10th frame is scored differently from frames 1~9 and you can have up to 3 throws in this frame.

  • The score of the 10th frame is just the number of pins you knocked down. So if you hit a strike or spare, it counts for 10 points – no bonus!
  • If you hit a strike on the 1st throw, you get new pins and can throw 2 extra balls, so you will have 3 throws on the frame.
  • If you hit another strike on the 2nd throw, you get new pins and take your 3rd throw.
  • If you hit a spare on the 2nd throw, you get new pins and can throw 1 extra ball, so you will have 3 throws on the frame.

Note that, although you do *not* get bonus for strike/spare on the 10th frame, if you get a spare (strike) on the 9th frame, the bonus points comes from the first (2) throw(s) of the 10th.

Full game scoring example

Sample game taken from ref #1 below.

Throws: 8/ 54 90 X X 5/ 53 63 9/ 9/X

Scores by frame:

  1. 8/ (first throw is an 8, completed spare with 2nd throw)
  • frame score: 8 + 2 + 5 = 15
  • running total: 15
  1. 54 (first throw is a 5, second is a 4)
  • frame score: 5 + 4 = 9
  • running total: 24
  1. 90 (first throw is a 9, second is a 0)
  • frame score: 9 + 0 = 9
  • running total: 33
  1. X (first throw knocked all pins, strike)
  • frame score: 10 + 10 + 5 = 25
  • running total: 58
  1. X (first throw knocked all pins, strike)
  • frame score: 10 + 5 + 5 = 20
  • running total: 78
  1. 5/ (first throw is a 5, completed spare with 2nd throw)
  • frame score: 5 + 5 + 5 = 15
  • running total: 93
  1. 53 (first throw is a 5, second is a 3)
  • frame score: 5 + 3 = 8
  • running total: 101
  1. 63 (first throw is a 6, second is a 3)
  • frame score: 6 + 3 = 9
  • running total: 110
  1. 9/ (first throw is a 9, completed spare with 2nd throw)
  • frame score: 9 + 1 + 9 = 19
  • running total: 129
  1. 9/X (first throw is a 9, completed spare with 2nd, strike with 3rd throw)
  • frame score: 9 + 1 + 10 = 20
  • running total: 149

Extra references

If you have any questions about how to score bowling, please ask the teaching staff questions. You can also refer to:

  1. http://www.fryes4fun.com/Bowling/scoring.htm
  2. https://out-of-bounds.co.uk/how-points-are-calculated-in-bowling/

Order of implementation

The test cases are setup to give you points as you make progress towards your final solution. We suggest you implement your code in the same order we showed the sample games:

  1. Games with only Player 1 (assume 0 for P2) but no spares or strikes
  2. Games with both players but no spares or strikes
  3. Games with both players and spares but no strikes
  4. Games with both players and strikes but no spares
  5. Games with both players, spares, and strikes
  6. Games with both players, spares, strikes, and 10th frame extra throws

Break your code into pieces

It might be easier to have a subroutine to handle strikes, one to handle spares, etc. If you do take this route, make sure to pay attention to the link register (i.e., lr, x30) so you can ret to the correct spot.