Colorado State University

This file defines the header for each page. An optional "icon" image (I use the textbook):

Replace this with info about this class:

CS253: Problem Solving with C++

Fall 2013

HW 5: Snakes and Ladders

Links to the various pages for this class:

Wish I could do this: * Schedule

Description

For this assignment, you will write a gtkmm 3.0 program called snake which simulates a solitaire version of the Snakes and Ladders (also called Chutes and Ladders) game.

Gtkmm 3.0 documentation: http://www.gtkmm.org/en/documentation.html

Game Play

Cheating

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).

Display

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:

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.

Mandatory Buttons

Help
This will bring up a dialog box that explains:
  • How the current position is indicated
  • How the snakes are represented
  • How the ladders are represented
and anything else that might be unclear.
Move
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.
Quit
Gets rid of all windows and terminates the program

Board File

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:

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.

Requirements

Turning it in

Since we don't know how many files you will use, provide a Makefile, 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
    make
    ./snake boardfile

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.

Page: Main.HW5
Modified: April 19, 2013, at 08:31 AM
Wiki: pmwiki-2.2.35
CS Department
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2012 Colorado State University