Bowling : confused about the rules

Hi,

The rules state that:

A strike is where all ten pins are knocked down by the first throw.
The total value of a strike is 10 plus the number of pins knocked down in the next two throws.
If a strike is immediately followed by a second strike, then the value of the first strike cannot be determined until the ball is thrown one more time.

The tenth frame in the game is a special case. If someone throws a spare or a strike then they get one or two fill balls respectively. Fill balls exist to calculate the total of the 10th frame. Scoring a strike or spare on the fill ball does not give the player more fill balls. The total value of the 10th frame is the total number of pins knocked down.

So these are the rules. Then there’s a test that I do not understand.

/**
     * uuid 576faac1-7cff-4029-ad72-c16bcada79b5
     * @testdox strikes with the two roll bonus do not get bonus rolls
     */
    public function testRollingASpareWithTheTwoRollBonusDoesNotGetABonusRoll(): void
    {
        $this->rollMany(18, 0);
        $this->game->roll(10);
        $this->game->roll(10);
        $this->game->roll(10);

        $this->assertEquals(30, $this->game->score());
    }

First, the 19the frame is not a spare but a strike. Since it is not the last frame, the tenth frame of the second game, 10 + the next two throws should be counted. (right?). 10+10+10. Then we have the 20th frame and a strike gets two fill throws. 10 + 10 + ? . That’s how I understand the rules but the test suggests otherwise. So total 50 + another fill throw.

But, as soon as I posted this, I just knew I had overlooked something. This may be it:

If a strike is immediately followed by a second strike, then the value of the first strike cannot be determined until the ball is thrown one more time.

Does that mean that the maximum points you can win in a frame is 30? Two strikes can only be followed by one more throw, a strike or not.
Three strikes in a row is always 30, whether it is a tenth frame or not.

I’ve just updated this post and copied the test again. In the comments the word ‘strike’ is used and in the test I see the word ‘spare’.
testdox strikes with the two roll bonus do not get bonus rolls : does this refer to the idea that the maximum score is 30 and there’s a mistake in the function name of the test?

I see a lot of posts, it makes my head spin and I’m not getting it.

Thank you and greetings,
Karin

Does that mean that the maximum points you can win in a frame is 30?

Yes, that’s why the maximum point you can get in a tenpin 10 frames game (12 throws total) is 300

When a player does not bowl a strike, the frame is not immediately over. They receive another bowl in the same frame.

So in this test case the player has 9 frames without knocking over a single pin. Their first strike is in the 10th frame.

Thanks,

I have never bowled in my life. Maybe I should try it.

Btw, I looked at that test again and noticed a difference in the description that is commented out and the name of the function :

    /**
     * uuid 576faac1-7cff-4029-ad72-c16bcada79b5
     * @testdox strikes with the two roll bonus do not get bonus rolls
     */
    public function testRollingASpareWithTheTwoRollBonusDoesNotGetABonusRoll(): void
    {
        $this->rollMany(18, 0);
        $this->game->roll(10);
        $this->game->roll(10);
        $this->game->roll(10);

        $this->assertEquals(30, $this->game->score());
    }

In the bit that is commented out I see the word ‘strike’ but the name of the function uses the word ‘spare’. Maybe this is indeed about the maximum score and this test is not about the tenth frame but about 3 strikes in a row. What do you think?

Greets,
Karin

Hi,

I’m sorry, I’m not getting this at all.

I believe in this test case the player has 8 frames without knocking over a single pin. The first strike is in the 9th frame of the second game.

Btw, I looked at that test again and noticed a difference in the description that is commented out and the description of the test:

    /**
     * uuid 576faac1-7cff-4029-ad72-c16bcada79b5
     * @testdox strikes with the two roll bonus do not get bonus rolls
     */
    public function testRollingASpareWithTheTwoRollBonusDoesNotGetABonusRoll(): void
    {
        $this->rollMany(18, 0);
        $this->game->roll(10);
        $this->game->roll(10);
        $this->game->roll(10);

        $this->assertEquals(30, $this->game->score());
    }

In the bit that is commented out I see the word ‘strike’ but the name of the function uses the word ‘spare’. Maybe this is indeed about the maximum score and this test is not about the tenth frame but about 3 strikes in a row ?

Thanks and greets,
Karin

I can see why this could be confusing, however strike exist as an actual word in English, totally independent of the bowling game, similar to the world hit
So strikes there just mean multiple hit, and not the actual Strike property of a bowling game

Edit: seeing a post below, the test is actually a bowling strike, the name should be changed to reflect it

When i tried to implement this exercise in Clojure, i was also very confused. Very unclear instructions if you are a non native speaker. I just ended up abandoning it.

Yeah, I can see that. Also when people go out and bowl, the machine did basically all the of the work to calculate your score, you don’t have to think about anything except throwing the ball

Here is the canonical test (test specification shared across tracks):

    {
      "uuid": "576faac1-7cff-4029-ad72-c16bcada79b5",
      "description": "strikes with the two roll bonus do not get bonus rolls",
      "property": "score",
      "input": {
        "previousRolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10]
      },
      "expected": 30
    },

So in the PHP test the comment is correct but the function name should be changed.

We are taking about a single game.

[
  0, 0, // first frame
  0, 0, // second frame
  0, 0, // third frame
  0, 0, // fourth frame
  0, 0, // fifth frame
  0, 0, // sixth frame
  0, 0, // seventh frame
  0, 0, // eighth frame
  0, 0, // ninth frame
  10, // tenth frame
  10, // first fill ball
  10 // second fill ball
]
2 Likes

Oh I see, so this is actually Strike in relation to bowling term, and not just an English word. In this case I agree that the function name should probably be changed to avoid confusion
I’ve looked at some other tracks and the description name is often also the name of the function itself in the test suite, but it got changed here somehow

I’ve edited my post above to reflect this information as well. I guess people are right about the potential of confusion this could generated :sweat_smile:

It actually is the other way around. The test name wasn’t adjusted when the description from problem specification was added in the comment. The string in the comment is what is shown in the online editor and the test name should match it.

Anyone wanting to do a PR?

Hi,

Thanks. Exactly.

OMG, rollMany(18, 0) is the number of throws and not the number of frames! That’s why everybody keeps talking about the ninth frame.

Why did I not see this?

Well, I didn’t and now I do.

Thanks and greets,

Karin

Hi,

I thought rollMany(18,0) was the number of frames but it’s 18 throws.
My head is a bowling ball.

I can get on with it now.

Thanks for hanging in there.

Greets,
Karin

Hi,

Yeah, I speak Dutch at home, my English is good but bowling is not an important sport here. Nevertheless, I would post the problem on the forum. Bowling is a great exercise and native English speakers are not aware of the confusion non-native speakers experience unless you tell them.

Anyway, I was confusing the number of throws with the number of frames. rollMany(18,0) creates 18 throws, not frames.

Mybad,

Greets,
Karin

2 Likes

Well, actually the exercise could also be improved. Instead of hiding the throws behind rollMany(18,0) (a DRY principle decision, not a student friendly one) we should show what actually happens in each test.

I’ll put it on the list of changes for the track.

1 Like

Hi,

Great. Had this test been about the rules of tennis, it would have been easier for me to understand the instructions because I’ve watched it on tv and I know the rules. The rules of bowling are new to me. The word ‘frame’ got lodged in my mind and I was thinking in frames not in throws. rollMany is about throws. That was the source of all the confusion.

Thanks, greets,
Karin

1 Like