For this assignment, you will write a gtkmm 3.0
snake which simulates a solitaire version of the
Snakes and Ladders (also called Chutes and Ladders) game.
Gtkmm 3.0 documentation:
- The board is numbered, starting with 1 in the lower-left square.
The numbering of the rows alternates left-to-right and right-to-left, in
- There is only one player.
- The player starts off-board (think of it as square zero).
- The game ends when the player reaches the highest-numbered square
(100, in the picture to the right)
or passes it. It is not necessary to land exactly on the last square.
- On each turn, the player presses the “Move” button and hence
moves a random amount, 1–6 spaces.
- When the player lands exactly on the low point of a ladder,
the player is transported to the high point of the ladder.
- Similarly, landing on the high point of a snake moves the player
to the low point of the snake.
- In general, ladders go up, and snakes go down, numerically.
- When the player wins, a pop-up dialog box should announce the win.
When that dialog box is acknowledged, the program terminates.
- The game has no strategy whatsoever.
- If you learned the game with different rules, then mine are right.
As an aid for testing, if you press the keys 1–9, then you go
forward that many spaces, as if you rolled that number.
If you land on a snake or ladder, then take it.
This must work no matter where the focus is (that is, no matter
what you clicked on last).
The details of the display, colors, fonts, and button layout, are up to you,
as long as they’re shown graphically (not just numbers in a text box)
and understandable to the grader. However, the general layout of the board
must be as described above:
- a square of squares with numbers in them
- first square in the lower-left
- goal square on the top row
How you portray the snakes and the ladders is up to you.
However, it must be clear to the user what you mean (perhaps after
pressing the Help button). You may use complex pictures, as shown
in the picture above, or very simple abstract representations.
It must be clear to the user where the snakes and ladders are,
and which are which. You don’t have to show the moral lessons.
The player's current position must be clearly indicated,
as explained by the Help button.
This will bring up a dialog box that explains:
and anything else that might be unclear.
- How the current position is indicated
- How the snakes are represented
- How the ladders are represented
Produce & display a random number 1–6.
It is acceptable to simply display a number, or you can display
a fancier die face, if you wish. The player will then
move forward that many spaces, taking snakes & ladders into account.
Gets rid of all windows and terminates the program
The program takes a single mandatory command-line argument,
a file containing a description of the board.
The first integer in the file is the length of the side of the square board
(10 for the board pictured above).
The remainder of the file consists of pairs of integers, which are
numbers of squares on the board. The pair α β
means that there’s a ladder going from α to β,
if α<β, or a snake going from α to β,
if α>β. The integers are surrounded by
arbitrary amounts of whitespace.
Complain to stderr and terminate the program if there are any
errors in the file, including:
- not enough or extra arguments given in
- can’t open the file
- file contains non-integers
- file doesn’t contain an odd number of integers
- any snake or ladder is outside the range of the possible
squares of the board
- any two snakes or ladders start on the same square
- a snake or ladder ends on a square that starts a snake or ladder
(can’t teleport to a teleporter)
We will not test your program with snakes and ladders that
completely obscure each other, though crossing each other is ok.
That is, for the sample board above, we wouldn’t have
a ladder that goes from 2–72, and a snake that goes from 40–24.
You don’t have to detect this as an error case.
- All displays/complaints will be via gtkmm;
messages via standard output or standard error are unacceptable,
except for problems with the board file.
- The entire game must be viewable without user intervention.
Don’t force the player to resize the board, or to scroll.
- Memory leaks are not acceptable.
- No external programs (system, popen, exec, etc.) are permitted.
- Each function of method definition must have a comment block
Turning it in
Since we don't know how many files you will use, provide a
and package your files into
snake.tar, like this:
tar -cvf snake.tar Makefile *.cc *.h
We will test your program like this:
tar -xvf snake.tar
You may use C++11 (alias C++0x) features.
How to submit your homework:
Follow the directions on the homework page.
How to receive negative points:
Turn in someone else’s work.