Elevator Input Files


For the Core, you may have used only the two files in the starter code - new.in and save.in. To test your AI for the Reach, you will want to use a variety of game input files.

File IO and Project Setup

It is imperative that your Xcode/Visual studio project is set up correctly to read and write text files. Be sure to edit the scheme for Xcode and that the files are in the correct directory in Visual Studio.

Here is a test case that you can add to your test.cpp to check if your text files, like save.in and new.in, are in the correct directory. Be sure to call file_check in your start_tests function!

void file_check() {

    // open one of the text files that are part of the starter code
    ifstream ins;

    // if the file was not in the correct directory, the stream state is fail
    if (ins.fail()) {
        cout << "Could not open new.in" << endl;
    else {
        cout << "Success! Text files are in the right directory." << endl;


If you get the message "Could not open new.in" try editing the scheme again (Mac) or checking that you have the project files in the correct directory (Windows).

If you cannot get the text files in the correct directory, then try adding the following to your file_check test.

// if the file is not in the right directory, try this:
ofstream outs;
outs << "find the file named crazyfilename in windows explorer or finder";

Then open Windows Explorer (Windows) or Finder (Mac) and search for the file named crazyfilename. Once you find the folder with that file name, copy all of the .in files from the project starter files to that directory. Then try the file_check test again.

Loading different files

How to load a different input file to play a different game.

  1. Delete the contents of save.in
  2. Make sure it is the correct file, in the directory where VS or Xcode will attempt to open files.
    • XCode: make sure to set your Scheme to the folder that contains the .in files according to these instructions
    • Visual Studio: make sure your .in files are stored in the same folder that your project is in. You should see files that end in .vcxproj in this folder (these are the files that Visual Studio creates when you make a new project)
  3. Copy contents from another file, such as randomGame.in, and paste them into save.in.
    • Sample input files can be found in the starter files, and can also be downloaded here
    • Do not forget to save the file.
  4. Run the game in your IDE.
  5. Select 1 Load save game

What is in an input file


The first six rows correspond to the values, in order, from SatisfactionIndex class:

int sumIndex;
int sumUpRequest;
int sumDownRequest;
int sumExploded;
int sumIdle;
int timeReached;

The next three rows are starting states for the elevators:

0w -> floor 0, waiting (not servicing)

The remaining rows are people:


Represents the data for a Person class instance:

11 - turn 11
f8 - currentFloor 8
t0 - targetFloor 0
a1 - angerLevel 1

Assumptions about file contents