Computer Science Fundamentals (CS153 2004S)

Scoring a game of bliv

Summary: In this assignment, you will write a program that analyzes the results of one or more games of Bliv, a game created by my colleague, John David Stone.

Key Topical Goals: Recursion, Documentation, Verifying Preconditions, Variable-Arity Procedures


The Rules of Bliv

Bliv is the national game of the imaginary republic of Blivetia. It is played by two teams of seven players each, and involves moving an inflated ball up and down a sandy playing field with paddles.

A team scores five points (a casmot) for hitting the ball across the opposing team's goal line, four points (a riasa) if the ball crosses the opposing team's goal line while still in contact with an offensive player's paddle, and two points (a zor-patandi) if the opposing team hits or pushes the ball backwards across its own goal line. The referees can impose a one-point penalty (flagrat) against a team for certain egregious fouls.

As a game of bliv proceeds, the scorekeepers conventionally maintain a list of each team's scoring events, rather than maintaining a running point total for each team. So, near the end of a game, the scoreboard might look like this:

Corgu Raiders Varzi Dark Wolves
casmot casmot
casmot riasa
casmot flagrat
riasa casmot
casmot riasa
zor-patandi casmot

At the end of the game, the final score for each team is computed by adding together the points for the events on the list: 5 for each casmot, 4 for each riasa, 2 for each zor-patandi, and -1 for each flagrat. If the scoring lists above are final, they show a game in which the Corgu Raiders have defeated the Varzi Dark Wolves, 29-22.

Exercise 1: Scoring Procedures

The first part of this assignment is to develop three Scheme procedures that can aid in the scoring of Bliv.

The first procedure, points, should take as its argument any of the four scoring events (each represented in Scheme by a symbol), and return the number of points awarded for it:

> (points 'riasa)

The second procedure, point-total, should take a list of scoring events and return the corresponding point total:

> (point-total (list 'casmot 'riasa 'flagrat 'casmot 'riasa 'casmot))

The third procedure, winner, should take two lists as arguments, each list having as its first element a symbol identifying the team and as its remaining elements the scoring events for that team in the course of a game. It should return the symbol identifying the winner of the game, or the symbol tie if the final scores are equal.

> (winner (list 'Corgu-Raiders 'casmot 'casmot 'casmot 'riasa
                'casmot 'zor-patandi 'flagrat 'casmot 'flagrat)
          (list 'Varzi-Dark-Wolves 'casmot 'riasa 'flagrat 'casmot
                'riasa 'casmot))

Exercise 2: Designing a Bliv Tournament

The citizens of Blivetia traditionally consider each game of Bliv individually. However, they have recently come to learn that in other countries, their a leagues that combine the results of individual games to determine champions and such. Unfortunately, not all teams play each other, so such computation may be difficult.

Although the teams are happy to ask the players to rank each other based on their experience, the National Blivetian Athletic Association has determined that an algorithmic approach would be the best. They would like your help in determining and implementing an appropriate methodology.

Begin by designing a set of guidelines that determine rankings of teams. Your guidelines might include not just win/loss records, but particular kinds of points scored and such. Your rankings should reflect the creative design of Bliv. (For example, you might choose terms rather than numbers for different successes and failures.)

Next, develop a procedure, rankings, that takes as input an undertermined number of lists of lists of scoring events and outputs information on the rank or rating of each team.

>  (rankings (list (list 'Corgu-Raiders 'casmot 'casmot 'casmot 'riasa
                      'casmot 'zor-patandi 'flagrat 'casmot 'flagrat)
                (list 'Varzi-Dark-Wolves 'casmot 'riasa 'flagrat 'casmot
                      'riasa 'casmot))
          (list (list 'Shmuza-Pioneers 'flagrat 'flagrat 'casmot)
                (list 'Shuuza-Natives 'riasa 'riasa 'casmot 'flagrat)))

Developing Procedures

Developing a procedure involves writing out a comprehensive collection of sample calls that indicate how the procedure should deal with any valid arguments that it receives; drawing up a specification for the procedure that tells what arguments it expects, what results it delivers, what preconditions must be met for it to work correctly, and what postconditions are guaranteed to be satisfied when the procedure has finished its work; writing and documenting the procedure definition; and executing and checking the sample calls to make sure that they work as described. For the purposes of this assignment, you should write your procedures so that they verify their preconditions using the husk-and-kernel technique.



31 August 2001 [John David Stone]

5 September 2001 [John David Stone]

Friday, 6 February 2004 [Samuel A. Rebelsky]


Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Fri May 7 09:44:07 2004.
The source to the document was last modified on Mon Feb 9 09:58:27 2004.
This document may be found at

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky,