Big Program 2: Adventure Story
In this assignment, you will create a text-based adventure story game inspired by Zork (Wikipedia: Zork) and Choose Your Own Adventure (Wikipedia: CYOA), among others. The game play essentially has the player move through a series of locations or rooms. Each room has a description that moves typically moves along the narrative with a selection of possible actions that transition the narrative to a different room. In this particular implementation, it will be possible to design rooms with random transitions. This allows for an element of chance in the story and can be used to simulate random events with uncertain outcomes such as a roll of a die, or engaging in a battle.
A sample run of the finished program (interleaved input and output): SampleFinal.txt Grading Scheme: GradingBigPrograms.pdf – Be sure to read this fully.
Files: AdventureStory.java, Config.java and TestAdventureStory.java are provided. Be sure to download them from the links provided here.
● AdventureStory.java — Contains all the methods (as stubs) necessary for all three milestones of this program. Detailed method headers are provided for you in the file. The implementation of each method must meet the detailed descriptions in the method headers. Do not change the method headers!
● TestAdventureStory.java — Contains a framework for your test bench.
● Config.java — Whenever you need these values, use the constants defined in Config.java. The testing
may use different values for these constants.
Some sample story files are: Goldilocks.story, GoldiFight.story and NeverEnd.story
Unlike BP1, Big Program 2 is an individual assignment!
You should not share your code, or review others code for this assignment. Your code is like an essay; when discussing with classmates, talk about the ideas and concepts not the specific code. (CS200: Academic Integrity)
Project designed by Marc Renault.
Last update: 2019-04-01 1 of 5
Milestone 1: Initial Interface and Supporting Methods.
1. Create a new project in Eclipse. (AdventureStory would be a sensible choice for the project name.)
2. Download AdventureStory.java, C onfig.java and TestAdventureStory.java and save them in your
project src folder.
3. Review the contents of Config.java to become familiar with the constants.
4. Best practice: Start by writing the tests.
a. Add at least 1 more tests to the each of the test methods corresponding to the methods that you will be implementing for this milestone (see below).
5. In this milestone, you will implement the methods: promptString, promptChar, promptInt, getRoomIndex, getRoomDetails, printLine,and printString.
6. Milestone 1 Main Method: With the supporting methods written, you can write the basic main method with a play again loop. The details can be found in the method header comments in AdventureStory.java.
7. Submit your AdventureStory.java, and TestAdventureStory.java files to zyBooks for feedback and grading. We recommend you complete commenting and styling your code for each milestone as described in the Program Grading section of this document.
This milestone is due Thursday, April 11th at 6 pm, see the Program Grading section for details on bonus points and late penalties.
Note: We may use different values in the Config.java for testing.
Milestone 1 Sample run: Milestone1.txt (interleaved input and output) [Milestone1In.txt, Milestone1Out.txt]
Project designed by Marc Renault.
Last update: 2019-04-01 2 of 5
Milestone 2: Parsing the Story File
1. Best practice: Start by writing the tests.
a. Using the test methods given for this project and the previous big program, create test methods
with at least 2 additional tests for the method parseStory.
2. In this milestone, you will implement the methods: displayRoom, displayTransitions,
parseFile (Milestone 2 version as described in the method header), and parseStory.
3. Milestone 2 Main Method: The details can be found in the method header comments in
AdventureStory.java.
4. Submit your AdventureStory.java, and TestAdventureStory.java files to zyBooks for feedback and
grading. We recommend you complete commenting and styling your code for each milestone as described in the Program Grading section of this document.
This milestone is due Thursday, April 18th at 6 pm, see the Program Grading section for details on bonus points and late penalties.
Note: We may use different values in the Config.java for testing.
Milestone 2 Sample run: Milestone2.txt (interleaved input and output) [Milestone2In.txt, Milestone2Out.txt]
Note on the data structures:
● There are 2 key ArrayList data structures for the story data, one containing the room details and one containing an ArrayList of the room transitions .
● They are parallel ArrayLists, meaning that the room data at index i in rooms has the list of the transition at index i of trans.
● Each entry in the room details is a String[] of length Config.ROOM_DET_LEN. There are 3 key values stored in the array:
○ The room’s id at index Config.ROOM_ID
○ The room’s title at index Config.ROOM_TITLE ○ The room’s description at Config.ROOM_DESC
● Each entry in the room transitions ArrayList is an ArrayList of the transitions associated with a room.
● Each entry in the ArrayList of transitions for a given room is a String[] of length
Config.TRAN_DET_LEN. There are 3 key values stored in the array:
○ The transition description at index Config.TRAN_DESC
○ The transition destination which is a room id at index Config.TRAN_ROOM_ID
○ The probability weight for the transition which is Config.TRAN_PROB
For an example of parsing the story text into these two array structures, look at the test provided in the testParseStory method in TestAdventureStory.java.
Project designed by Marc Renault. Last update: 2019-04-01
3 of 5
Milestone 3: Random Transitions and Saving the Game
1. Best practice: Start by writing the tests.
a. Using the test methods given for this project and the previous big program, create test methods,
with at least 2 tests, for the methods parseBookmark, and probTrans.
2. In this milestone, you will implement the methods: parseFile (Milestone 3 version as described in
the method header), parseBookmark, probTrans, and saveBookmark.
3. Milestone 3 Main Method: The details can be found in the method header comments in
AdventureStory.java.
4. Submit your AdventureStory.java, and TestAdventureStory.java files to zyBooks for feedback and
grading. We recommend you complete commenting and styling your code for each milestone as described in the Program Grading section of this document.
This milestone is due Thursday, April 25th at 6 pm, see the Program Grading section for details on bonus points and late penalties.
Note: We may use different values in the Config.java for testing.
Milestone 3 Sample run: SampleFinal.txt (interleaved input and output) [SampleFinalIn.txt, SampleFinalOut.txt]
Project designed by Marc Renault.
Last update: 2019-04-01 4 of 5
Appendix
Debugging Tips
● Write your tests first!
● Compile, run tests and run the program often! Think about doing this with each code change and each
completed method.
● Do your tests cover a breadth (ideally all) of possible scenarios?
● Do your tests check the boundary or edge cases?
● Do your tests cover valid, but unexpected, inputs?
● Make use of print statements!
● Have you gone through the tips on the CS Website: https://cs200-www.cs.wisc.edu/wp/help/#Tips
Extensions
The are many ways your might consider improving this program. If you are interested in pursuing these extensions or others that you might think of, please submit your fully completed Milestone 3 before attempting any extensions. The instructional staff would be happy to review your extensions with you or answer questions regarding extensions, but do not submit your extensions.
Change Log
● Initial version: 2019-04-01
Project designed by Marc Renault.
Last update: 2019-04-01 5 of 5