    % displayBorder
    %----------------------------------------------------------------
    % Display the horizontal border that should appear between rows in a
    % diagram of the board.

    proc displayBorder

        for j : 1 .. boardSize
            put "+-----" ..
        end for
        put "+"

    end displayBorder


    % characterAt
    %----------------------------------------------------------------
    % To be used when drawing a 3 row by 5 column, text-based diagram of a
    % tile.  3-by-5 looks square when printed.
    %     Return the character that should be drawn at location (row,col)
    % if we are drawing the given type of tile.  The answer will depend on
    % whether or not there is a player or prize on the tile.  Player A is
    % always displayed in the upper left corner of the tile, and Player B
    % in the lower right corner.  Prizes are displayed in the middle.
    %     This function encapsulates all the information about how tiles
    % should be drawn in a text-based diagram.

    function characterAt (row : int, col : int, tile : tileType,
            playerA : boolean, playerB : boolean, prizeAt : int) : char

        if row = 1 and col = 1 and playerA then

            % Return "A" if player A is on the tile and we're printing the
            % upper left piece.
            result "A"

        elsif row = 3 and col = 5 and playerB then

            % Return "B" if player B is on the tile and we're printing the
            % lower right piece.
            result "B"

        elsif row = 2 and col = 3 then

            % Return the center of the tile.
            if prizeAt not= 0 then
                result intstr (prizeAt)
            else
                % All tile types have a "*" in their centre.
                result "*"
            end if

        elsif (row = 1 or row = 3) and (col not= 3) then

            % Return " " if the position is always blank.
            result " "

        elsif row = 1 and col = 3 then

            % Return the upper center character.
            case tile of
                label tileType.elbowUR, tileType.elbowLU, tileType.Tleft,
                        tileType.Tup, tileType.Tright,
                        tileType.straightVert, tileType.cross :
                    result "*"
                label :
                    result " "
            end case

        elsif row = 3 and col = 3 then

            % Return the bottom center character.
            case tile of
                label tileType.elbowRD, tileType.elbowDL, tileType.Tdown,
                        tileType.Tleft, tileType.Tright,
                        tileType.straightVert,
                        tileType.cross :
                    result "*"
                label :
                    result " "
            end case

        elsif row = 2 and (col = 1 or col = 2) then

            % Return the middle left characters.
            case tile of
                label tileType.elbowDL, tileType.elbowLU, tileType.Tdown,
                        tileType.Tleft, tileType.Tup, tileType.straightHoriz,
                        tileType.cross :
                    result "*"
                label :
                    result " "
            end case

        elsif row = 2 and (col = 4 or col = 5) then

            % Return the middle right characters.
            case tile of
                label tileType.elbowUR, tileType.elbowRD, tileType.Tdown,
                        tileType.Tup, tileType.Tright,
                        tileType.straightHoriz,
                        tileType.cross :
                    result "*"
                label :
                    result " "
            end case

        end if

    end characterAt



    % displayTopOfRow
    %----------------------------------------------------------------
    % Display the top line in a diagram of the given row within the board.

    proc displayTopOfRow (row : int)

        % Go by column through all the tiles in the given row.
        for col : 1 .. boardSize
            put "|" ..

            % For each tile in the row, print a strip of characters that
            % will be the top of the tile in the diagram.
            for c : 1 .. 5
                put characterAt (1, c, tileTypeAt (row, col),
                    playerAAt (row, col), playerBAt (row, col),
                    prizeAt (row, col)) ..
            end for
        end for

        put "|"

    end displayTopOfRow


    % displayMiddleOfRow
    %----------------------------------------------------------------
    % Display the middle line in a diagram of the given row within the board.

    proc displayMiddleOfRow (row : int)

        % Go by column through all the tiles in the given row.
        for col : 1 .. boardSize
            put "|" ..

            % For each tile in the row, print a strip of characters that
            % will be the middle of the tile in the diagram.
            for c : 1 .. 5
                put characterAt (2, c, tileTypeAt (row, col),
                    playerAAt (row, col), playerBAt (row, col),
                    prizeAt (row, col)) ..
            end for
        end for

        put "|"

    end displayMiddleOfRow


    % displayBottomOfRow
    %----------------------------------------------------------------
    % Display the bottom line in a diagram of the given row within the board.

    proc displayBottomOfRow (row : int)

        % Go by column through all the tiles in the given row.
        for col : 1 .. boardSize
            put "|" ..

            % For each tile in the row, print a strip of characters that
            % will be the top of the tile in the diagram.
            for c : 1 .. 5
                put characterAt (3, c, tileTypeAt (row, col),
                    playerAAt (row, col), playerBAt (row, col),
                    prizeAt (row, col)) ..
            end for
        end for

        put "|"

    end displayBottomOfRow


    % displayRow
    %----------------------------------------------------------------
    % Display row i of the board.  We must do it in three passes,
    % for the three rows of the diagram, because when printing plain
    % text (vs drawing in graphics mode) we must print rows of characters
    % from the top to bottom of a diagram. 

    proc displayRow (i : int)

        displayTopOfRow (i)
        displayMiddleOfRow (i)
        displayBottomOfRow (i)

    end displayRow


    % displayBoard
    %----------------------------------------------------------------
    % Display the current board.

    proc displayBoard

        var tPtr := board

        put ""
        % Print each of the rows.
        for i : 1 .. boardSize
            displayBorder
            displayRow (i)
        end for

        displayBorder

        put ""

    end displayBoard
