YCP Logo Assignment 6: Roguelike Game

Milestone 1: Due Wednesday, March 31st by 11:59 PM

Milestone 2: Due Friday, April 9th by 11:59 PM

Getting Started

Start by downloading CS101_Assign6.zip, saving it in the directory H:\CS101.

Start a Cygwin Bash Shell and run the following commands:

cd h:
cd CS101
unzip CS101_Assign6.zip
cd CS101_Assign6

Using Notepad++, open the file


You will add your code to this file.

Run the command


when you are ready to compile the program. To run the program, run the command


Your Task

Your task is to implement a game similar to the classic dungeon crawl game Rogue.

You will implement a very basic game, with relatively simple game play. (For extra credit, you may implement additional features.)

Important: You will submit the program twice. The first submission, Milestone 1, requires only a subset of the overall game features. The second submission, Milestone 2, requires the completion of all game features.

Goal, Game Features

The goal of the game is for the player to retrieve a magical treasure known as the Orb of Zot.

The overall features of the game are as follows:

The game is played on a map consisting of rectangular rooms connected by tunnels. Your game must have at least 3 rooms.

The player's character is represented by an '@' symbol.

The game is turn based: on each turn, the player can choose which direction to move his/her character.

The player can attempt to move into any of the 8 locations immediately adjacent to the player's current location.

The player can only move into locations inside a room on the map or in a tunnel which connects rooms.

There is at least one monster, represented by an 'M'.

After the player moves, each monster can move.

If the player and a monster are in adjacent locations, the player can attack a monster by attempting to move towards the monster. If the attack succeeds, the monster's hit points decrease. If the monster's hit points reach 0, it dies.

If the player ends a turn adjacent to a monster, the monster can attack the player. If the attack succeeds, the player's hit points decrease. If the player's hit points reach 0, the player dies and the game ends and the program displays a consolation message (e.g., "Better luck next time.")

The game always shows the number of hit points the player has. The player should start out with 20 hit points when the game starts.

There is at least one treasure (the Orb of Zot), represented by a '*' symbol.

The player picks up a treasure by moving onto its location.

When the player has collected the Orb of Zot, the player wins game ends. The program should display a congratulatory message.

Here is a screenshot showing what a basic implementation of the game might look like:


The |, -, and + characters represent the walls of rooms. The . character represents the floor of a room. The # character represents a corridor the player can move through to get from one room to another. The space character represents solid rock that the player cannot move through.

Specifications and Hints


An instance of the Scene struct type represents the overall state of the game. You should add fields to this struct to represent all of the information that the game must keep track of, such as:

  • The map (where the rooms, walls, floors, and corridors are)
  • The player's location
  • The player's current hit points
  • The monster's location
  • The monster's hit points
  • The treasure location

You may find it useful to define additional struct data types. For example, a Location data type to represent locations on the map will be useful.

Representing the map

A good way to to represent the map is as a two-dimensional array of integer values, defined as a field of the Scene struct:

struct Scene {
        int map[NROWS][NCOLS];

Each integer value represents a particular kind of "terrain" on the map. For example, you might have the value 0 represent solid rock (which the player cannot move through), 1 represent the floor of a room (which the player can move over), etc.

The map should have about 20 rows and 65 columns.

The create_scene function should initialize the map, setting the array values to appropriate values in order to create the rooms and corridors of the map.


Use the numbers on the numeric keypad to allow the user to move around the map:

  • '1' means down and left
  • '2' means down
  • '3' means down and right
  • '4' means left
  • '6' means right
  • '7' means up and left
  • '8' means up
  • '9' means up and right

The update_scene function is responsible for updating the state of the game, based on the key that the user pressed. When handling the movement keys, your program must

  • check to see if the move targets a location containing a monster, and if so, attack rather than moving
  • check to see if the move targets a location that the player shouldn't be able to move through (e.g., a wall), and if so, do nothing

Monster AI

The monster should move around the map randomly, unless the player is nearby, in which case the monster should attempt to move towards (and attack) the player.

Note that the monster should not be allowed to move through walls or solid rock.

Milestone 1

Milestone 1 is due Wednesday, March 31st. For this milestone, your game should implement the following features

  • Map with at least three rooms connected by corridors (40 points)
  • The player can move around the map, and is not allowed to move through walls or rock (40 points)
  • The monster and treasure are shown, but the monster does not move (or interact with the player in any way), and the player cannot pick up the treasure (20 points)

To submit Milestone 1, make sure RoguelikeGame.cpp is saved, and from the cygwin bash shell, run the command

make milestone1

You will be prompted for your username and password as usual. Make sure you see the message indicating that the submission was successful.

Important: make sure that the confirmation message contains

Assignment: assign6_milestone1

Milestone 2

Milestone 2 is due Friday, April 9th. For this milestone, your game should implement the entire set of features described above. Grading will be determined as follows:

  • Milestone 1 features (map, movement, monster/treasure placement): 30 points
  • Monster moves randomly: 20 points
  • Monster moves towards player when nearby: 20 points
  • Combat between player and monster: 15 points
  • Player can pick up treasure to win game: 15 points

To submit Milestone 2, make sure RoguelikeGame.cpp is saved, and from the cygwin bash shell, run the command

make milestone2

Again, enter your username/password and make sure you see the message indicating a successful submission. Make sure the assignment is assign6_milestone2.

Insane extra credit

For milestone 2, you may implement the following extra credit features:

  • Multiple monsters
  • Multiple treasures
  • Randomly-generated map (hard)
  • Multiple levels, connected by stairs (hard)
  • Line of sight: player can only see monster/treasure if the view is not obstructed by wall or rock (really hard)

Important: If you implement extra credit features, you will need to include a text file called ExtraCredit.txt explaining which extra credit features you implemented, and how they work. You can create this file with Notepad++ and place it in the CS101_Assign6 directory.

Checking your submission

Important: Make sure that you check the file(s) you submitted to ensure that they are correct. Log into the server using the following URL:


You should see a list of labs and assignments. In the row for assign6_milestone1 or assign6_milestone2, click the link labeled view. You will see a list of your submissions. Download the most recent one (which should be listed first). Verify that it contains the correct files.

You are responsible for making sure that your submission contains the correct file(s).